Modify pthread_create() wrapper such that isthreaded is only set once.

This commit is contained in:
Jason Evans 2009-12-29 00:09:15 -08:00
parent f251814779
commit d64d4448cd

View File

@ -1115,6 +1115,9 @@ static void wrtmessage(const char *p1, const char *p2, const char *p3,
#ifdef JEMALLOC_STATS #ifdef JEMALLOC_STATS
static void malloc_printf(const char *format, ...); static void malloc_printf(const char *format, ...);
#endif #endif
#ifdef JEMALLOC_LAZY_LOCK
static void pthread_create_once(void);
#endif
static char *umax2s(uintmax_t x, unsigned base, char *s); static char *umax2s(uintmax_t x, unsigned base, char *s);
#ifdef JEMALLOC_DSS #ifdef JEMALLOC_DSS
static bool base_pages_alloc_dss(size_t minsize); static bool base_pages_alloc_dss(size_t minsize);
@ -1336,7 +1339,7 @@ int (*pthread_create_fptr)(pthread_t *__restrict, const pthread_attr_t *,
void *(*)(void *), void *__restrict); void *(*)(void *), void *__restrict);
static void static void
get_pthread_create_fptr(void) pthread_create_once(void)
{ {
pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create"); pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create");
@ -1346,6 +1349,8 @@ get_pthread_create_fptr(void)
""); "");
abort(); abort();
} }
isthreaded = true;
} }
int int
@ -1355,9 +1360,8 @@ pthread_create(pthread_t *__restrict thread,
{ {
static pthread_once_t once_control = PTHREAD_ONCE_INIT; static pthread_once_t once_control = PTHREAD_ONCE_INIT;
pthread_once(&once_control, get_pthread_create_fptr); pthread_once(&once_control, pthread_create_once);
isthreaded = true;
return (pthread_create_fptr(thread, attr, start_routine, arg)); return (pthread_create_fptr(thread, attr, start_routine, arg));
} }
#endif #endif