about summary refs log tree commit diff
path: root/src/rt/rust_gc.cpp
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-08-20 14:06:04 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-08-20 14:06:04 -0700
commit2f650038ad3e53d92203153eef03294a95daba41 (patch)
treee8e77b15c7828288ab47466cbc58fac34661cb84 /src/rt/rust_gc.cpp
parent15e456d54757dded70bf4a4bd8e11256f0cceb5d (diff)
downloadrust-2f650038ad3e53d92203153eef03294a95daba41.tar.gz
rust-2f650038ad3e53d92203153eef03294a95daba41.zip
rt: Move the GetProcAddress/dlsym stuff out of rust_gc.cpp into rust_abi.h
Diffstat (limited to 'src/rt/rust_gc.cpp')
-rw-r--r--src/rt/rust_gc.cpp23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/rt/rust_gc.cpp b/src/rt/rust_gc.cpp
index b83c54ed73c..cb9d7e949ad 100644
--- a/src/rt/rust_gc.cpp
+++ b/src/rt/rust_gc.cpp
@@ -6,6 +6,7 @@
 #include <vector>
 #include <stdint.h>
 
+#include "rust_abi.h"
 #include "rust_gc.h"
 #include "rust_internal.h"
 #include "rust_shape.h"
@@ -22,6 +23,8 @@
 
 namespace gc {
 
+weak_symbol<const uintptr_t> safe_point_data("rust_gc_safe_points");
+
 struct frame {
     uint8_t *bp;    // The frame pointer.
     void (*ra)();   // The return address.
@@ -77,7 +80,7 @@ class safe_point_map {
 
 public:
     safe_point_map() {
-        const uintptr_t *data = get_safe_point_data();
+        const uintptr_t *data = *safe_point_data;
         n_safe_points = *data++;
         index = (const safe_point_index_entry *)data;
         data += n_safe_points * 2;
@@ -85,22 +88,6 @@ public:
     }
 
     const safe_point *get_safe_point(void (*addr)());
-
-    static const uintptr_t *get_safe_point_data() {
-        static bool init = false;
-        static const uintptr_t *data;
-        if (!init) {
-#ifdef __WIN32__
-            data = (const uintptr_t *)GetProcAddress(GetModuleHandle(NULL),
-                                                     "rust_gc_safe_points");
-#else
-            data = (const uintptr_t *)dlsym(RTLD_DEFAULT,
-                                            "rust_gc_safe_points");
-#endif
-            init = true;
-        }
-        return data;
-    }
 };
 
 class gc {
@@ -192,7 +179,7 @@ gc::run() {
 
 void
 maybe_gc(rust_task *task) {
-    if (safe_point_map::get_safe_point_data() == NULL)
+    if (*safe_point_data == NULL)
         return;
 
     // FIXME: We ought to lock this.