about summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-08-17 02:12:08 -0700
committerBrian Anderson <banderson@mozilla.com>2013-08-24 15:46:03 -0700
commit8fc1d9db21fa9d4abd9b40d09be8fa061abb3bb5 (patch)
tree543ee79365aff171c5555d4a0582696619c298a7 /src/rt/rust_builtin.cpp
parenta37bdde3f9c0b711ecfbaffa5b00b8272d76b131 (diff)
downloadrust-8fc1d9db21fa9d4abd9b40d09be8fa061abb3bb5.tar.gz
rust-8fc1d9db21fa9d4abd9b40d09be8fa061abb3bb5.zip
std: Convert the runtime TLS key to a Rust global to avoid FFI
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 6f3a3bd3686..27cc486c39e 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -447,19 +447,14 @@ rust_readdir() {
 #endif
 
 #ifndef _WIN32
-pthread_key_t rt_key = -1;
+typedef pthread_key_t tls_key;
 #else
-DWORD rt_key = -1;
+typedef DWORD tls_key;
 #endif
 
-extern "C" void*
-rust_get_rt_tls_key() {
-    return &rt_key;
-}
-
 // Initialize the TLS key used by the new scheduler
 extern "C" CDECL void
-rust_initialize_rt_tls_key() {
+rust_initialize_rt_tls_key(tls_key *key) {
 
     static lock_and_signal init_lock;
     static bool initialized = false;
@@ -469,10 +464,10 @@ rust_initialize_rt_tls_key() {
     if (!initialized) {
 
 #ifndef _WIN32
-        assert(!pthread_key_create(&rt_key, NULL));
+        assert(!pthread_key_create(key, NULL));
 #else
-        rt_key = TlsAlloc();
-        assert(rt_key != TLS_OUT_OF_INDEXES);
+        *key = TlsAlloc();
+        assert(*key != TLS_OUT_OF_INDEXES);
 #endif
 
         initialized = true;