1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-09 23:40:29 +02:00
guile/gc-types.h
Andy Wingo 52166fe286 Add gc_edge data structure
Less casting in user programs, and it's a step on the way to evacuation
in whippet.
2022-07-20 14:40:47 +02:00

26 lines
497 B
C

#ifndef GC_TYPES_H_
#define GC_TYPES_H_
struct gc_edge {
union {
void *addr;
void **loc;
};
};
static inline struct gc_edge gc_edge(void* addr) {
struct gc_edge edge;
edge.addr = addr;
return edge;
}
static inline struct gc_edge object_field(void* addr) {
return gc_edge(addr);
}
static inline void* dereference_edge(struct gc_edge edge) {
return *edge.loc;
}
static inline void update_edge(struct gc_edge edge, void *value) {
*edge.loc = value;
}
#endif // GC_TYPES_H_