diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2023-03-18 18:17:23 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2023-03-18 18:17:23 +0300 |
commit | aa2b00d83ead0d48670a00ef77174db7dc4b5b6b (patch) | |
tree | a07242b4c67a9cdc7b4237526900781136da90ba /include | |
parent | a04c55a5b50d6754db600d0c07162b8627cc33bb (diff) | |
download | bdwgc-aa2b00d83ead0d48670a00ef77174db7dc4b5b6b.tar.gz |
New API for disappearing links registration accepting interior pointers
GC_GENERAL_REGISTER_DISAPPEARING_LINK_SAFE() and
GC_REGISTER_LONG_LINK_SAFE() macros are provided.
* include/gc/gc.h (GC_GENERAL_REGISTER_DISAPPEARING_LINK_SAFE,
GC_REGISTER_LONG_LINK_SAFE): New API macros.
* include/gc/gc.h [GC_DEBUG] (GC_GENERAL_REGISTER_DISAPPEARING_LINK):
Use GC_GENERAL_REGISTER_DISAPPEARING_LINK_SAFE() instead of
GC_general_register_disappearing_link() and GC_base() directly.
* include/gc/gc.h [GC_DEBUG] (GC_REGISTER_LONG_LINK): Use
GC_REGISTER_LONG_LINK_SAFE() instead of GC_register_long_link() and
GC_base() directly.
Diffstat (limited to 'include')
-rw-r--r-- | include/gc/gc.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/include/gc/gc.h b/include/gc/gc.h index e28a1235..6bf37930 100644 --- a/include/gc/gc.h +++ b/include/gc/gc.h @@ -1037,6 +1037,15 @@ GC_API /* 'realloc' attr */ GC_ATTR_ALLOC_SIZE(2) void * GC_CALL GC_debug_realloc_replacement(void * /* object_addr */, size_t /* size_in_bytes */); +/* Convenient macros for disappearing links registration working both */ +/* for debug and non-debug allocated objects, and accepting interior */ +/* pointers to object. */ +#define GC_GENERAL_REGISTER_DISAPPEARING_LINK_SAFE(link, obj) \ + GC_general_register_disappearing_link(link, \ + GC_base((/* no const */ void *)(obj))) +#define GC_REGISTER_LONG_LINK_SAFE(link, obj) \ + GC_register_long_link(link, GC_base((/* no const */ void *)(obj))) + #ifdef GC_DEBUG_REPLACEMENT # define GC_MALLOC(sz) GC_debug_malloc_replacement(sz) # define GC_REALLOC(old, sz) GC_debug_realloc_replacement(old, sz) @@ -1072,10 +1081,9 @@ GC_API /* 'realloc' attr */ GC_ATTR_ALLOC_SIZE(2) void * GC_CALL # define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p) # define GC_PTR_STORE_AND_DIRTY(p, q) GC_debug_ptr_store_and_dirty(p, q) # define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \ - GC_general_register_disappearing_link(link, \ - GC_base((/* no const */ void *)(obj))) + GC_GENERAL_REGISTER_DISAPPEARING_LINK_SAFE(link, obj) # define GC_REGISTER_LONG_LINK(link, obj) \ - GC_register_long_link(link, GC_base((/* no const */ void *)(obj))) + GC_REGISTER_LONG_LINK_SAFE(link, obj) # define GC_REGISTER_DISPLACEMENT(n) GC_debug_register_displacement(n) #else # define GC_MALLOC_ATOMIC(sz) GC_malloc_atomic(sz) |