diff options
| author | bors <bors@rust-lang.org> | 2014-12-09 19:12:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-09 19:12:02 +0000 |
| commit | b25e100173effba685d076cee16f8af150078617 (patch) | |
| tree | 6c045a3ce5fe575f6e4e4663d4e748780e7416cd /src/libstd/sys | |
| parent | ef4982f0f8643af9e7deede95ad5e4e8df854d66 (diff) | |
| parent | 1a61fe4280b476bb2131f76414c32676b91e163c (diff) | |
| download | rust-b25e100173effba685d076cee16f8af150078617.tar.gz rust-b25e100173effba685d076cee16f8af150078617.zip | |
auto merge of #19665 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/common/thread_local.rs | 18 | ||||
| -rw-r--r-- | src/libstd/sys/windows/fs.rs | 2 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/libstd/sys/common/thread_local.rs b/src/libstd/sys/common/thread_local.rs index 370d74cc5e1..3eb0e3f46cb 100644 --- a/src/libstd/sys/common/thread_local.rs +++ b/src/libstd/sys/common/thread_local.rs @@ -185,7 +185,23 @@ impl StaticKey { } unsafe fn lazy_init(&self) -> uint { - let key = imp::create(self.dtor); + // POSIX allows the key created here to be 0, but the compare_and_swap + // below relies on using 0 as a sentinel value to check who won the + // race to set the shared TLS key. As far as I know, there is no + // guaranteed value that cannot be returned as a posix_key_create key, + // so there is no value we can initialize the inner key with to + // prove that it has not yet been set. As such, we'll continue using a + // value of 0, but with some gyrations to make sure we have a non-0 + // value returned from the creation routine. + // FIXME: this is clearly a hack, and should be cleaned up. + let key1 = imp::create(self.dtor); + let key = if key1 != 0 { + key1 + } else { + let key2 = imp::create(self.dtor); + imp::destroy(key1); + key2 + }; assert!(key != 0); match self.inner.key.compare_and_swap(0, key as uint, atomic::SeqCst) { // The CAS succeeded, so we've created the actual key diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index 16779a80185..05be8de0b56 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -15,7 +15,7 @@ use libc::{mod, c_int}; use c_str::CString; use mem; -use os::windows::fill_utf16_buf_and_decode; +use os::windoze::fill_utf16_buf_and_decode; use path; use ptr; use str; |
