diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-11-26 05:52:16 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-12-22 12:27:07 -0500 |
| commit | 7f6177e64627110e5b9776bd5304d65806081390 (patch) | |
| tree | 7f2836a870dc5221135964ff338b9f591b249ccd /src/libstd/thread_local | |
| parent | 211782fef562cac25922080229fd8443fb352792 (diff) | |
| download | rust-7f6177e64627110e5b9776bd5304d65806081390.tar.gz rust-7f6177e64627110e5b9776bd5304d65806081390.zip | |
Fix fallout from changes. In cases where stage0 compiler is needed, we
cannot use an `as` expression to coerce, so I used a one-off function instead (this is a no-op in stage0, but in stage1+ it triggers coercion from the fn pointer to the fn item type).
Diffstat (limited to 'src/libstd/thread_local')
| -rw-r--r-- | src/libstd/thread_local/mod.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/libstd/thread_local/mod.rs b/src/libstd/thread_local/mod.rs index 4c33d1c418d..04718dcc6ae 100644 --- a/src/libstd/thread_local/mod.rs +++ b/src/libstd/thread_local/mod.rs @@ -189,11 +189,12 @@ macro_rules! __thread_local_inner { } }; - #[cfg(not(any(target_os = "macos", target_os = "linux")))] + #[cfg(all(stage0, not(any(target_os = "macos", target_os = "linux"))))] const INIT: ::std::thread_local::KeyInner<$t> = { unsafe extern fn __destroy(ptr: *mut u8) { ::std::thread_local::destroy_value::<$t>(ptr); } + ::std::thread_local::KeyInner { inner: ::std::cell::UnsafeCell { value: $init }, os: ::std::thread_local::OsStaticKey { @@ -203,6 +204,21 @@ macro_rules! __thread_local_inner { } }; + #[cfg(all(not(stage0), not(any(target_os = "macos", target_os = "linux"))))] + const INIT: ::std::thread_local::KeyInner<$t> = { + unsafe extern fn __destroy(ptr: *mut u8) { + ::std::thread_local::destroy_value::<$t>(ptr); + } + + ::std::thread_local::KeyInner { + inner: ::std::cell::UnsafeCell { value: $init }, + os: ::std::thread_local::OsStaticKey { + inner: ::std::thread_local::OS_INIT_INNER, + dtor: ::std::option::Option::Some(__destroy as unsafe extern fn(*mut u8)), + }, + } + }; + INIT }); } @@ -323,6 +339,12 @@ mod imp { // *should* be the case that this loop always terminates because we // provide the guarantee that a TLS key cannot be set after it is // flagged for destruction. + #[cfg(not(stage0))] + static DTORS: os::StaticKey = os::StaticKey { + inner: os::INIT_INNER, + dtor: Some(run_dtors as unsafe extern "C" fn(*mut u8)), + }; + #[cfg(stage0)] static DTORS: os::StaticKey = os::StaticKey { inner: os::INIT_INNER, dtor: Some(run_dtors), |
