about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libcore/rt/local_sched.rs10
-rw-r--r--src/libcore/rt/sched.rs7
-rw-r--r--src/rt/rust_builtin.cpp4
-rw-r--r--src/rt/rustrt.def.in2
4 files changed, 15 insertions, 8 deletions
diff --git a/src/libcore/rt/local_sched.rs b/src/libcore/rt/local_sched.rs
index 895354d2218..5f7f8509a7b 100644
--- a/src/libcore/rt/local_sched.rs
+++ b/src/libcore/rt/local_sched.rs
@@ -23,6 +23,16 @@ use unstable::finally::Finally;
 
 #[cfg(test)] use rt::uv::uvio::UvEventLoop;
 
+/// Initialize the TLS key. Other ops will fail if this isn't executed first.
+pub fn init_tls_key() {
+    unsafe {
+        rust_initialize_rt_tls_key();
+        extern {
+            fn rust_initialize_rt_tls_key();
+        }
+    }
+}
+
 /// Give the Scheduler to thread-local storage
 pub fn put(sched: ~Scheduler) {
     unsafe {
diff --git a/src/libcore/rt/sched.rs b/src/libcore/rt/sched.rs
index 3abbb1f79e5..0cdc4e9602b 100644
--- a/src/libcore/rt/sched.rs
+++ b/src/libcore/rt/sched.rs
@@ -64,11 +64,8 @@ pub impl Scheduler {
 
     fn new(event_loop: ~EventLoopObject) -> Scheduler {
 
-        // Lazily initialize the global state, currently the scheduler TLS key
-        unsafe { rust_initialize_global_state(); }
-        extern {
-            fn rust_initialize_global_state();
-        }
+        // Lazily initialize the scheduler TLS key
+        local_sched::init_tls_key();
 
         Scheduler {
             event_loop: event_loop,
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 1a64066b5a9..a2f253550af 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -840,9 +840,9 @@ rust_get_rt_tls_key() {
     return &rt_key;
 }
 
-// Initialize the global state required by the new scheduler
+// Initialize the TLS key used by the new scheduler
 extern "C" CDECL void
-rust_initialize_global_state() {
+rust_initialize_rt_tls_key() {
 
     static lock_and_signal init_lock;
     static bool initialized = false;
diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in
index cdc282440b8..e3e522aa7ce 100644
--- a/src/rt/rustrt.def.in
+++ b/src/rt/rustrt.def.in
@@ -222,7 +222,7 @@ rust_uv_ip4_addrp
 rust_uv_ip6_addrp
 rust_uv_free_ip4_addr
 rust_uv_free_ip6_addr
-rust_initialize_global_state
+rust_initialize_rt_tls_key
 rust_dbg_next_port
 rust_new_memory_region
 rust_delete_memory_region