/* to suppress all warnings (unless statistics printing is turned on). */
GC_API void GC_CALLBACK GC_ignore_warn_proc(char *, GC_word);
+/* abort_func is invoked on GC fatal aborts (just before OS-dependent */
+/* abort or exit(1) is called). Must be non-NULL. The default one */
+/* outputs msg to stderr provided msg is non-NULL. msg is NULL if */
+/* invoked before exit(1) otherwise msg is non-NULL (i.e., if invoked */
+/* before abort). Both the setter and getter acquire the GC lock. */
+/* Both the setter and getter are defined only if the library has been */
+/* compiled without SMALL_CONFIG. */
+typedef void (GC_CALLBACK * GC_abort_func)(const char * /* msg */);
+GC_API void GC_CALL GC_set_abort_func(GC_abort_func) GC_ATTR_NONNULL(1);
+GC_API GC_abort_func GC_CALL GC_get_abort_func(void);
+
/* The following is intended to be used by a higher level */
/* (e.g. Java-like) finalization facility. It is expected */
/* that finalization code will arrange for hidden pointers to */
# ifdef SMALL_CONFIG
# define GC_on_abort(msg) (void)0 /* be silent on abort */
# else
- GC_API_PRIV void GC_on_abort(const char * msg);
+ GC_API_PRIV GC_abort_func GC_on_abort;
# endif /* !SMALL_CONFIG */
# if defined(MSWIN32) && (defined(NO_DEBUGGING) || defined(LINT2))
/* A more user-friendly abort after showing fatal message. */
/* Print (or display) a message before abnormal exit (including */
/* abort). Invoked from ABORT(msg) macro (there msg is non-NULL) */
/* and from EXIT() macro (msg is NULL in that case). */
- void GC_on_abort(const char *msg)
+ STATIC void GC_CALLBACK GC_default_on_abort(const char *msg)
{
if (msg != NULL) {
# if defined(MSWIN32)
}
# endif
}
+
+ GC_abort_func GC_on_abort = GC_default_on_abort;
+
+ GC_API void GC_CALL GC_set_abort_func(GC_abort_func fn)
+ {
+ DCL_LOCK_STATE;
+ GC_ASSERT(fn != 0);
+ LOCK();
+ GC_on_abort = fn;
+ UNLOCK();
+ }
+
+ GC_API GC_abort_func GC_CALL GC_get_abort_func(void)
+ {
+ GC_abort_func fn;
+ DCL_LOCK_STATE;
+ LOCK();
+ fn = GC_on_abort;
+ UNLOCK();
+ return fn;
+ }
#endif /* !SMALL_CONFIG */
GC_API void GC_CALL GC_enable(void)