about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2018-07-24 16:43:44 -0600
committerGitHub <noreply@github.com>2018-07-24 16:43:44 -0600
commit06ba69d043efd5612aad2aa4903125d34eba17d4 (patch)
tree9ffce52d8b60a116b13a0b0c48202028f65629e5 /src/libcore
parent487e961c6ae072d969e148def0b0856c2367ae00 (diff)
parent303306cf5ede678719ec1324bb02d3d02c014183 (diff)
Rollup merge of #52391 - Amanieu:volatile_unaligned, r=alexcrichton
Add unaligned volatile intrinsics

Surprisingly enough, it turns out that unaligned volatile loads are actually useful for certain (very niche) types of lock-free code. I included unaligned volatile stores for completeness, but I currently do not know of any use cases for them.

These are only exposed as intrinsics for now. If they turn out to be useful in practice, we can work towards stabilizing them.

r? @alexcrichton
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/intrinsics.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs
index 89fe2d941a3..854cb5f4e3b 100644
--- a/src/libcore/intrinsics.rs
+++ b/src/libcore/intrinsics.rs
@@ -1085,6 +1085,15 @@ extern "rust-intrinsic" {
     /// [`std::ptr::write_volatile`](../../std/ptr/fn.write_volatile.html).
     pub fn volatile_store<T>(dst: *mut T, val: T);
 
+    /// Perform a volatile load from the `src` pointer
+    /// The pointer is not required to be aligned.
+    #[cfg(not(stage0))]
+    pub fn unaligned_volatile_load<T>(src: *const T) -> T;
+    /// Perform a volatile store to the `dst` pointer.
+    /// The pointer is not required to be aligned.
+    #[cfg(not(stage0))]
+    pub fn unaligned_volatile_store<T>(dst: *mut T, val: T);
+
     /// Returns the square root of an `f32`
     pub fn sqrtf32(x: f32) -> f32;
     /// Returns the square root of an `f64`