summary refs log tree commit diff
path: root/src/rt/rust_log.cpp
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2011-10-13 12:23:50 -0700
committerBrian Anderson <banderson@mozilla.com>2011-11-02 14:13:22 -0700
commit8011e3fabb38e5bbc40038b540459595cce7a995 (patch)
treef4e5e59cce6db49091f8613dab24cffc383d6cfa /src/rt/rust_log.cpp
parent020cd360e1e4406c3dae93004b45104a2324d3c7 (diff)
downloadrust-8011e3fabb38e5bbc40038b540459595cce7a995.tar.gz
rust-8011e3fabb38e5bbc40038b540459595cce7a995.zip
hack around on makefiles trying to get a 64 bit build
right now there are many temporary hacks, search for NDM to find them
Diffstat (limited to 'src/rt/rust_log.cpp')
-rw-r--r--src/rt/rust_log.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/rt/rust_log.cpp b/src/rt/rust_log.cpp
index b4d26c780e6..e0d799f7caa 100644
--- a/src/rt/rust_log.cpp
+++ b/src/rt/rust_log.cpp
@@ -26,6 +26,7 @@ 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);
@@ -33,6 +34,18 @@ hash(uintptr_t ptr) {
     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;
 }
 
@@ -72,7 +85,7 @@ rust_log::trace_ln(rust_task *task, uint32_t level, char *message) {
 #if defined(__WIN32__)
     uint32_t thread_id = 0;
 #else
-    uint32_t thread_id = hash((uint32_t) pthread_self());
+    uint32_t thread_id = hash((uintptr_t) pthread_self());
 #endif
     char prefix[BUF_BYTES] = "";
     if (_sched && _sched->name) {