3030//!
3131//! The atomic intrinsics provide common atomic operations on machine
3232//! words, with multiple possible memory orderings. See the
33- //! [atomic types][crate::sync:: atomic] docs for details.
33+ //! [atomic types][atomic] docs for details.
3434//!
3535//! # Unwinding
3636//!
5050) ]
5151#![ allow( missing_docs) ]
5252
53- use crate :: marker:: { DiscriminantKind , Tuple } ;
53+ use crate :: marker:: { ConstParamTy , DiscriminantKind , Tuple } ;
5454use crate :: ptr;
5555
5656pub mod fallback;
@@ -62,6 +62,20 @@ pub mod simd;
6262#[ cfg( all( target_has_atomic = "8" , target_has_atomic = "32" , target_has_atomic = "ptr" ) ) ]
6363use crate :: sync:: atomic:: { self , AtomicBool , AtomicI32 , AtomicIsize , AtomicU32 , Ordering } ;
6464
65+ /// A type for atomic ordering parameters for intrinsics. This is a separate type from
66+ /// `atomic::Ordering` so that we can make it `ConstParamTy` and fix the values used here without a
67+ /// risk of leaking that to stable code.
68+ #[ derive( Debug , ConstParamTy , PartialEq , Eq ) ]
69+ pub enum AtomicOrdering {
70+ // These values must match the compiler's `AtomicOrdering` defined in
71+ // `rustc_middle/src/ty/consts/int.rs`!
72+ Relaxed = 0 ,
73+ Release = 1 ,
74+ Acquire = 2 ,
75+ AcqRel = 3 ,
76+ SeqCst = 4 ,
77+ }
78+
6579// N.B., these intrinsics take raw pointers because they mutate aliased
6680// memory, which is not valid for either `&` or `&mut`.
6781
@@ -391,6 +405,15 @@ pub unsafe fn atomic_cxchgweak_seqcst_acquire<T: Copy>(dst: *mut T, old: T, src:
391405#[ rustc_nounwind]
392406pub unsafe fn atomic_cxchgweak_seqcst_seqcst < T : Copy > ( dst : * mut T , old : T , src : T ) -> ( T , bool ) ;
393407
408+ /// Loads the current value of the pointer.
409+ /// `T` must be an integer or pointer type.
410+ ///
411+ /// The stabilized version of this intrinsic is available on the
412+ /// [`atomic`] types via the `load` method. For example, [`AtomicBool::load`].
413+ #[ rustc_intrinsic]
414+ #[ rustc_nounwind]
415+ #[ cfg( not( bootstrap) ) ]
416+ pub unsafe fn atomic_load < T : Copy , const ORD : AtomicOrdering > ( src : * const T ) -> T ;
394417/// Loads the current value of the pointer.
395418/// `T` must be an integer or pointer type.
396419///
@@ -399,6 +422,7 @@ pub unsafe fn atomic_cxchgweak_seqcst_seqcst<T: Copy>(dst: *mut T, old: T, src:
399422/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::load`].
400423#[ rustc_intrinsic]
401424#[ rustc_nounwind]
425+ #[ cfg( bootstrap) ]
402426pub unsafe fn atomic_load_seqcst < T : Copy > ( src : * const T ) -> T ;
403427/// Loads the current value of the pointer.
404428/// `T` must be an integer or pointer type.
@@ -408,6 +432,7 @@ pub unsafe fn atomic_load_seqcst<T: Copy>(src: *const T) -> T;
408432/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::load`].
409433#[ rustc_intrinsic]
410434#[ rustc_nounwind]
435+ #[ cfg( bootstrap) ]
411436pub unsafe fn atomic_load_acquire < T : Copy > ( src : * const T ) -> T ;
412437/// Loads the current value of the pointer.
413438/// `T` must be an integer or pointer type.
@@ -417,6 +442,7 @@ pub unsafe fn atomic_load_acquire<T: Copy>(src: *const T) -> T;
417442/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::load`].
418443#[ rustc_intrinsic]
419444#[ rustc_nounwind]
445+ #[ cfg( bootstrap) ]
420446pub unsafe fn atomic_load_relaxed < T : Copy > ( src : * const T ) -> T ;
421447
422448/// Stores the value at the specified memory location.
0 commit comments