Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 335d84f

Browse files
committed
Add MemoryOrder args to cas.
Fixes issue 20105
1 parent 1b13903 commit 335d84f

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/core/atomic.d

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
276276
* Returns:
277277
* true if the store occurred, false if not.
278278
*/
279-
bool cas(T,V1,V2)(T* here, V1 ifThis, V2 writeThis) pure nothrow @nogc @trusted
279+
bool cas(MemoryOrder succ = MemoryOrder.seq,MemoryOrder fail = MemoryOrder.seq,T,V1,V2)(T* here, V1 ifThis, V2 writeThis) pure nothrow @nogc @trusted
280280
if (!is(T == shared S, S) && is(T : V1))
281281
in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
282282
{
@@ -287,14 +287,14 @@ in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
287287
static if (__traits(isFloating, T))
288288
{
289289
alias IntTy = IntForFloat!T;
290-
return atomicCompareExchangeStrongNoResult(cast(IntTy*)here, *cast(IntTy*)&arg1, *cast(IntTy*)&arg2);
290+
return atomicCompareExchangeStrongNoResult!(succ, fail)(cast(IntTy*)here, *cast(IntTy*)&arg1, *cast(IntTy*)&arg2);
291291
}
292292
else
293-
return atomicCompareExchangeStrongNoResult(here, arg1, arg2);
293+
return atomicCompareExchangeStrongNoResult!(succ, fail)(here, arg1, arg2);
294294
}
295295

296296
/// Ditto
297-
bool cas(T,V1,V2)(shared(T)* here, V1 ifThis, V2 writeThis) pure nothrow @nogc @trusted
297+
bool cas(MemoryOrder succ = MemoryOrder.seq,MemoryOrder fail = MemoryOrder.seq,T,V1,V2)(shared(T)* here, V1 ifThis, V2 writeThis) pure nothrow @nogc @trusted
298298
if (!is(T == class) && (is(T : V1) || is(shared T : V1)))
299299
in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
300300
{
@@ -310,15 +310,15 @@ in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
310310
static assert(!hasUnsharedIndirections!V2, "Copying `" ~ V2.stringof ~ "* writeThis` to `" ~ shared(T).stringof ~ "* here` would violate shared.");
311311
alias Thunk2 = V2;
312312
}
313-
return cas(cast(T*)here, *cast(Thunk1*)&ifThis, *cast(Thunk2*)&writeThis);
313+
return cas!(succ, fail)(cast(T*)here, *cast(Thunk1*)&ifThis, *cast(Thunk2*)&writeThis);
314314
}
315315

316316
/// Ditto
317-
bool cas(T,V1,V2)(shared(T)* here, shared(V1) ifThis, shared(V2) writeThis) pure nothrow @nogc @trusted
317+
bool cas(MemoryOrder succ = MemoryOrder.seq,MemoryOrder fail = MemoryOrder.seq,T,V1,V2)(shared(T)* here, shared(V1) ifThis, shared(V2) writeThis) pure nothrow @nogc @trusted
318318
if (is(T == class))
319319
in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
320320
{
321-
return atomicCompareExchangeStrongNoResult(cast(T*)here, cast(V1)ifThis, cast(V2)writeThis);
321+
return atomicCompareExchangeStrongNoResult!(succ, fail)(cast(T*)here, cast(V1)ifThis, cast(V2)writeThis);
322322
}
323323

324324
/**
@@ -335,7 +335,7 @@ in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
335335
* Returns:
336336
* true if the store occurred, false if not.
337337
*/
338-
bool cas(T,V)(T* here, T* ifThis, V writeThis) pure nothrow @nogc @trusted
338+
bool cas(MemoryOrder succ = MemoryOrder.seq,MemoryOrder fail = MemoryOrder.seq,T,V)(T* here, T* ifThis, V writeThis) pure nothrow @nogc @trusted
339339
if (!is(T == shared S, S) && !is(V == shared U, U))
340340
in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
341341
{
@@ -345,14 +345,14 @@ in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
345345
static if (__traits(isFloating, T))
346346
{
347347
alias IntTy = IntForFloat!T;
348-
return atomicCompareExchangeStrong(cast(IntTy*)here, cast(IntTy*)ifThis, *cast(IntTy*)&writeThis);
348+
return atomicCompareExchangeStrong!(succ, fail)(cast(IntTy*)here, cast(IntTy*)ifThis, *cast(IntTy*)&writeThis);
349349
}
350350
else
351-
return atomicCompareExchangeStrong(here, ifThis, writeThis);
351+
return atomicCompareExchangeStrong!(succ, fail)(here, ifThis, writeThis);
352352
}
353353

354354
/// Ditto
355-
bool cas(T,V1,V2)(shared(T)* here, V1* ifThis, V2 writeThis) pure nothrow @nogc @trusted
355+
bool cas(MemoryOrder succ = MemoryOrder.seq,MemoryOrder fail = MemoryOrder.seq,T,V1,V2)(shared(T)* here, V1* ifThis, V2 writeThis) pure nothrow @nogc @trusted
356356
if (!is(T == class) && (is(T : V1) || is(shared T : V1)))
357357
in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
358358
{
@@ -373,15 +373,15 @@ in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
373373
alias Thunk2 = V2;
374374
}
375375
static assert (is(T : Thunk1), "Mismatching types for `here` and `ifThis`: `" ~ shared(T).stringof ~ "` and `" ~ V1.stringof ~ "`.");
376-
return cas(cast(T*)here, cast(Thunk1*)ifThis, *cast(Thunk2*)&writeThis);
376+
return cas!(succ, fail)(cast(T*)here, cast(Thunk1*)ifThis, *cast(Thunk2*)&writeThis);
377377
}
378378

379379
/// Ditto
380-
bool cas(T,V)(shared(T)* here, shared(T)* ifThis, shared(V) writeThis) pure nothrow @nogc @trusted
380+
bool cas(MemoryOrder succ = MemoryOrder.seq,MemoryOrder fail = MemoryOrder.seq,T,V)(shared(T)* here, shared(T)* ifThis, shared(V) writeThis) pure nothrow @nogc @trusted
381381
if (is(T == class))
382382
in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
383383
{
384-
return atomicCompareExchangeStrong(cast(T*)here, cast(T*)ifThis, cast(V)writeThis);
384+
return atomicCompareExchangeStrong!(succ, fail)(cast(T*)here, cast(T*)ifThis, cast(V)writeThis);
385385
}
386386

387387
/**

0 commit comments

Comments
 (0)