Add singlethreaded fence intrinsics.

These new intrinsics are comparable to `atomic_signal_fence` in C++,
ensuring the compiler will not reorder memory accesses across the
barrier, nor will it emit any machine instructions for it.

Closes #24118, implementing RFC 888.
This commit is contained in:
Peter Marheine
2015-02-14 23:48:10 -07:00
parent 0d8309ec0b
commit 998c10d6b6
7 changed files with 43 additions and 11 deletions

View File

@@ -139,6 +139,21 @@ extern "rust-intrinsic" {
pub fn atomic_fence_rel();
pub fn atomic_fence_acqrel();
/// A compiler-only memory barrier.
///
/// Memory accesses will never be reordered across this barrier by the compiler,
/// but no instructions will be emitted for it. This is appropriate for operations
/// on the same thread that may be preempted, such as when interacting with signal
/// handlers.
#[cfg(not(stage0))] // SNAP 5520801
pub fn atomic_singlethreadfence();
#[cfg(not(stage0))] // SNAP 5520801
pub fn atomic_singlethreadfence_acq();
#[cfg(not(stage0))] // SNAP 5520801
pub fn atomic_singlethreadfence_rel();
#[cfg(not(stage0))] // SNAP 5520801
pub fn atomic_singlethreadfence_acqrel();
/// Aborts the execution of the process.
pub fn abort() -> !;