@@ -2,7 +2,7 @@ use crate::mem::ManuallyDrop;
22use crate :: ptr;
33use crate :: sync:: atomic:: AtomicPtr ;
44use crate :: sync:: atomic:: AtomicUsize ;
5- use crate :: sync:: atomic:: Ordering :: SeqCst ;
5+ use crate :: sync:: atomic:: Ordering :: { Acquire , Relaxed , Release } ;
66use core:: arch:: asm;
77
88use crate :: os:: xous:: ffi:: { map_memory, unmap_memory, MemoryFlags } ;
@@ -92,7 +92,7 @@ fn tls_table() -> &'static mut [*mut u8] {
9292pub unsafe fn create ( dtor : Option < Dtor > ) -> Key {
9393 // Allocate a new TLS key. These keys are shared among all threads.
9494 #[ 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 ) } ;
9696 if let Some ( f) = dtor {
9797 unsafe { register_dtor ( key, f) } ;
9898 }
@@ -154,11 +154,11 @@ unsafe fn register_dtor(key: Key, dtor: Dtor) {
154154 let mut node = ManuallyDrop :: new ( Box :: new ( Node { key, dtor, next : ptr:: null_mut ( ) } ) ) ;
155155
156156 #[ allow( unused_unsafe) ]
157- let mut head = unsafe { DTORS . load ( SeqCst ) } ;
157+ let mut head = unsafe { DTORS . load ( Acquire ) } ;
158158 loop {
159159 node. next = head;
160160 #[ 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 ) } {
162162 Ok ( _) => return , // nothing to drop, we successfully added the node to the list
163163 Err ( cur) => head = cur,
164164 }
@@ -199,7 +199,7 @@ unsafe fn run_dtors() {
199199 }
200200 any_run = false ;
201201 #[ allow( unused_unsafe) ]
202- let mut cur = unsafe { DTORS . load ( SeqCst ) } ;
202+ let mut cur = unsafe { DTORS . load ( Acquire ) } ;
203203 while !cur. is_null ( ) {
204204 let ptr = unsafe { get ( ( * cur) . key ) } ;
205205
0 commit comments