about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authoroli <oli@uhura.edef.eu>2020-10-06 10:03:52 +0000
committeroli <github35764891676564198441@oli-obk.de>2020-11-28 17:13:47 +0000
commitaabe70f90e30c45f13dbdaaed1ea05776e541b8d (patch)
tree553b6cf37362a6629bf5d76a255d4a999b1edf0c /library/core/src
parent4ae328bef47dffcbf363e5ae873f419c06a5511d (diff)
downloadrust-aabe70f90e30c45f13dbdaaed1ea05776e541b8d.tar.gz
rust-aabe70f90e30c45f13dbdaaed1ea05776e541b8d.zip
Directly use raw pointers in `AtomicPtr` store/load
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/sync/atomic.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs
index 9d204599057..c167a9d8e5b 100644
--- a/library/core/src/sync/atomic.rs
+++ b/library/core/src/sync/atomic.rs
@@ -966,8 +966,16 @@ impl<T> AtomicPtr<T> {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn load(&self, order: Ordering) -> *mut T {
+        #[cfg(not(bootstrap))]
         // SAFETY: data races are prevented by atomic intrinsics.
-        unsafe { atomic_load(self.p.get() as *mut usize, order) as *mut T }
+        unsafe {
+            atomic_load(self.p.get(), order)
+        }
+        #[cfg(bootstrap)]
+        // SAFETY: data races are prevented by atomic intrinsics.
+        unsafe {
+            atomic_load(self.p.get() as *mut usize, order) as *mut T
+        }
     }
 
     /// Stores a value into the pointer.
@@ -994,6 +1002,12 @@ impl<T> AtomicPtr<T> {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn store(&self, ptr: *mut T, order: Ordering) {
+        #[cfg(not(bootstrap))]
+        // SAFETY: data races are prevented by atomic intrinsics.
+        unsafe {
+            atomic_store(self.p.get(), ptr, order);
+        }
+        #[cfg(bootstrap)]
         // SAFETY: data races are prevented by atomic intrinsics.
         unsafe {
             atomic_store(self.p.get() as *mut usize, ptr as usize, order);
@@ -1105,6 +1119,7 @@ impl<T> AtomicPtr<T> {
         success: Ordering,
         failure: Ordering,
     ) -> Result<*mut T, *mut T> {
+        #[cfg(bootstrap)]
         // SAFETY: data races are prevented by atomic intrinsics.
         unsafe {
             let res = atomic_compare_exchange(
@@ -1119,6 +1134,11 @@ impl<T> AtomicPtr<T> {
                 Err(x) => Err(x as *mut T),
             }
         }
+        #[cfg(not(bootstrap))]
+        // SAFETY: data races are prevented by atomic intrinsics.
+        unsafe {
+            atomic_compare_exchange(self.p.get(), current, new, success, failure)
+        }
     }
 
     /// Stores a value into the pointer if the current value is the same as the `current` value.
@@ -1165,6 +1185,7 @@ impl<T> AtomicPtr<T> {
         success: Ordering,
         failure: Ordering,
     ) -> Result<*mut T, *mut T> {
+        #[cfg(bootstrap)]
         // SAFETY: data races are prevented by atomic intrinsics.
         unsafe {
             let res = atomic_compare_exchange_weak(
@@ -1179,6 +1200,11 @@ impl<T> AtomicPtr<T> {
                 Err(x) => Err(x as *mut T),
             }
         }
+        #[cfg(not(bootstrap))]
+        // SAFETY: data races are prevented by atomic intrinsics.
+        unsafe {
+            atomic_compare_exchange_weak(self.p.get(), current, new, success, failure)
+        }
     }
 
     /// Fetches the value, and applies a function to it that returns an optional