Skip to content

Commit

Permalink
Get rid of req for 64 bit atomics
Browse files Browse the repository at this point in the history
  • Loading branch information
bakpakin committed Oct 1, 2023
1 parent 7cdd7cf commit af7ed43
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 23 deletions.
16 changes: 0 additions & 16 deletions src/core/capi.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,22 +509,6 @@ JanetAtomicInt janet_atomic_dec(JanetAtomicInt volatile *x) {
#endif
}

JanetAtomicInt64 janet_atomic64_inc(JanetAtomicInt64 volatile *x) {
#ifdef JANET_WINDOWS
return InterlockedDecrement(x);
#else
return __atomic_add_fetch(x, 1, __ATOMIC_RELAXED);
#endif
}

JanetAtomicInt64 janet_atomic64_dec(JanetAtomicInt64 volatile *x) {
#ifdef JANET_WINDOWS
return InterlockedDecrement64(x);
#else
return __atomic_add_fetch(x, -1, __ATOMIC_RELAXED);
#endif
}

/* Some definitions for function-like macros */

JANET_API JanetStructHead *(janet_struct_head)(JanetStruct st) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/ev.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,11 +633,11 @@ void janet_addtimeout(double sec) {
}

void janet_ev_inc_refcount(void) {
janet_atomic64_inc(&janet_vm.listener_count);
janet_atomic_inc(&janet_vm.listener_count);
}

void janet_ev_dec_refcount(void) {
janet_atomic64_dec(&janet_vm.listener_count);
janet_atomic_dec(&janet_vm.listener_count);
}

/* Channels */
Expand Down
2 changes: 1 addition & 1 deletion src/core/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ struct JanetVM {
JanetQueue spawn;
JanetTimeout *tq;
JanetRNG ev_rng;
volatile JanetAtomicInt64 listener_count; /* used in signal handler, must be volatile */
volatile JanetAtomicInt listener_count; /* used in signal handler, must be volatile */
JanetTable threaded_abstracts; /* All abstract types that can be shared between threads (used in this thread) */
JanetTable active_tasks; /* All possibly live task fibers - used just for tracking */
JanetArray *listeners; /* For GC */
Expand Down
4 changes: 0 additions & 4 deletions src/include/janet.h
Original file line number Diff line number Diff line change
Expand Up @@ -637,15 +637,11 @@ struct JanetListenerState {
* signals. Define them here */
#ifdef JANET_WINDOWS
typedef long JanetAtomicInt;
typedef long long JanetAtomicInt64;
#else
typedef int32_t JanetAtomicInt;
typedef int64_t JanetAtomicInt64;
#endif
JANET_API JanetAtomicInt janet_atomic_inc(JanetAtomicInt volatile *x);
JANET_API JanetAtomicInt janet_atomic_dec(JanetAtomicInt volatile *x);
JANET_API JanetAtomicInt64 janet_atomic64_inc(JanetAtomicInt64 volatile *x);
JANET_API JanetAtomicInt64 janet_atomic64_dec(JanetAtomicInt64 volatile *x);

/* We provide three possible implementations of Janets. The preferred
* nanboxing approach, for 32 or 64 bits, and the standard C version. Code in the rest of the
Expand Down

0 comments on commit af7ed43

Please sign in to comment.