Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Add support for atomicFetchAdd and atomicFetchSub #193

Merged
merged 1 commit into from
Jan 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/core/internal/atomic.d
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ version (LDC)
llvm_atomic_store!A(*cast(A*) &value, cast(shared A*) dest, _ordering!(order));
}

T atomicFetchAdd(MemoryOrder order = MemoryOrder.seq, T)(T* dest, T value) pure nothrow @nogc @trusted
{
alias A = _AtomicType!T;
return llvm_atomic_rmw_add!A(cast(shared A*) dest, value, _ordering!(order));
}

T atomicFetchSub(MemoryOrder order = MemoryOrder.seq, T)(T* dest, T value) pure nothrow @nogc @trusted
{
alias A = _AtomicType!T;
return llvm_atomic_rmw_sub!A(cast(shared A*) dest, value, _ordering!(order));
}

T atomicExchange(MemoryOrder order = MemoryOrder.seq, bool result = true, T)(T* dest, T value) pure nothrow @nogc @trusted
{
alias A = _AtomicType!T;
Expand Down