summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2013-07-16 14:19:12 +0200
committerIvan Maidanski <ivmai@mail.ru>2013-07-16 14:19:12 +0200
commita05920c6a86a0e2b9c7989c5b42945d89039e8a7 (patch)
treef39a1856c6d094e7edc43b83ebc8076e68c082a8
parent07676ad23c787fc5d399830308ae2a749151c627 (diff)
Allow to compile GC_inner_start_routine aside from extra/gc.c
(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.
-rw-r--r--extra/gc.c4
-rw-r--r--include/private/pthread_support.h11
-rw-r--r--pthread_start.c5
-rw-r--r--pthread_support.c8
4 files changed, 20 insertions, 8 deletions
diff --git a/extra/gc.c b/extra/gc.c
index 9c16d20..fa70a0a 100644
--- a/extra/gc.c
+++ b/extra/gc.c
@@ -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). */
diff --git a/include/private/pthread_support.h b/include/private/pthread_support.h
index 8820fc4..525a9aa 100644
--- a/include/private/pthread_support.h
+++ b/include/private/pthread_support.h
@@ -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 */
diff --git a/pthread_start.c b/pthread_start.c
index 776a368..bd4fc4a 100644
--- a/pthread_start.c
+++ b/pthread_start.c
@@ -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;
diff --git a/pthread_support.c b/pthread_support.c
index 994a2ed..c129e63 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -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)