Based on GCC atomic built-ins. See: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
The specification is exactly the same for all sizes of data (8, 16, 32, 64).
function Compare_Exchange
(This : aliased in out Instance;
Expected : T;
Desired : T;
Weak : Boolean;
Success_Order : Mem_Order := Seq_Cst;
Failure_Order : Mem_Order := Seq_Cst) return Boolean
procedure Compare_Exchange
(This : aliased in out Instance;
Expected : T;
Desired : T;
Weak : Boolean;
Success : out Boolean;
Success_Order : Mem_Order := Seq_Cst;
Failure_Order : Mem_Order := Seq_Cst)
function Exchange
(This : aliased in out Instance; Val : T; Order : Mem_Order := Seq_Cst)
return T
procedure Exchange
(This : aliased in out Instance;
Val : T;
Old : out T;
Order : Mem_Order := Seq_Cst)
function Init (Val : T) return Instance
Can be used to initialize an atomic instance:
A : My_Atomic_Access.Instance := My_Atomic_Access.Init (null);
type Instance is limited private;
This type is limited and private, it can only be manipulated using the primitives below.
function Load
(This : aliased Instance; Order : Mem_Order := Seq_Cst) return T
procedure Store
(This : aliased in out Instance; Val : T; Order : Mem_Order := Seq_Cst)
type T is private;
function Value (This : Instance) return T
Ghost function to get the value of an instance without needing it aliased. This function can be used in contracts for instance. This doesn't use the atomic built-ins.