summaryrefslogtreecommitdiff
path: root/boehm-gc/pthread_support.c
diff options
context:
space:
mode:
Diffstat (limited to 'boehm-gc/pthread_support.c')
-rw-r--r--boehm-gc/pthread_support.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/boehm-gc/pthread_support.c b/boehm-gc/pthread_support.c
index 4271803c7c2..7c7bb0519b2 100644
--- a/boehm-gc/pthread_support.c
+++ b/boehm-gc/pthread_support.c
@@ -47,6 +47,9 @@
/*#define DEBUG_THREADS 1*/
/*#define GC_ASSERTIONS*/
+#define _GNU_SOURCE
+#include <dlfcn.h>
+
# include "gc.h"
# include "private/pthread_support.h"
@@ -1193,8 +1196,37 @@ void * GC_start_routine(void * arg)
return(result);
}
+#ifdef GC_PTHREAD_SYM_VERSION
+
+/* Force constr to execute prior to main(). */
+static void constr (void) __attribute__ ((constructor));
+
+static int
+(*pthread_create_)(pthread_t *new_thread,
+ const pthread_attr_t *attr_in,
+ void * (*thread_execp)(void *), void *arg);
+
+static void
+constr (void)
+{
+ /* Get a pointer to the real pthread_create. */
+ pthread_create_ = dlvsym (RTLD_NEXT, "pthread_create",
+ GC_PTHREAD_SYM_VERSION);
+}
+
+#define GC_PTHREAD_CREATE_NAME pthread_create
+#define GC_PTHREAD_REAL_NAME (*pthread_create_)
+
+#else
+
+#define GC_PTHREAD_CREATE_NAME WRAP_FUNC(pthread_create)
+#define GC_PTHREAD_REAL_NAME REAL_FUNC(pthread_create)
+
+#endif
+
+
int
-WRAP_FUNC(pthread_create)(pthread_t *new_thread,
+GC_PTHREAD_CREATE_NAME(pthread_t *new_thread,
const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg)
{
@@ -1255,7 +1287,7 @@ WRAP_FUNC(pthread_create)(pthread_t *new_thread,
pthread_self());
# endif
- result = REAL_FUNC(pthread_create)(new_thread, attr, GC_start_routine, si);
+ result = GC_PTHREAD_REAL_NAME(new_thread, attr, GC_start_routine, si);
# ifdef DEBUG_THREADS
GC_printf1("Started thread 0x%X\n", *new_thread);