summary refs log tree commit diff
path: root/src/libstd/thread/scoped_tls.rs
AgeCommit message (Collapse)AuthorLines
2015-06-01std: Fix unsoundness of std::thread::ScopedKeyAlex Crichton-32/+47
Currently the compiler has no knowledge of `#[thread_local]` which forces users to take on two burdens of unsafety: * The lifetime of the borrow of a `#[thread_local]` static is **not** `'static` * Types in `static`s are required to be `Sync` The thread-local modules mostly curb these facets of unsafety by only allowing very limited scopes of borrows as well as allowing all types to be stored in a thread-local key (regardless of whether they are `Sync`) through an `unsafe impl`. Unfortunately these measures have the consequence of being able to take the address of the key itself and send it to another thread, allowing the same key to be accessed from two different threads. This is clearly unsafe, and this commit fixes this problem with the same trick used by `LocalKey`, which is to have an indirect function call to find the address of the *current thread's* thread local. This way the address of thread local keys can safely be sent among threads as their lifetime truly is `'static`. This commit will reduce the performance of cross-crate scoped thread locals as it now requires an indirect function call, but this can likely be overcome in a future commit. Closes #25894
2015-05-28std: Add an option to disable ELF based TLSAlex Crichton-3/+21
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.
2015-05-27Use `const fn` to abstract away the contents of UnsafeCell & friends.Eduard Burtescu-65/+26
2015-05-11docs: Link from tls macros to relevant docsUlrik Sverdrup-0/+2
Fixes #25233
2015-04-28Register new snapshotsTamir Duberstein-2/+1
2015-04-13pluralize doc comment verbs and add missing periodsAndrew Paseltiner-2/+2
2015-04-12std: Work around a stability bug in threadAlex Crichton-0/+320
Make sure the unstable `scoped` modules isn't named the same as the `scoped` function. cc #24334