From 8fc1d9db21fa9d4abd9b40d09be8fa061abb3bb5 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 17 Aug 2013 02:12:08 -0700 Subject: std: Convert the runtime TLS key to a Rust global to avoid FFI --- src/rt/rust_builtin.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/rt/rust_builtin.cpp') 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; -- cgit 1.4.1-3-g733a5