1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-06 09:30:29 +02:00
guile/api/gc-safepoint.h
Andy Wingo 4fe4177d7c Split inline function definitions out to separate headers
Users will need to include gc-allocate.h, gc-safepoint.h, and
gc-barrier.h explicitly.
2025-07-01 12:45:41 +02:00

35 lines
999 B
C

#ifndef GC_SAFEPOINT_H_
#define GC_SAFEPOINT_H_
#include "gc-api.h"
static inline int gc_should_stop_for_safepoint(struct gc_mutator *mut) {
switch (gc_cooperative_safepoint_kind()) {
case GC_COOPERATIVE_SAFEPOINT_NONE:
return 0;
case GC_COOPERATIVE_SAFEPOINT_MUTATOR_FLAG:
case GC_COOPERATIVE_SAFEPOINT_HEAP_FLAG: {
return atomic_load_explicit(gc_safepoint_flag_loc(mut),
memory_order_relaxed);
}
default:
GC_CRASH();
}
}
static inline void gc_safepoint(struct gc_mutator *mut) {
if (GC_UNLIKELY(gc_should_stop_for_safepoint(mut)))
gc_safepoint_slow(mut);
}
static inline void gc_inhibit_preemption(struct gc_mutator *mut) {
if (gc_safepoint_mechanism() == GC_SAFEPOINT_MECHANISM_SIGNAL)
gc_safepoint_signal_inhibit(mut);
}
static inline void gc_reallow_preemption(struct gc_mutator *mut) {
if (gc_safepoint_mechanism() == GC_SAFEPOINT_MECHANISM_SIGNAL)
gc_safepoint_signal_reallow(mut);
}
#endif // GC_SAFEPOINT_H_