mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-19 19:20:23 +02:00
Get handles out of collectors
This commit is contained in:
parent
607585e7f0
commit
9e8940e59f
10 changed files with 149 additions and 57 deletions
|
@ -6,8 +6,8 @@ struct handle {
|
|||
#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, &h.handle)
|
||||
#define POP_HANDLE(cx) pop_handle(&cx->roots)
|
||||
#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) {
|
||||
handle->next = *roots;
|
||||
|
@ -17,3 +17,11 @@ static inline void push_handle(struct handle **roots, struct handle *handle) {
|
|||
static inline void pop_handle(struct handle **roots) {
|
||||
*roots = (*roots)->next;
|
||||
}
|
||||
|
||||
static inline void visit_roots(struct handle *roots,
|
||||
void (*trace_edge)(struct gc_edge edge,
|
||||
void *trace_data),
|
||||
void *trace_data) {
|
||||
for (struct handle *h = roots; h; h = h->next)
|
||||
trace_edge(gc_edge(&h->v), trace_data);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue