diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2024-03-19 14:57:59 +0100 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2024-03-19 15:27:11 +0100 |
| commit | 904fef0e24c8b7f7ff0a33c1b7f3ecbb59ade249 (patch) | |
| tree | ffc8344a9b8462ca01dea03573f7878326e4e918 | |
| parent | bf3debe9d776a6eeda48e4c063ab6798d066fc4e (diff) | |
| download | rust-904fef0e24c8b7f7ff0a33c1b7f3ecbb59ade249.tar.gz rust-904fef0e24c8b7f7ff0a33c1b7f3ecbb59ade249.zip | |
SeqCst->{Release,Acquire} for alloc error hook.
SeqCst is unnecessary.
| -rw-r--r-- | library/std/src/alloc.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs index a834b36697c..dc0e302a810 100644 --- a/library/std/src/alloc.rs +++ b/library/std/src/alloc.rs @@ -329,7 +329,7 @@ static HOOK: AtomicPtr<()> = AtomicPtr::new(ptr::null_mut()); /// ``` #[unstable(feature = "alloc_error_hook", issue = "51245")] pub fn set_alloc_error_hook(hook: fn(Layout)) { - HOOK.store(hook as *mut (), Ordering::SeqCst); + HOOK.store(hook as *mut (), Ordering::Release); } /// Unregisters the current allocation error hook, returning it. @@ -339,7 +339,7 @@ pub fn set_alloc_error_hook(hook: fn(Layout)) { /// If no custom hook is registered, the default hook will be returned. #[unstable(feature = "alloc_error_hook", issue = "51245")] pub fn take_alloc_error_hook() -> fn(Layout) { - let hook = HOOK.swap(ptr::null_mut(), Ordering::SeqCst); + let hook = HOOK.swap(ptr::null_mut(), Ordering::Acquire); if hook.is_null() { default_alloc_error_hook } else { unsafe { mem::transmute(hook) } } } @@ -362,7 +362,7 @@ fn default_alloc_error_hook(layout: Layout) { #[alloc_error_handler] #[unstable(feature = "alloc_internals", issue = "none")] pub fn rust_oom(layout: Layout) -> ! { - let hook = HOOK.load(Ordering::SeqCst); + let hook = HOOK.load(Ordering::Acquire); let hook: fn(Layout) = if hook.is_null() { default_alloc_error_hook } else { unsafe { mem::transmute(hook) } }; hook(layout); |
