mirror of
https://github.com/janet-lang/janet
synced 2025-02-15 00:00:01 +00:00
Use msvc compiler intrinsics for atomics.
This will let us use GCC atomics on mingw.
This commit is contained in:
parent
d18472b07d
commit
d10c1fe759
@ -548,8 +548,8 @@ void *janet_optabstract(const Janet *argv, int32_t argc, int32_t n, const JanetA
|
|||||||
/* Atomic refcounts */
|
/* Atomic refcounts */
|
||||||
|
|
||||||
JanetAtomicInt janet_atomic_inc(JanetAtomicInt volatile *x) {
|
JanetAtomicInt janet_atomic_inc(JanetAtomicInt volatile *x) {
|
||||||
#ifdef JANET_WINDOWS
|
#ifdef _MSC_VER
|
||||||
return InterlockedIncrement(x);
|
return _InterlockedIncrement(x);
|
||||||
#elif defined(JANET_USE_STDATOMIC)
|
#elif defined(JANET_USE_STDATOMIC)
|
||||||
return atomic_fetch_add_explicit(x, 1, memory_order_relaxed) + 1;
|
return atomic_fetch_add_explicit(x, 1, memory_order_relaxed) + 1;
|
||||||
#else
|
#else
|
||||||
@ -558,8 +558,8 @@ JanetAtomicInt janet_atomic_inc(JanetAtomicInt volatile *x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JanetAtomicInt janet_atomic_dec(JanetAtomicInt volatile *x) {
|
JanetAtomicInt janet_atomic_dec(JanetAtomicInt volatile *x) {
|
||||||
#ifdef JANET_WINDOWS
|
#ifdef _MSC_VER
|
||||||
return InterlockedDecrement(x);
|
return _InterlockedDecrement(x);
|
||||||
#elif defined(JANET_USE_STDATOMIC)
|
#elif defined(JANET_USE_STDATOMIC)
|
||||||
return atomic_fetch_add_explicit(x, -1, memory_order_acq_rel) - 1;
|
return atomic_fetch_add_explicit(x, -1, memory_order_acq_rel) - 1;
|
||||||
#else
|
#else
|
||||||
@ -568,8 +568,8 @@ JanetAtomicInt janet_atomic_dec(JanetAtomicInt volatile *x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JanetAtomicInt janet_atomic_load(JanetAtomicInt volatile *x) {
|
JanetAtomicInt janet_atomic_load(JanetAtomicInt volatile *x) {
|
||||||
#ifdef JANET_WINDOWS
|
#ifdef _MSC_VER
|
||||||
return InterlockedOr(x, 0);
|
return _InterlockedOr(x, 0);
|
||||||
#elif defined(JANET_USE_STDATOMIC)
|
#elif defined(JANET_USE_STDATOMIC)
|
||||||
return atomic_load_explicit(x, memory_order_acquire);
|
return atomic_load_explicit(x, memory_order_acquire);
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user