Index: boehm-gc/pthread_support.c =================================================================== RCS file: /cvs/gcc/gcc/boehm-gc/pthread_support.c,v retrieving revision 1.2 diff -u -p -r1.2 pthread_support.c --- boehm-gc/pthread_support.c 13 Aug 2004 23:05:30 -0000 1.2 +++ boehm-gc/pthread_support.c 4 Jul 2005 01:37:10 -0000 @@ -44,7 +44,10 @@ * + # define GC_LOCK_TAKEN GC_allocate_lock */ -/*#define DEBUG_THREADS 1*/ +#define _GNU_SOURCE +#include + +#define DEBUG_THREADS 1 /*#define GC_ASSERTIONS*/ # include "gc.h" @@ -1194,8 +1197,24 @@ void * GC_start_routine(void * arg) return(result); } +/* 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_ = dlsym (RTLD_NEXT, "pthread_create"); +} + int -WRAP_FUNC(pthread_create)(pthread_t *new_thread, +pthread_create (pthread_t *new_thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) { @@ -1250,7 +1269,7 @@ WRAP_FUNC(pthread_create)(pthread_t *new pthread_self()); # endif - result = REAL_FUNC(pthread_create)(new_thread, attr, GC_start_routine, si); + result = (*pthread_create_)(new_thread, attr, GC_start_routine, si); # ifdef DEBUG_THREADS GC_printf1("Started thread 0x%X\n", *new_thread); Index: boehm-gc/include/gc_pthread_redirects.h =================================================================== RCS file: /cvs/gcc/gcc/boehm-gc/include/gc_pthread_redirects.h,v retrieving revision 1.4 diff -u -p -r1.4 gc_pthread_redirects.h --- boehm-gc/include/gc_pthread_redirects.h 28 Jul 2003 04:18:23 -0000 1.4 +++ boehm-gc/include/gc_pthread_redirects.h 4 Jul 2005 01:37:10 -0000 @@ -67,8 +67,8 @@ # undef pthread_join # undef pthread_detach #endif - -# define pthread_create GC_pthread_create +// Test new pthread_create wrapping mechanism. +// # define pthread_create GC_pthread_create # define pthread_join GC_pthread_join # define pthread_detach GC_pthread_detach