Skip to content

Commit

Permalink
Use msvc compiler intrinsics for atomics.
Browse files Browse the repository at this point in the history
This will let us use GCC atomics on mingw.
  • Loading branch information
bakpakin committed Oct 12, 2024
1 parent d18472b commit d10c1fe
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/capi.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,8 @@ void *janet_optabstract(const Janet *argv, int32_t argc, int32_t n, const JanetA
/* Atomic refcounts */

JanetAtomicInt janet_atomic_inc(JanetAtomicInt volatile *x) {
#ifdef JANET_WINDOWS
return InterlockedIncrement(x);
#ifdef _MSC_VER
return _InterlockedIncrement(x);
#elif defined(JANET_USE_STDATOMIC)
return atomic_fetch_add_explicit(x, 1, memory_order_relaxed) + 1;
#else
Expand All @@ -558,8 +558,8 @@ JanetAtomicInt janet_atomic_inc(JanetAtomicInt volatile *x) {
}

JanetAtomicInt janet_atomic_dec(JanetAtomicInt volatile *x) {
#ifdef JANET_WINDOWS
return InterlockedDecrement(x);
#ifdef _MSC_VER
return _InterlockedDecrement(x);
#elif defined(JANET_USE_STDATOMIC)
return atomic_fetch_add_explicit(x, -1, memory_order_acq_rel) - 1;
#else
Expand All @@ -568,8 +568,8 @@ JanetAtomicInt janet_atomic_dec(JanetAtomicInt volatile *x) {
}

JanetAtomicInt janet_atomic_load(JanetAtomicInt volatile *x) {
#ifdef JANET_WINDOWS
return InterlockedOr(x, 0);
#ifdef _MSC_VER
return _InterlockedOr(x, 0);
#elif defined(JANET_USE_STDATOMIC)
return atomic_load_explicit(x, memory_order_acquire);
#else
Expand Down

0 comments on commit d10c1fe

Please sign in to comment.