Expected : in out Atomic_Type;
Desired : Atomic_Type) return Boolean
is
- function My_Sync_Compare_And_Swap is
- new Sync_Compare_And_Swap (Atomic_Type);
-
- Actual : Atomic_Type;
+ function My_Atomic_Compare_Exchange is
+ new Atomic_Compare_Exchange (Atomic_Type);
begin
if Expected /= Desired then
if Atomic_Type'Atomic_Always_Lock_Free then
- Actual := My_Sync_Compare_And_Swap (Ptr, Expected, Desired);
+ return My_Atomic_Compare_Exchange (Ptr, Expected'Address, Desired);
else
raise Program_Error;
end if;
-
- if Actual /= Expected then
- Expected := Actual;
- return False;
- end if;
end if;
return True;
generic
type Atomic_Type is mod <>;
- function Sync_Compare_And_Swap
- (Ptr : Address;
- Expected : Atomic_Type;
- Desired : Atomic_Type) return Atomic_Type;
+ function Atomic_Compare_Exchange
+ (Ptr : Address;
+ Expected : Address;
+ Desired : Atomic_Type;
+ Weak : Boolean := False;
+ Success_Model : Mem_Model := Seq_Cst;
+ Failure_Model : Mem_Model := Seq_Cst) return Boolean;
pragma Import
- (Intrinsic, Sync_Compare_And_Swap, "__sync_val_compare_and_swap");
+ (Intrinsic, Atomic_Compare_Exchange, "__atomic_compare_exchange_n");
- function Sync_Compare_And_Swap_8 is new Sync_Compare_And_Swap (uint8);
- function Sync_Compare_And_Swap_16 is new Sync_Compare_And_Swap (uint16);
- function Sync_Compare_And_Swap_32 is new Sync_Compare_And_Swap (uint32);
- function Sync_Compare_And_Swap_64 is new Sync_Compare_And_Swap (uint64);
+ function Atomic_Compare_Exchange_8 is new Atomic_Compare_Exchange (uint8);
+ function Atomic_Compare_Exchange_16 is new Atomic_Compare_Exchange (uint16);
+ function Atomic_Compare_Exchange_32 is new Atomic_Compare_Exchange (uint32);
+ function Atomic_Compare_Exchange_64 is new Atomic_Compare_Exchange (uint64);
function Atomic_Test_And_Set
(Ptr : System.Address;