]> granicus.if.org Git - gc/commitdiff
Allow to compile GC_inner_start_routine aside from extra/gc.c
authorIvan Maidanski <ivmai@mail.ru>
Tue, 16 Jul 2013 12:19:12 +0000 (16:19 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 16 Jul 2013 12:19:12 +0000 (16:19 +0400)
(for proper exceptions support on Linux)

* extra/gc.c: Do not include pthread_start.c if
GC_PTHREAD_START_STANDALONE defined (thus pthread_start.c could go to
a standalone compilation unit).
* include/private/pthread_support.h (GC_INNER_PTHRSTART): New macro
(defined to either empty or GC_INNER depending on
GC_PTHREAD_START_STANDALONE).
* include/private/pthread_support.h (GC_start_rtn_prepare_thread,
GC_thread_exit_proc): Replace GC_INNER to GC_INNER_PTHRSTART.
* pthread_support.c (GC_thread_exit_proc,
GC_start_rtn_prepare_thread): Likewise.
* pthread_start.c (GC_inner_start_routine): Define as
GC_INNER_PTHRSTART; do not call GC_log_printf if
GC_PTHREAD_START_STANDALONE (since the function might be visible only
within extra/gc.c compilation unit).
* pthread_support.c (GC_inner_start_routine): Declare as
GC_INNER_PTHRSTART.

extra/gc.c
include/private/pthread_support.h
pthread_start.c
pthread_support.c

index 9c16d2066beabe65f98d22574b52857f7b0d56d0..fa70a0a886d2d0a07ddacc8fb1b1e59ea720b76c 100644 (file)
@@ -70,7 +70,9 @@
 #include "../specific.c"
 #include "../win32_threads.c"
 
-#include "../pthread_start.c"
+#ifndef GC_PTHREAD_START_STANDALONE
+# include "../pthread_start.c"
+#endif
 
 /* Restore pthread calls redirection (if altered in             */
 /* pthread_stop_world.c, pthread_support.c or win32_threads.c). */
index 8820fc475c308adf2ec9223f0c9591c4e854e9cb..525a9aac2f37340b24f52e0c161df1a276a47dd0 100644 (file)
@@ -136,10 +136,17 @@ GC_EXTERN GC_bool GC_in_thread_creation;
   GC_INNER void GC_unblock_gc_signals(void);
 #endif
 
-GC_INNER GC_thread GC_start_rtn_prepare_thread(void *(**pstart)(void *),
+#ifdef GC_PTHREAD_START_STANDALONE
+# define GC_INNER_PTHRSTART /* empty */
+#else
+# define GC_INNER_PTHRSTART GC_INNER
+#endif
+
+GC_INNER_PTHRSTART GC_thread GC_start_rtn_prepare_thread(
+                                        void *(**pstart)(void *),
                                         void **pstart_arg,
                                         struct GC_stack_base *sb, void *arg);
-GC_INNER void GC_thread_exit_proc(void *);
+GC_INNER_PTHRSTART void GC_thread_exit_proc(void *);
 
 #endif /* GC_PTHREADS && !GC_WIN32_THREADS */
 
index 776a368d29dd7b6d36ef9fb1ced3b37314eeb817..bd4fc4a048893f655903a8d5c56f40ed968f83e9 100644 (file)
@@ -42,7 +42,8 @@
 #include <sched.h>
 
 /* Invoked from GC_start_routine(). */
-void * GC_CALLBACK GC_inner_start_routine(struct GC_stack_base *sb, void *arg)
+GC_INNER_PTHRSTART void * GC_CALLBACK GC_inner_start_routine(
+                                        struct GC_stack_base *sb, void *arg)
 {
   void * (*start)(void *);
   void * start_arg;
@@ -54,7 +55,7 @@ void * GC_CALLBACK GC_inner_start_routine(struct GC_stack_base *sb, void *arg)
     pthread_cleanup_push(GC_thread_exit_proc, me);
 # endif
   result = (*start)(start_arg);
-# ifdef DEBUG_THREADS
+# if defined(DEBUG_THREADS) && !defined(GC_PTHREAD_START_STANDALONE)
     GC_log_printf("Finishing thread %p\n", (void *)pthread_self());
 # endif
   me -> status = result;
index 994a2edf35f02cb0f9b867627476f8233281315f..c129e63e089fc56b07713e454f13fe804078db0d 100644 (file)
@@ -1361,7 +1361,7 @@ GC_API int GC_CALL GC_unregister_my_thread(void)
 /* results in at most a tiny one-time leak.  And        */
 /* linuxthreads doesn't reclaim the main threads        */
 /* resources or id anyway.                              */
-GC_INNER void GC_thread_exit_proc(void *arg)
+GC_INNER_PTHRSTART void GC_thread_exit_proc(void *arg)
 {
 #   ifdef DEBUG_THREADS
         GC_log_printf("Called GC_thread_exit_proc on %p, gc_thread = %p\n",
@@ -1597,7 +1597,8 @@ struct start_info {
 /* Called from GC_inner_start_routine().  Defined in this file to       */
 /* minimize the number of include files in pthread_start.c (because     */
 /* sem_t and sem_post() are not used that file directly).               */
-GC_INNER GC_thread GC_start_rtn_prepare_thread(void *(**pstart)(void *),
+GC_INNER_PTHRSTART GC_thread GC_start_rtn_prepare_thread(
+                                        void *(**pstart)(void *),
                                         void **pstart_arg,
                                         struct GC_stack_base *sb, void *arg)
 {
@@ -1627,7 +1628,8 @@ GC_INNER GC_thread GC_start_rtn_prepare_thread(void *(**pstart)(void *),
     return me;
 }
 
-void * GC_CALLBACK GC_inner_start_routine(struct GC_stack_base *sb, void *arg);
+GC_INNER_PTHRSTART void * GC_CALLBACK GC_inner_start_routine(
+                                        struct GC_stack_base *sb, void *arg);
                                         /* defined in pthread_start.c   */
 
 STATIC void * GC_start_routine(void * arg)