-/* Debugging (annotated) allocation. GC_gcollect will check */
-/* objects allocated in this way for overwrites, etc. */
-GC_API void * GC_debug_malloc(size_t size_in_bytes, GC_EXTRA_PARAMS);
-GC_API void * GC_debug_malloc_atomic(size_t size_in_bytes, GC_EXTRA_PARAMS);
-GC_API char * GC_debug_strdup(const char *str, GC_EXTRA_PARAMS);
-GC_API void * GC_debug_malloc_uncollectable
- (size_t size_in_bytes, GC_EXTRA_PARAMS);
-GC_API void * GC_debug_malloc_stubborn
- (size_t size_in_bytes, GC_EXTRA_PARAMS);
-GC_API void * GC_debug_malloc_ignore_off_page
- (size_t size_in_bytes, GC_EXTRA_PARAMS);
-GC_API void * GC_debug_malloc_atomic_ignore_off_page
- (size_t size_in_bytes, GC_EXTRA_PARAMS);
-GC_API void GC_debug_free (void * object_addr);
-GC_API void * GC_debug_realloc
- (void * old_object, size_t new_size_in_bytes, GC_EXTRA_PARAMS);
-GC_API void GC_debug_change_stubborn(void *);
-GC_API void GC_debug_end_stubborn_change(void *);
-
-/* Routines that allocate objects with debug information (like the */
-/* above), but just fill in dummy file and line number information. */
-/* Thus they can serve as drop-in malloc/realloc replacements. This */
-/* can be useful for two reasons: */
-/* 1) It allows the collector to be built with DBG_HDRS_ALL defined */
-/* even if some allocation calls come from 3rd party libraries */
-/* that can't be recompiled. */
-/* 2) On some platforms, the file and line information is redundant, */
-/* since it can be reconstructed from a stack trace. On such */
-/* platforms it may be more convenient not to recompile, e.g. for */
-/* leak detection. This can be accomplished by instructing the */
-/* linker to replace malloc/realloc with these. */
-GC_API void * GC_debug_malloc_replacement (size_t size_in_bytes);
-GC_API void * GC_debug_realloc_replacement
- (void * object_addr, size_t size_in_bytes);
-
-# ifdef GC_DEBUG
-# define GC_MALLOC(sz) GC_debug_malloc(sz, GC_EXTRAS)
-# define GC_MALLOC_ATOMIC(sz) GC_debug_malloc_atomic(sz, GC_EXTRAS)
-# define GC_STRDUP(s) GC_debug_strdup((s), GC_EXTRAS)
-# define GC_MALLOC_UNCOLLECTABLE(sz) \
- GC_debug_malloc_uncollectable(sz, GC_EXTRAS)
-# define GC_MALLOC_IGNORE_OFF_PAGE(sz) \
- GC_debug_malloc_ignore_off_page(sz, GC_EXTRAS)
-# define GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE(sz) \
- GC_debug_malloc_atomic_ignore_off_page(sz, GC_EXTRAS)
-# define GC_REALLOC(old, sz) GC_debug_realloc(old, sz, GC_EXTRAS)
-# define GC_FREE(p) GC_debug_free(p)
-# define GC_REGISTER_FINALIZER(p, f, d, of, od) \
- GC_debug_register_finalizer(p, f, d, of, od)
-# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
- GC_debug_register_finalizer_ignore_self(p, f, d, of, od)
-# define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \
- GC_debug_register_finalizer_no_order(p, f, d, of, od)
-# define GC_REGISTER_FINALIZER_UNREACHABLE(p, f, d, of, od) \
- GC_debug_register_finalizer_unreachable(p, f, d, of, od)
-# define GC_MALLOC_STUBBORN(sz) GC_debug_malloc_stubborn(sz, GC_EXTRAS);
-# define GC_CHANGE_STUBBORN(p) GC_debug_change_stubborn(p)
-# define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p)
-# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
- GC_general_register_disappearing_link(link, GC_base(obj))
-# define GC_REGISTER_DISPLACEMENT(n) GC_debug_register_displacement(n)
-# else
-# define GC_MALLOC(sz) GC_malloc(sz)
-# define GC_MALLOC_ATOMIC(sz) GC_malloc_atomic(sz)
-# define GC_STRDUP(s) GC_strdup(s)
-# define GC_MALLOC_UNCOLLECTABLE(sz) GC_malloc_uncollectable(sz)
-# define GC_MALLOC_IGNORE_OFF_PAGE(sz) \
- GC_malloc_ignore_off_page(sz)
-# define GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE(sz) \
- GC_malloc_atomic_ignore_off_page(sz)
-# define GC_REALLOC(old, sz) GC_realloc(old, sz)
-# define GC_FREE(p) GC_free(p)
-# define GC_REGISTER_FINALIZER(p, f, d, of, od) \
- GC_register_finalizer(p, f, d, of, od)
-# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
- GC_register_finalizer_ignore_self(p, f, d, of, od)
-# define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \
- GC_register_finalizer_no_order(p, f, d, of, od)
-# define GC_REGISTER_FINALIZER_UNREACHABLE(p, f, d, of, od) \
- GC_register_finalizer_unreachable(p, f, d, of, od)
-# define GC_MALLOC_STUBBORN(sz) GC_malloc_stubborn(sz)
-# define GC_CHANGE_STUBBORN(p) GC_change_stubborn(p)
-# define GC_END_STUBBORN_CHANGE(p) GC_end_stubborn_change(p)
-# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
- GC_general_register_disappearing_link(link, obj)
-# define GC_REGISTER_DISPLACEMENT(n) GC_register_displacement(n)
-# endif
-/* The following are included because they are often convenient, and */
-/* reduce the chance for a misspecifed size argument. But calls may */
-/* expand to something syntactically incorrect if t is a complicated */
-/* type expression. */
-# define GC_NEW(t) (t *)GC_MALLOC(sizeof (t))
-# define GC_NEW_ATOMIC(t) (t *)GC_MALLOC_ATOMIC(sizeof (t))
-# define GC_NEW_STUBBORN(t) (t *)GC_MALLOC_STUBBORN(sizeof (t))
-# define GC_NEW_UNCOLLECTABLE(t) (t *)GC_MALLOC_UNCOLLECTABLE(sizeof (t))
-
-/* Finalization. Some of these primitives are grossly unsafe. */
-/* The idea is to make them both cheap, and sufficient to build */
-/* a safer layer, closer to Modula-3, Java, or PCedar finalization. */
-/* The interface represents my conclusions from a long discussion */
-/* with Alan Demers, Dan Greene, Carl Hauser, Barry Hayes, */
-/* Christian Jacobi, and Russ Atkinson. It's not perfect, and */
-/* probably nobody else agrees with it. Hans-J. Boehm 3/13/92 */
-typedef void (*GC_finalization_proc) (void * obj, void * client_data);
-
-GC_API void GC_register_finalizer(void * obj, GC_finalization_proc fn,
- void * cd, GC_finalization_proc *ofn,
- void * *ocd);
-GC_API void GC_debug_register_finalizer
- (void * obj, GC_finalization_proc fn, void * cd,
- GC_finalization_proc *ofn, void * *ocd);
- /* When obj is no longer accessible, invoke */
- /* (*fn)(obj, cd). If a and b are inaccessible, and */
- /* a points to b (after disappearing links have been */
- /* made to disappear), then only a will be */
- /* finalized. (If this does not create any new */
- /* pointers to b, then b will be finalized after the */
- /* next collection.) Any finalizable object that */
- /* is reachable from itself by following one or more */
- /* pointers will not be finalized (or collected). */
- /* Thus cycles involving finalizable objects should */
- /* be avoided, or broken by disappearing links. */
- /* All but the last finalizer registered for an object */
- /* is ignored. */
- /* Finalization may be removed by passing 0 as fn. */
- /* Finalizers are implicitly unregistered just before */
- /* they are invoked. */
- /* The old finalizer and client data are stored in */
- /* *ofn and *ocd. */
- /* Fn is never invoked on an accessible object, */
- /* provided hidden pointers are converted to real */
- /* pointers only if the allocation lock is held, and */
- /* such conversions are not performed by finalization */
- /* routines. */
- /* If GC_register_finalizer is aborted as a result of */
- /* a signal, the object may be left with no */
- /* finalization, even if neither the old nor new */
- /* finalizer were NULL. */
- /* Obj should be the nonNULL starting address of an */
- /* object allocated by GC_malloc or friends. */
- /* Note that any garbage collectable object referenced */
- /* by cd will be considered accessible until the */
- /* finalizer is invoked. */
-
-/* Another versions of the above follow. It ignores */
-/* self-cycles, i.e. pointers from a finalizable object to */
-/* itself. There is a stylistic argument that this is wrong, */
-/* but it's unavoidable for C++, since the compiler may */
-/* silently introduce these. It's also benign in that specific */
-/* case. And it helps if finalizable objects are split to */
-/* avoid cycles. */
-/* Note that cd will still be viewed as accessible, even if it */
-/* refers to the object itself. */
-GC_API void GC_register_finalizer_ignore_self
- (void * obj, GC_finalization_proc fn, void * cd,
- GC_finalization_proc *ofn, void * *ocd);
-GC_API void GC_debug_register_finalizer_ignore_self
- (void * obj, GC_finalization_proc fn, void * cd,
- GC_finalization_proc *ofn, void * *ocd);
+/* Debugging (annotated) allocation. GC_gcollect will check */
+/* objects allocated in this way for overwrites, etc. */
+GC_API void * GC_CALL GC_debug_malloc(size_t /* size_in_bytes */,
+ GC_EXTRA_PARAMS)
+ GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1);
+GC_API void * GC_CALL GC_debug_malloc_atomic(size_t /* size_in_bytes */,
+ GC_EXTRA_PARAMS)
+ GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1);
+GC_API char * GC_CALL GC_debug_strdup(const char *,
+ GC_EXTRA_PARAMS) GC_ATTR_MALLOC;
+GC_API void * GC_CALL GC_debug_malloc_uncollectable(
+ size_t /* size_in_bytes */, GC_EXTRA_PARAMS)
+ GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1);
+GC_API void * GC_CALL GC_debug_malloc_stubborn(size_t /* size_in_bytes */,
+ GC_EXTRA_PARAMS)
+ GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1);
+GC_API void * GC_CALL GC_debug_malloc_ignore_off_page(
+ size_t /* size_in_bytes */, GC_EXTRA_PARAMS)
+ GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1);
+GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page(
+ size_t /* size_in_bytes */, GC_EXTRA_PARAMS)
+ GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1);
+GC_API void GC_CALL GC_debug_free(void *);
+GC_API void * GC_CALL GC_debug_realloc(void * /* old_object */,
+ size_t /* new_size_in_bytes */, GC_EXTRA_PARAMS)
+ /* 'realloc' attr */ GC_ATTR_ALLOC_SIZE(2);
+GC_API void GC_CALL GC_debug_change_stubborn(void *);
+GC_API void GC_CALL GC_debug_end_stubborn_change(void *);
+
+/* Routines that allocate objects with debug information (like the */
+/* above), but just fill in dummy file and line number information. */
+/* Thus they can serve as drop-in malloc/realloc replacements. This */
+/* can be useful for two reasons: */
+/* 1) It allows the collector to be built with DBG_HDRS_ALL defined */
+/* even if some allocation calls come from 3rd party libraries */
+/* that can't be recompiled. */
+/* 2) On some platforms, the file and line information is redundant, */
+/* since it can be reconstructed from a stack trace. On such */
+/* platforms it may be more convenient not to recompile, e.g. for */
+/* leak detection. This can be accomplished by instructing the */
+/* linker to replace malloc/realloc with these. */
+GC_API void * GC_CALL GC_debug_malloc_replacement(size_t /* size_in_bytes */)
+ GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1);
+GC_API void * GC_CALL GC_debug_realloc_replacement(void * /* object_addr */,
+ size_t /* size_in_bytes */)
+ /* 'realloc' attr */ GC_ATTR_ALLOC_SIZE(2);
+
+#ifdef GC_DEBUG
+# define GC_MALLOC(sz) GC_debug_malloc(sz, GC_EXTRAS)
+# define GC_MALLOC_ATOMIC(sz) GC_debug_malloc_atomic(sz, GC_EXTRAS)
+# define GC_STRDUP(s) GC_debug_strdup((s), GC_EXTRAS)
+# define GC_MALLOC_UNCOLLECTABLE(sz) \
+ GC_debug_malloc_uncollectable(sz, GC_EXTRAS)
+# define GC_MALLOC_IGNORE_OFF_PAGE(sz) \
+ GC_debug_malloc_ignore_off_page(sz, GC_EXTRAS)
+# define GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE(sz) \
+ GC_debug_malloc_atomic_ignore_off_page(sz, GC_EXTRAS)
+# define GC_REALLOC(old, sz) GC_debug_realloc(old, sz, GC_EXTRAS)
+# define GC_FREE(p) GC_debug_free(p)
+# define GC_REGISTER_FINALIZER(p, f, d, of, od) \
+ GC_debug_register_finalizer(p, f, d, of, od)
+# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
+ GC_debug_register_finalizer_ignore_self(p, f, d, of, od)
+# define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \
+ GC_debug_register_finalizer_no_order(p, f, d, of, od)
+# define GC_REGISTER_FINALIZER_UNREACHABLE(p, f, d, of, od) \
+ GC_debug_register_finalizer_unreachable(p, f, d, of, od)
+# define GC_MALLOC_STUBBORN(sz) GC_debug_malloc_stubborn(sz, GC_EXTRAS);
+# define GC_CHANGE_STUBBORN(p) GC_debug_change_stubborn(p)
+# define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p)
+# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
+ GC_general_register_disappearing_link(link, GC_base(obj))
+# define GC_REGISTER_DISPLACEMENT(n) GC_debug_register_displacement(n)
+#else
+# define GC_MALLOC(sz) GC_malloc(sz)
+# define GC_MALLOC_ATOMIC(sz) GC_malloc_atomic(sz)
+# define GC_STRDUP(s) GC_strdup(s)
+# define GC_MALLOC_UNCOLLECTABLE(sz) GC_malloc_uncollectable(sz)
+# define GC_MALLOC_IGNORE_OFF_PAGE(sz) \
+ GC_malloc_ignore_off_page(sz)
+# define GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE(sz) \
+ GC_malloc_atomic_ignore_off_page(sz)
+# define GC_REALLOC(old, sz) GC_realloc(old, sz)
+# define GC_FREE(p) GC_free(p)
+# define GC_REGISTER_FINALIZER(p, f, d, of, od) \
+ GC_register_finalizer(p, f, d, of, od)
+# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
+ GC_register_finalizer_ignore_self(p, f, d, of, od)
+# define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \
+ GC_register_finalizer_no_order(p, f, d, of, od)
+# define GC_REGISTER_FINALIZER_UNREACHABLE(p, f, d, of, od) \
+ GC_register_finalizer_unreachable(p, f, d, of, od)
+# define GC_MALLOC_STUBBORN(sz) GC_malloc_stubborn(sz)
+# define GC_CHANGE_STUBBORN(p) GC_change_stubborn(p)
+# define GC_END_STUBBORN_CHANGE(p) GC_end_stubborn_change(p)
+# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
+ GC_general_register_disappearing_link(link, obj)
+# define GC_REGISTER_DISPLACEMENT(n) GC_register_displacement(n)
+#endif
+
+/* The following are included because they are often convenient, and */
+/* reduce the chance for a misspecified size argument. But calls may */
+/* expand to something syntactically incorrect if t is a complicated */
+/* type expression. */
+#define GC_NEW(t) (t *)GC_MALLOC(sizeof (t))
+#define GC_NEW_ATOMIC(t) (t *)GC_MALLOC_ATOMIC(sizeof (t))
+#define GC_NEW_STUBBORN(t) (t *)GC_MALLOC_STUBBORN(sizeof (t))
+#define GC_NEW_UNCOLLECTABLE(t) (t *)GC_MALLOC_UNCOLLECTABLE(sizeof (t))
+
+/* Finalization. Some of these primitives are grossly unsafe. */
+/* The idea is to make them both cheap, and sufficient to build */
+/* a safer layer, closer to Modula-3, Java, or PCedar finalization. */
+/* The interface represents my conclusions from a long discussion */
+/* with Alan Demers, Dan Greene, Carl Hauser, Barry Hayes, */
+/* Christian Jacobi, and Russ Atkinson. It's not perfect, and */
+/* probably nobody else agrees with it. Hans-J. Boehm 3/13/92 */
+typedef void (GC_CALLBACK * GC_finalization_proc)(void * /* obj */,
+ void * /* client_data */);
+
+GC_API void GC_CALL GC_register_finalizer(void * /* obj */,
+ GC_finalization_proc /* fn */, void * /* cd */,
+ GC_finalization_proc * /* ofn */, void ** /* ocd */);
+GC_API void GC_CALL GC_debug_register_finalizer(void * /* obj */,
+ GC_finalization_proc /* fn */, void * /* cd */,
+ GC_finalization_proc * /* ofn */, void ** /* ocd */);
+ /* When obj is no longer accessible, invoke */
+ /* (*fn)(obj, cd). If a and b are inaccessible, and */
+ /* a points to b (after disappearing links have been */
+ /* made to disappear), then only a will be */
+ /* finalized. (If this does not create any new */
+ /* pointers to b, then b will be finalized after the */
+ /* next collection.) Any finalizable object that */
+ /* is reachable from itself by following one or more */
+ /* pointers will not be finalized (or collected). */
+ /* Thus cycles involving finalizable objects should */
+ /* be avoided, or broken by disappearing links. */
+ /* All but the last finalizer registered for an object */
+ /* is ignored. */
+ /* Finalization may be removed by passing 0 as fn. */
+ /* Finalizers are implicitly unregistered when they are */
+ /* enqueued for finalization (i.e. become ready to be */
+ /* finalized). */
+ /* The old finalizer and client data are stored in */
+ /* *ofn and *ocd. (ofn and/or ocd may be NULL. */
+ /* The allocation lock is held while *ofn and *ocd are */
+ /* updated. In case of error (no memory to register */
+ /* new finalizer), *ofn and *ocd remain unchanged.) */
+ /* Fn is never invoked on an accessible object, */
+ /* provided hidden pointers are converted to real */
+ /* pointers only if the allocation lock is held, and */
+ /* such conversions are not performed by finalization */
+ /* routines. */
+ /* If GC_register_finalizer is aborted as a result of */
+ /* a signal, the object may be left with no */
+ /* finalization, even if neither the old nor new */
+ /* finalizer were NULL. */
+ /* Obj should be the starting address of an object */
+ /* allocated by GC_malloc or friends. Obj may also be */
+ /* NULL or point to something outside GC heap (in this */
+ /* case, fn is ignored, *ofn and *ocd are set to NULL). */
+ /* Note that any garbage collectable object referenced */
+ /* by cd will be considered accessible until the */
+ /* finalizer is invoked. */
+
+/* Another versions of the above follow. It ignores */
+/* self-cycles, i.e. pointers from a finalizable object to */
+/* itself. There is a stylistic argument that this is wrong, */
+/* but it's unavoidable for C++, since the compiler may */
+/* silently introduce these. It's also benign in that specific */
+/* case. And it helps if finalizable objects are split to */
+/* avoid cycles. */
+/* Note that cd will still be viewed as accessible, even if it */
+/* refers to the object itself. */
+GC_API void GC_CALL GC_register_finalizer_ignore_self(void * /* obj */,
+ GC_finalization_proc /* fn */, void * /* cd */,
+ GC_finalization_proc * /* ofn */, void ** /* ocd */);
+GC_API void GC_CALL GC_debug_register_finalizer_ignore_self(void * /* obj */,
+ GC_finalization_proc /* fn */, void * /* cd */,
+ GC_finalization_proc * /* ofn */, void ** /* ocd */);