1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-10 10:49:54 +00:00

Get rid of req for 64 bit atomics

This commit is contained in:
Calvin Rose 2023-10-01 10:27:51 -05:00
parent 7cdd7cf6eb
commit af7ed4322e
4 changed files with 3 additions and 23 deletions

View File

@ -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) {

View File

@ -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 */

View File

@ -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 */

View File

@ -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