From ecfae949b68b69cb97b5e9015e3a2bc2bc01c3ec Mon Sep 17 00:00:00 2001 From: rymrg <54061433+rymrg@users.noreply.github.com> Date: Tue, 19 Jan 2021 12:23:59 +0200 Subject: [PATCH] Add support for atomicFetchAdd and atomicFetchSub --- src/core/internal/atomic.d | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/core/internal/atomic.d b/src/core/internal/atomic.d index fb21eb381e..dbc235c5e8 100644 --- a/src/core/internal/atomic.d +++ b/src/core/internal/atomic.d @@ -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;