From: Jean-Claude Beaudoin Date: Sun, 24 Jun 2012 03:34:50 +0000 (-0400) Subject: Segregated exit and abort hooks changes into their own branch X-Git-Tag: gc7_4_0~263^2^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eaa195f75fea74e26e97393195395f8798f1423a;p=gc Segregated exit and abort hooks changes into their own branch --- diff --git a/include/gc.h b/include/gc.h index ba0962db..42c205a0 100644 --- a/include/gc.h +++ b/include/gc.h @@ -1611,19 +1611,13 @@ GC_API void GC_CALL GC_win32_free_heap(void); #endif /* _AMIGA && !GC_AMIGA_MAKINGLIB */ -typedef void (GC_CALLBACK * GC_exit_func)(const int status); +typedef void (GC_CALLBACK * GC_exit_func)(int /* status */); -GC_API void GC_CALL GC_set_exit_func(GC_exit_func fn); +GC_API void GC_CALL GC_set_exit_func(GC_exit_func); -typedef void (GC_CALLBACK * GC_abort_func)(const char * const msg); - -GC_API void GC_CALL GC_set_abort_func(GC_abort_func fn); - -#if defined(GC_LINUX_THREADS) -GC_API void GC_CALL GC_set_suspend_signal(const int sig); -GC_API void GC_CALL GC_set_thr_restart_signal(const int sig); -#endif +typedef void (GC_CALLBACK * GC_abort_func)(char * /* msg */); +GC_API void GC_CALL GC_set_abort_func(GC_abort_func); #ifdef __cplusplus } /* end of extern "C" */ diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h index 9d589007..eee7ff3b 100644 --- a/include/gc_config_macros.h +++ b/include/gc_config_macros.h @@ -376,4 +376,14 @@ #endif /* GC_PTHREADS */ +# if !defined(GC_ATTR_NORETURN) + # if defined(__GNUC__) /* since GCC v2.7 */ +# define GC_ATTR_NORETURN __attribute__((__noreturn__)) +# elif defined(__NORETURN) /* used in Solaris */ +# define GC_ATTR_NORETURN __NORETURN +# else +# define GC_ATTR_NORETURN /* empty */ +# endif +# endif + #endif diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 91695132..db9571da 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -493,7 +493,7 @@ typedef char * ptr_t; /* A generic pointer to which we can add */ # ifdef PCR # define EXIT() PCR_Base_Exit(1,PCR_waitForever) # else - GC_API_PRIV void GC_exit(int status); + GC_API_PRIV void GC_exit(int status) GC_ATTR_NORETURN; # define EXIT() GC_exit(1) # endif @@ -2287,10 +2287,7 @@ GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str, # define SIG_SUSPEND SIGLOST # else /* Linuxthreads itself uses SIGUSR1 and SIGUSR2. */ -# define SIG_SUSPEND GC_get_suspend_signal() -# define SIG_THR_RESTART GC_get_thr_restart_signal() -# define SIG_SUSPEND_DEFAULT SIGPWR -# define SIG_THR_RESTART_DEFAULT SIGXCPU +# define SIG_SUSPEND SIGPWR # endif # elif !defined(GC_OPENBSD_THREADS) && !defined(GC_DARWIN_THREADS) # if defined(_SIGRTMIN) diff --git a/misc.c b/misc.c index 7ae02f5b..79c88bde 100644 --- a/misc.c +++ b/misc.c @@ -509,40 +509,12 @@ GC_API void GC_CALL GC_get_heap_usage_safe(GC_word *pheap_size, #ifdef THREADS -STATIC int suspend_signal = SIG_SUSPEND_DEFAULT; -STATIC int thread_restart_signal = SIG_THR_RESTART_DEFAULT; - -void GC_set_suspend_signal(const int sig) -{ - if (GC_is_initialized) return; - suspend_signal = sig; -} - -void GC_set_thread_restart_signal(const int sig) -{ - if (GC_is_initialized) return; - thread_restart_signal = sig; -} - - - GC_API int GC_CALL GC_get_suspend_signal(void) - { -# ifdef SIG_SUSPEND - return suspend_signal; -# else - return -1; -# endif - } - - GC_API int GC_CALL GC_get_thr_restart_signal(void) - { -# ifdef SIG_THR_RESTART - return thread_restart_signal; -# else +# if defined(GC_DARWIN_THREADS) || defined(GC_WIN32_THREADS) + GC_API int GC_CALL GC_get_thr_restart_signal(void) + { return -1; /* GC does not use signals to restart threads. */ -# endif - } - + } +# endif #endif /* THREADS */ #if !defined(_MAX_PATH) && (defined(MSWIN32) || defined(MSWINCE) \ @@ -1478,7 +1450,7 @@ GC_API GC_warn_proc GC_CALL GC_get_warn_proc(void) return(result); } -STATIC GC_abort_func abort_fn = NULL; /* JCB */ +STATIC GC_abort_func abort_fn = NULL; GC_API void GC_CALL GC_set_abort_func(GC_abort_func fn) {