diff options
author | Jason Evans <jasone@canonware.com> | 2009-12-29 08:09:15 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2009-12-29 08:09:15 (GMT) |
commit | d64d4448cd421ab3b9c28e11b4172944881981df (patch) | |
tree | 30e7b9e01b39abe18705c311d64b45205b503402 /jemalloc/src | |
parent | f2518147794cf631e35d1a7e186656770b14a2ca (diff) | |
download | jemalloc-d64d4448cd421ab3b9c28e11b4172944881981df.zip jemalloc-d64d4448cd421ab3b9c28e11b4172944881981df.tar.gz jemalloc-d64d4448cd421ab3b9c28e11b4172944881981df.tar.bz2 |
Modify pthread_create() wrapper such that isthreaded is only set once.
Diffstat (limited to 'jemalloc/src')
-rw-r--r-- | jemalloc/src/jemalloc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/jemalloc/src/jemalloc.c b/jemalloc/src/jemalloc.c index 1644ee4..a371d02 100644 --- a/jemalloc/src/jemalloc.c +++ b/jemalloc/src/jemalloc.c @@ -1115,6 +1115,9 @@ static void wrtmessage(const char *p1, const char *p2, const char *p3, #ifdef JEMALLOC_STATS static void malloc_printf(const char *format, ...); #endif +#ifdef JEMALLOC_LAZY_LOCK +static void pthread_create_once(void); +#endif static char *umax2s(uintmax_t x, unsigned base, char *s); #ifdef JEMALLOC_DSS 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); static void -get_pthread_create_fptr(void) +pthread_create_once(void) { pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create"); @@ -1346,6 +1349,8 @@ get_pthread_create_fptr(void) ""); abort(); } + + isthreaded = true; } int @@ -1355,9 +1360,8 @@ pthread_create(pthread_t *__restrict thread, { 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)); } #endif |