diff --git a/src/core/state.c b/src/core/state.c index e2423936..8d5e2556 100644 --- a/src/core/state.c +++ b/src/core/state.c @@ -62,18 +62,10 @@ void janet_vm_load(JanetVM *from) { * use NULL to interrupt the current VM when convenient */ void janet_interpreter_interrupt(JanetVM *vm) { vm = vm ? vm : &janet_vm; -#ifdef JANET_WINDOWS - InterlockedIncrement(&vm->auto_suspend); -#else - __atomic_add_fetch(&vm->auto_suspend, 1, __ATOMIC_RELAXED); -#endif + janet_atomic_inc(&vm->auto_suspend); } void janet_interpreter_interrupt_handled(JanetVM *vm) { vm = vm ? vm : &janet_vm; -#ifdef JANET_WINDOWS - InterlockedDecrement(&vm->auto_suspend); -#else - __atomic_add_fetch(&vm->auto_suspend, -1, __ATOMIC_RELAXED); -#endif + janet_atomic_dec(&vm->auto_suspend); } diff --git a/src/core/state.h b/src/core/state.h index 1c64496d..12ea13a6 100644 --- a/src/core/state.h +++ b/src/core/state.h @@ -89,7 +89,7 @@ struct JanetVM { /* If this flag is true, suspend on function calls and backwards jumps. * When this occurs, this flag will be reset to 0. */ - volatile int32_t auto_suspend; + volatile JanetAtomicInt auto_suspend; /* The current running fiber on the current thread. * Set and unset by functions in vm.c */