1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-09 07:00:23 +02:00
guile/simple-roots-api.h
Andy Wingo c614c2e40b Refactor embedder interface for conservative GC
Now users don't have to #ifdef on conservative vs precise tracing; it's
just a generic embedder concern.
2022-10-26 11:59:56 +02:00

25 lines
675 B
C

#ifndef SIMPLE_ROOTS_API_H
#define SIMPLE_ROOTS_API_H
#include "gc-config.h"
#include "simple-roots-types.h"
#define HANDLE_TO(T) union { T* v; struct handle handle; }
#define HANDLE_REF(h) h.v
#define HANDLE_SET(h,val) do { h.v = val; } while (0)
#define PUSH_HANDLE(cx, h) push_handle(&(cx)->roots.roots, &h.handle)
#define POP_HANDLE(cx) pop_handle(&(cx)->roots.roots)
static inline void push_handle(struct handle **roots, struct handle *handle) {
if (GC_PRECISE_ROOTS) {
handle->next = *roots;
*roots = handle;
}
}
static inline void pop_handle(struct handle **roots) {
if (GC_PRECISE_ROOTS)
*roots = (*roots)->next;
}
#endif // SIMPLE_ROOTS_API_H