]> granicus.if.org Git - gc/commitdiff
Segregated suspend/restart signal init changes into their own branch.
authorJean-Claude Beaudoin <jean.claude.beaudoin@gmail.com>
Sun, 24 Jun 2012 07:15:46 +0000 (03:15 -0400)
committerJean-Claude Beaudoin <jean.claude.beaudoin@gmail.com>
Sun, 24 Jun 2012 07:15:46 +0000 (03:15 -0400)
include/gc.h
include/private/gc_priv.h
misc.c

index ba0962dbd5bc1b52971ad37b9b3bec580945fba6..1cc3929148620576e877b0f63d7320799a440b27 100644 (file)
@@ -1131,13 +1131,21 @@ GC_API void * GC_CALL GC_call_with_stack_base(GC_stack_base_func /* fn */,
 #endif
 
 #ifdef GC_THREADS
-  /* Return the signal number (constant) used by the garbage collector  */
+  /* Return the signal number (constant after init) used by the GC      */
   /* to suspend threads on POSIX systems.  Return -1 otherwise.         */
   GC_API int GC_CALL GC_get_suspend_signal(void);
+  /* Sets the signal number (constant after init) used by the GC        */
+  /* to suspend threads on POSIX systems.                               */
+  /* Effective only when used before GC_init().                         */
+  GC_API void GC_CALL GC_set_suspend_signal(int sig);
 
-  /* Return the signal number (constant) used by the garbage collector  */
+  /* Return the signal number (constant after init) used by the GC      */
   /* to restart (resume) threads on POSIX systems. Return -1 otherwise. */
   GC_API int GC_CALL GC_get_thr_restart_signal(void);
+  /* Sets the signal number (constant after init) used by the GC        */
+  /* to restart (resume) threads on POSIX systems.                      */
+  /* Effective only when used before GC_init().                         */
+  GC_API void GC_CALL GC_set_thr_restart_signal(int sig);
 
   /* Explicitly enable GC_register_my_thread() invocation.              */
   /* Done implicitly if a GC thread-creation function is called (or     */
@@ -1610,21 +1618,6 @@ GC_API void GC_CALL GC_win32_free_heap(void);
         (*GC_amiga_allocwrapper_do)(a,GC_malloc_atomic_ignore_off_page)
 #endif /* _AMIGA && !GC_AMIGA_MAKINGLIB */
 
-
-typedef void (GC_CALLBACK * GC_exit_func)(const int status);
-
-GC_API void GC_CALL GC_set_exit_func(GC_exit_func fn);
-
-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
-
-
 #ifdef __cplusplus
   }  /* end of extern "C" */
 #endif
index 91695132f753cf693b092d33b8115a2a5801a8e6..578a1e2bdb1ecd3919d59baf0cd1879f001b3b02 100644 (file)
@@ -493,8 +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);
-#   define EXIT() GC_exit(1)
+#   define EXIT() (void)exit(1)
 # endif
 
 /* Print warning message, e.g. almost out of memory.    */
diff --git a/misc.c b/misc.c
index 7ae02f5bd5b1cd76b30901ead812fe29027d273c..7c418cf24a15f9ca01bbe8be2a2f1f8c4549a6bd 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -509,39 +509,43 @@ GC_API void GC_CALL GC_get_heap_usage_safe(GC_word *pheap_size,
 
 
 #ifdef THREADS
+# ifdef SIG_SUSPEND_DEFAULT
 STATIC int suspend_signal = SIG_SUSPEND_DEFAULT;
+# else
+STATIC int suspend_signal = -1;
+# endif
+# ifdef SIG_THR_RESTART_DEFAULT
 STATIC int thread_restart_signal = SIG_THR_RESTART_DEFAULT;
+# else
+STATIC int thread_restart_signal = -1;
+# endif
 
-void GC_set_suspend_signal(const int sig)
+GC_API void GC_CALL GC_set_suspend_signal(int sig)
 {
+# ifdef SIG_SUSPEND_DEFAULT
   if (GC_is_initialized) return;
   suspend_signal = sig;
+# endif
 }
 
-void GC_set_thread_restart_signal(const int sig)
+GC_API void GC_CALL GC_set_thread_restart_signal(int sig)
 {
+# ifdef SIG_THR_RESTART_DEFAULT
   if (GC_is_initialized) return;
   thread_restart_signal = sig;
+# endif
 }
 
 
-    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_suspend_signal(void)
+{
+  return suspend_signal;
+}
 
-    GC_API int GC_CALL GC_get_thr_restart_signal(void)
-    {
-#   ifdef SIG_THR_RESTART
-      return thread_restart_signal;
-#   else      
-      return -1; /* GC does not use signals to restart threads. */
-#   endif
-    }
+GC_API int GC_CALL GC_get_thr_restart_signal(void)
+{
+  return thread_restart_signal;
+}
 
 #endif /* THREADS */
 
@@ -1478,19 +1482,10 @@ GC_API GC_warn_proc GC_CALL GC_get_warn_proc(void)
     return(result);
 }
 
-STATIC GC_abort_func abort_fn = NULL; /* JCB */
-
-GC_API void GC_CALL GC_set_abort_func(GC_abort_func fn)
-{
-  abort_fn = fn;
-}
-
-
 #if !defined(PCR) && !defined(SMALL_CONFIG)
   /* Print (or display) a message before abort. msg must not be NULL. */
   void GC_on_abort(const char *msg)
   {
-    if (abort_fn) abort_fn(msg);
 #   if defined(MSWIN32)
 #     ifndef DONT_USE_USER32_DLL
         /* Use static binding to "user32.dll".  */
@@ -1527,20 +1522,6 @@ GC_API void GC_CALL GC_set_abort_func(GC_abort_func fn)
   }
 #endif /* !SMALL_CONFIG */
 
-STATIC GC_exit_func exit_fn = NULL;
-
-void GC_exit(int status)
-{
-  if (exit_fn) exit_fn(status);
-  (void) exit(status);
-}
-
-GC_API void GC_CALL GC_set_exit_func(GC_exit_func fn)
-{
-  exit_fn = fn;
-}
-
-
 GC_API void GC_CALL GC_enable(void)
 {
     DCL_LOCK_STATE;