mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-11 00:00:49 +02:00
Add gc_edge data structure
Less casting in user programs, and it's a step on the way to evacuation in whippet.
This commit is contained in:
parent
808d365f4b
commit
52166fe286
9 changed files with 81 additions and 48 deletions
26
gc-types.h
Normal file
26
gc-types.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#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_
|
Loading…
Add table
Add a link
Reference in a new issue