diff options
| author | bors <bors@rust-lang.org> | 2019-11-16 02:40:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-11-16 02:40:52 +0000 |
| commit | 1d8b6ce89e0874b5e93c9e41bfdd565c56372bb0 (patch) | |
| tree | 363c94e009f1ebf5b5b562c34caac92815a497e4 /src/libstd/sys | |
| parent | 82161cda33406ae8dda08b3e4afe97a44b193792 (diff) | |
| parent | ae9a62633aa0c92f826ffe0d82e9e03b41a66de1 (diff) | |
| download | rust-1d8b6ce89e0874b5e93c9e41bfdd565c56372bb0.tar.gz rust-1d8b6ce89e0874b5e93c9e41bfdd565c56372bb0.zip | |
Auto merge of #66453 - Centril:rollup-w1ohzxs, r=Centril
Rollup of 5 pull requests Successful merges: - #66350 (protect creation of destructors by a mutex) - #66407 (Add more tests for fixed ICEs) - #66415 (Add --force-run-in-process unstable option to libtest) - #66427 (Move the JSON error emitter to librustc_errors) - #66441 (libpanic_unwind for Miri: make sure we have the SEH lang items when needed) Failed merges: r? @ghost
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/hermit/thread_local.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libstd/sys/hermit/thread_local.rs b/src/libstd/sys/hermit/thread_local.rs index 4bc8c4d5883..268fb770eae 100644 --- a/src/libstd/sys/hermit/thread_local.rs +++ b/src/libstd/sys/hermit/thread_local.rs @@ -3,6 +3,7 @@ use crate::collections::BTreeMap; use crate::ptr; use crate::sync::atomic::{AtomicUsize, Ordering}; +use crate::sys_common::mutex::Mutex; pub type Key = usize; @@ -11,6 +12,7 @@ type Dtor = unsafe extern fn(*mut u8); static NEXT_KEY: AtomicUsize = AtomicUsize::new(0); static mut KEYS: *mut BTreeMap<Key, Option<Dtor>> = ptr::null_mut(); +static KEYS_LOCK: Mutex = Mutex::new(); #[thread_local] static mut LOCALS: *mut BTreeMap<Key, *mut u8> = ptr::null_mut(); @@ -32,6 +34,7 @@ unsafe fn locals() -> &'static mut BTreeMap<Key, *mut u8> { #[inline] pub unsafe fn create(dtor: Option<Dtor>) -> Key { let key = NEXT_KEY.fetch_add(1, Ordering::SeqCst); + let _guard = KEYS_LOCK.lock(); keys().insert(key, dtor); key } |
