@@ -329,7 +329,7 @@ static HOOK: AtomicPtr<()> = AtomicPtr::new(ptr::null_mut());
329
329
/// ```
330
330
#[ unstable( feature = "alloc_error_hook" , issue = "51245" ) ]
331
331
pub fn set_alloc_error_hook ( hook : fn ( Layout ) ) {
332
- HOOK . store ( hook as * mut ( ) , Ordering :: SeqCst ) ;
332
+ HOOK . store ( hook as * mut ( ) , Ordering :: Release ) ;
333
333
}
334
334
335
335
/// Unregisters the current allocation error hook, returning it.
@@ -339,7 +339,7 @@ pub fn set_alloc_error_hook(hook: fn(Layout)) {
339
339
/// If no custom hook is registered, the default hook will be returned.
340
340
#[ unstable( feature = "alloc_error_hook" , issue = "51245" ) ]
341
341
pub fn take_alloc_error_hook ( ) -> fn ( Layout ) {
342
- let hook = HOOK . swap ( ptr:: null_mut ( ) , Ordering :: SeqCst ) ;
342
+ let hook = HOOK . swap ( ptr:: null_mut ( ) , Ordering :: Acquire ) ;
343
343
if hook. is_null ( ) { default_alloc_error_hook } else { unsafe { mem:: transmute ( hook) } }
344
344
}
345
345
@@ -362,7 +362,7 @@ fn default_alloc_error_hook(layout: Layout) {
362
362
#[ alloc_error_handler]
363
363
#[ unstable( feature = "alloc_internals" , issue = "none" ) ]
364
364
pub fn rust_oom ( layout : Layout ) -> ! {
365
- let hook = HOOK . load ( Ordering :: SeqCst ) ;
365
+ let hook = HOOK . load ( Ordering :: Acquire ) ;
366
366
let hook: fn ( Layout ) =
367
367
if hook. is_null ( ) { default_alloc_error_hook } else { unsafe { mem:: transmute ( hook) } } ;
368
368
hook ( layout) ;
0 commit comments