Skip to content

Commit

Permalink
2010-03-12 Ivan Maidanski <ivmai@mail.ru>
Browse files Browse the repository at this point in the history
	* alloc.c (GC_start_call_back): Replace the definition type to
	GC_start_callback_proc.
	* alloc.c (GC_set_start_callback, GC_get_start_callback): New
	setter/getter function.
	* alloc.c (GC_try_to_collect_inner): Call GC_notify_full_gc()
	unconditionally (because GC_try_to_collect_inner always does full
	GC).
	* include/gc_mark.h (GC_start_callback_proc): New type.
	* include/gc_mark.h (GC_set_start_callback,
	GC_get_start_callback): New API function declaration.
  • Loading branch information
ivmai authored and ivmai committed Jul 26, 2011
1 parent 90ca8ad commit 86a4ee9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
13 changes: 13 additions & 0 deletions ChangeLog
@@ -1,3 +1,16 @@
2010-03-12 Ivan Maidanski <ivmai@mail.ru>

* alloc.c (GC_start_call_back): Replace the definition type to
GC_start_callback_proc.
* alloc.c (GC_set_start_callback, GC_get_start_callback): New
setter/getter function.
* alloc.c (GC_try_to_collect_inner): Call GC_notify_full_gc()
unconditionally (because GC_try_to_collect_inner always does full
GC).
* include/gc_mark.h (GC_start_callback_proc): New type.
* include/gc_mark.h (GC_set_start_callback,
GC_get_start_callback): New API function declaration.

2010-03-12 Ivan Maidanski <ivmai@mail.ru>

* doc/README.macros (USE_GET_STACKBASE_FOR_MAIN): Document.
Expand Down
22 changes: 20 additions & 2 deletions alloc.c
Expand Up @@ -303,11 +303,29 @@ GC_INNER GC_bool GC_should_collect(void)
|| GC_heapsize >= GC_collect_at_heapsize);
}

/* STATIC */ void (*GC_start_call_back) (void) = 0;
/* STATIC */ GC_start_callback_proc GC_start_call_back = 0;
/* Called at start of full collections. */
/* Not called if 0. Called with the allocation */
/* lock held. Not used by GC itself. */

GC_API void GC_CALL GC_set_start_callback(GC_start_callback_proc fn)
{
DCL_LOCK_STATE;
LOCK();
GC_start_call_back = fn;
UNLOCK();
}

GC_API GC_start_callback_proc GC_CALL GC_get_start_callback(void)
{
GC_start_callback_proc fn;
DCL_LOCK_STATE;
LOCK();
fn = GC_start_call_back;
UNLOCK();
return fn;
}

GC_INLINE void GC_notify_full_gc(void)
{
if (GC_start_call_back != 0) {
Expand Down Expand Up @@ -407,7 +425,7 @@ GC_INNER GC_bool GC_try_to_collect_inner(GC_stop_func stop_func)
GC_collect_a_little_inner(1);
}
}
if (stop_func == GC_never_stop_func) GC_notify_full_gc();
GC_notify_full_gc();
# ifndef SMALL_CONFIG
if (GC_print_stats) {
GET_TIME(start_time);
Expand Down
7 changes: 7 additions & 0 deletions include/gc_mark.h
Expand Up @@ -211,6 +211,13 @@ GC_API void GC_CALL GC_register_describe_type_fn(int /* kind */,
GC_API size_t GC_CALL GC_get_heap_size_inner(void);
GC_API size_t GC_CALL GC_get_free_bytes_inner(void);

/* Set and get the client notifier on collections. The client function */
/* is called at the start of every full GC (called with the allocation */
/* lock held). May be 0. */
typedef void (GC_CALLBACK * GC_start_callback_proc)(void);
GC_API void GC_CALL GC_set_start_callback(GC_start_callback_proc);
GC_API GC_start_callback_proc GC_CALL GC_get_start_callback(void);

#ifdef __cplusplus
} /* end of extern "C" */
#endif
Expand Down

0 comments on commit 86a4ee9

Please sign in to comment.