@@ -2,7 +2,7 @@ use crate::mem::ManuallyDrop;
2
2
use crate :: ptr;
3
3
use crate :: sync:: atomic:: AtomicPtr ;
4
4
use crate :: sync:: atomic:: AtomicUsize ;
5
- use crate :: sync:: atomic:: Ordering :: SeqCst ;
5
+ use crate :: sync:: atomic:: Ordering :: { Acquire , Relaxed , Release } ;
6
6
use core:: arch:: asm;
7
7
8
8
use crate :: os:: xous:: ffi:: { map_memory, unmap_memory, MemoryFlags } ;
@@ -92,7 +92,7 @@ fn tls_table() -> &'static mut [*mut u8] {
92
92
pub unsafe fn create ( dtor : Option < Dtor > ) -> Key {
93
93
// Allocate a new TLS key. These keys are shared among all threads.
94
94
#[ allow( unused_unsafe) ]
95
- let key = unsafe { TLS_KEY_INDEX . fetch_add ( 1 , SeqCst ) } ;
95
+ let key = unsafe { TLS_KEY_INDEX . fetch_add ( 1 , Relaxed ) } ;
96
96
if let Some ( f) = dtor {
97
97
unsafe { register_dtor ( key, f) } ;
98
98
}
@@ -154,11 +154,11 @@ unsafe fn register_dtor(key: Key, dtor: Dtor) {
154
154
let mut node = ManuallyDrop :: new ( Box :: new ( Node { key, dtor, next : ptr:: null_mut ( ) } ) ) ;
155
155
156
156
#[ allow( unused_unsafe) ]
157
- let mut head = unsafe { DTORS . load ( SeqCst ) } ;
157
+ let mut head = unsafe { DTORS . load ( Acquire ) } ;
158
158
loop {
159
159
node. next = head;
160
160
#[ allow( unused_unsafe) ]
161
- match unsafe { DTORS . compare_exchange ( head, & mut * * node, SeqCst , SeqCst ) } {
161
+ match unsafe { DTORS . compare_exchange ( head, & mut * * node, Release , Acquire ) } {
162
162
Ok ( _) => return , // nothing to drop, we successfully added the node to the list
163
163
Err ( cur) => head = cur,
164
164
}
@@ -199,7 +199,7 @@ unsafe fn run_dtors() {
199
199
}
200
200
any_run = false ;
201
201
#[ allow( unused_unsafe) ]
202
- let mut cur = unsafe { DTORS . load ( SeqCst ) } ;
202
+ let mut cur = unsafe { DTORS . load ( Acquire ) } ;
203
203
while !cur. is_null ( ) {
204
204
let ptr = unsafe { get ( ( * cur) . key ) } ;
205
205
0 commit comments