about summary refs log tree commit diff
path: root/src/rt/rust_log.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rt/rust_log.cpp')
-rw-r--r--src/rt/rust_log.cpp155
1 files changed, 0 insertions, 155 deletions
diff --git a/src/rt/rust_log.cpp b/src/rt/rust_log.cpp
index f7b117a8cb1..25b246c69f5 100644
--- a/src/rt/rust_log.cpp
+++ b/src/rt/rust_log.cpp
@@ -17,161 +17,6 @@
 #include "rust_crate_map.h"
 #include "util/array_list.h"
 #include "rust_util.h"
-#include "rust_task.h"
-
-/**
- * Synchronizes access to the underlying logging mechanism.
- */
-static lock_and_signal _log_lock;
-/**
- * Indicates whether we are outputting to the console.
- * Protected by _log_lock;
- */
-static bool _log_to_console = true;
-
-/*
- * Request that console logging be turned on.
- */
-void
-log_console_on() {
-    scoped_lock with(_log_lock);
-    _log_to_console = true;
-}
-
-/*
- * Request that console logging be turned off. Can be
- * overridden by the environment.
- */
-void
-log_console_off() {
-    scoped_lock with(_log_lock);
-    _log_to_console = false;
-}
-
-bool
-should_log_console() {
-    scoped_lock with(_log_lock);
-    return _log_to_console;
-}
-
-rust_log::rust_log(rust_sched_loop *sched_loop) :
-    _sched_loop(sched_loop) {
-}
-
-rust_log::~rust_log() {
-
-}
-
-const uint16_t
-hash(uintptr_t ptr) {
-#   if(ULONG_MAX == 0xFFFFFFFF)
-    // Robert Jenkins' 32 bit integer hash function
-    ptr = (ptr + 0x7ed55d16) + (ptr << 12);
-    ptr = (ptr ^ 0xc761c23c) ^ (ptr >> 19);
-    ptr = (ptr + 0x165667b1) + (ptr << 5);
-    ptr = (ptr + 0xd3a2646c) ^ (ptr << 9);
-    ptr = (ptr + 0xfd7046c5) + (ptr << 3);
-    ptr = (ptr ^ 0xb55a4f09) ^ (ptr >> 16);
-#   elif(ULONG_MAX == 0xFFFFFFFFFFFFFFFF)
-    // "hash64shift()" from http://www.concentric.net/~Ttwang/tech/inthash.htm
-    ptr = (~ptr) + (ptr << 21); // ptr = (ptr << 21) - ptr - 1;
-    ptr = ptr ^ (ptr >> 24);
-    ptr = (ptr + (ptr << 3)) + (ptr << 8); // ptr * 265
-    ptr = ptr ^ (ptr >> 14);
-    ptr = (ptr + (ptr << 2)) + (ptr << 4); // ptr * 21
-    ptr = ptr ^ (ptr >> 28);
-    ptr = ptr + (ptr << 31);
-#   else
-#   error "hash() not defined for this pointer size"
-#   endif
-    return (uint16_t) ptr;
-}
-
-char *
-copy_string(char *dst, const char *src, size_t length) {
-    return strncpy(dst, src, length) + length;
-}
-
-char *
-append_string(char *buffer, const char *format, ...) {
-    if (buffer != NULL && format) {
-        va_list args;
-        va_start(args, format);
-        size_t off = strlen(buffer);
-        vsnprintf(buffer + off, BUF_BYTES - off, format, args);
-        va_end(args);
-    }
-    return buffer;
-}
-
-void
-rust_log::log(rust_task* task, uint32_t level, char const *fmt, ...) {
-    char buf[BUF_BYTES];
-    va_list args;
-    va_start(args, fmt);
-    int formattedbytes = vsnprintf(buf, sizeof(buf), fmt, args);
-    if( formattedbytes and (unsigned)formattedbytes > BUF_BYTES ){
-        const char truncatedstr[] = "[...]";
-        memcpy( &buf[BUF_BYTES-sizeof(truncatedstr)],
-                truncatedstr,
-                sizeof(truncatedstr));
-    }
-    trace_ln(task, level, buf);
-    va_end(args);
-}
-
-void
-rust_log::trace_ln(char *prefix, char *message) {
-    char buffer[BUF_BYTES] = "";
-    _log_lock.lock();
-    append_string(buffer, "%s", prefix);
-    append_string(buffer, "%s", message);
-    if (_log_to_console) {
-        fprintf(stderr, "rust: %s\n", buffer);
-        fflush(stderr);
-    }
-    _log_lock.unlock();
-}
-
-void
-rust_log::trace_ln(rust_task *task, uint32_t level, char *message) {
-
-    if (task) {
-        // There is not enough room to be logging on the rust stack
-        assert(!task->on_rust_stack() && "logging on rust stack");
-    }
-
-    // FIXME (#2672): The scheduler and task names used to have meaning,
-    // but they are always equal to 'main' currently
-#if 0
-
-#if defined(__WIN32__)
-    uint32_t thread_id = 0;
-#else
-    uint32_t thread_id = hash((uintptr_t) pthread_self());
-#endif
-
-    char prefix[BUF_BYTES] = "";
-    if (_sched_loop && _sched_loop-.name) {
-        append_string(prefix, "%04" PRIxPTR ":%.10s:",
-                      thread_id, _sched_loop->name);
-    } else {
-        append_string(prefix, "%04" PRIxPTR ":0x%08" PRIxPTR ":",
-                      thread_id, (uintptr_t) _sched_loop);
-    }
-    if (task) {
-        if (task->name) {
-            append_string(prefix, "%.10s:", task->name);
-        } else {
-            append_string(prefix, "0x%08" PRIxPTR ":", (uintptr_t) task);
-        }
-    }
-#else
-    char prefix[BUF_BYTES] = "";
-#endif
-
-    trace_ln(prefix, message);
-}
 
 // Reading log directives and setting log level vars