void GC_check_tls(void);
#endif
-void (*GC_on_heap_resize)(size_t new_size) = 0;
+GC_on_heap_resize_proc GC_on_heap_resize = 0;
/* Finish up a collection. Assumes mark bits are consistent, lock is */
/* held, but the world is otherwise running. */
if (GC_collect_at_heapsize < GC_heapsize /* wrapped */)
GC_collect_at_heapsize = (word)(-1);
if (GC_on_heap_resize)
- (*GC_on_heap_resize)((size_t)GC_heapsize);
+ (*GC_on_heap_resize)(GC_heapsize);
return(TRUE);
}
GC_API void GC_CALL GC_set_oom_fn(GC_oom_func);
GC_API GC_oom_func GC_CALL GC_get_oom_fn(void);
-GC_API void (*GC_on_heap_resize)(size_t /* new_size */);
- /* Invoked when the heap grows or shrinks */
+typedef void (GC_CALLBACK * GC_on_heap_resize_proc)(GC_word /* new_size */);
+GC_API GC_on_heap_resize_proc GC_on_heap_resize;
+ /* Invoked when the heap grows or shrinks. */
+ /* Called with the world stopped (and the */
+ /* allocation lock held). May be 0. */
+GC_API void GC_CALL GC_set_on_heap_resize(GC_on_heap_resize_proc);
+GC_API GC_on_heap_resize_proc GC_CALL GC_get_on_heap_resize(void);
+ /* Both the supplied setter and the getter */
+ /* acquire the GC lock (to avoid data races). */
GC_API int GC_find_leak;
/* Do not actually garbage collect, but simply */
return fn;
}
+GC_API void GC_CALL GC_set_on_heap_resize(GC_on_heap_resize_proc fn)
+{
+ /* fn may be 0 (means no event notifier). */
+ DCL_LOCK_STATE;
+ LOCK();
+ GC_on_heap_resize = fn;
+ UNLOCK();
+}
+
+GC_API GC_on_heap_resize_proc GC_CALL GC_get_on_heap_resize(void)
+{
+ GC_on_heap_resize_proc fn;
+ DCL_LOCK_STATE;
+ LOCK();
+ fn = GC_on_heap_resize;
+ UNLOCK();
+ return fn;
+}
+
GC_API void GC_CALL GC_set_finalizer_notifier(GC_finalizer_notifier_proc fn)
{
/* fn may be 0 (means no finalizer notifier). */