about summary refs log tree commit diff
path: root/src/libstd/thread/scoped_tls.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-06-01 19:51:57 +0000
committerbors <bors@rust-lang.org>2015-06-01 19:51:57 +0000
commita49ae5bd4378cb47fd5cfdcd0c31e04d55373696 (patch)
tree14163a282e9219494242beff9b9506a62461d0f8 /src/libstd/thread/scoped_tls.rs
parent3e561f05c00cd180ec02db4ccab2840a4aba93d2 (diff)
parent1b5f9cb1f1529e03cd9a1d60a40d17624baffa65 (diff)
downloadrust-a49ae5bd4378cb47fd5cfdcd0c31e04d55373696.tar.gz
rust-a49ae5bd4378cb47fd5cfdcd0c31e04d55373696.zip
Auto merge of #25858 - alexcrichton:disable-os-tls, r=brson
This commit adds a ./configure option called `--disable-elf-tls` which disables
ELF based TLS (that which is communicated to LLVM) on platforms which already
support it. OSX 10.6 does not support this form of TLS, and some users of Rust
need to target 10.6 and are unable to do so due to the usage of TLS. The
standard library will continue to use ELF based TLS on OSX by default (as the
officially supported platform is 10.7+), but this adds an option to compile the
standard library in a way that is compatible with 10.6.

Closes #25342
Diffstat (limited to 'src/libstd/thread/scoped_tls.rs')
-rw-r--r--src/libstd/thread/scoped_tls.rs24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/libstd/thread/scoped_tls.rs b/src/libstd/thread/scoped_tls.rs
index dda1db9aece..f0a4c318d91 100644
--- a/src/libstd/thread/scoped_tls.rs
+++ b/src/libstd/thread/scoped_tls.rs
@@ -60,9 +60,11 @@ pub struct ScopedKey<T> { inner: imp::KeyInner<T> }
 /// This macro declares a `static` item on which methods are used to get and
 /// set the value stored within.
 ///
-/// See [ScopedKey documentation](thread/struct.ScopedKey.html) for more information.
+/// See [ScopedKey documentation](thread/struct.ScopedKey.html) for more
+/// information.
 #[macro_export]
 #[allow_internal_unstable]
+#[cfg(not(no_elf_tls))]
 macro_rules! scoped_thread_local {
     (static $name:ident: $t:ty) => (
         #[cfg_attr(not(any(windows,
@@ -86,6 +88,20 @@ macro_rules! scoped_thread_local {
     );
 }
 
+#[macro_export]
+#[allow_internal_unstable]
+#[cfg(no_elf_tls)]
+macro_rules! scoped_thread_local {
+    (static $name:ident: $t:ty) => (
+        static $name: ::std::thread::ScopedKey<$t> =
+            ::std::thread::ScopedKey::new();
+    );
+    (pub static $name:ident: $t:ty) => (
+        pub static $name: ::std::thread::ScopedKey<$t> =
+            ::std::thread::ScopedKey::new();
+    );
+}
+
 #[unstable(feature = "scoped_tls",
            reason = "scoped TLS has yet to have wide enough use to fully consider \
                      stabilizing its interface")]
@@ -187,7 +203,8 @@ impl<T> ScopedKey<T> {
               target_os = "android",
               target_os = "ios",
               target_os = "openbsd",
-              target_arch = "aarch64")))]
+              target_arch = "aarch64",
+              no_elf_tls)))]
 mod imp {
     use std::cell::Cell;
 
@@ -208,7 +225,8 @@ mod imp {
           target_os = "android",
           target_os = "ios",
           target_os = "openbsd",
-          target_arch = "aarch64"))]
+          target_arch = "aarch64",
+          no_elf_tls))]
 mod imp {
     use prelude::v1::*;