From b480808a6a511c9350a6559b63938ac261c83a76 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 3 Mar 2011 18:30:44 -0500 Subject: optimize POSIX TSD for fast pthread_getspecific --- src/thread/pthread_setspecific.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/thread/pthread_setspecific.c') diff --git a/src/thread/pthread_setspecific.c b/src/thread/pthread_setspecific.c index 171cef41..55e46a89 100644 --- a/src/thread/pthread_setspecific.c +++ b/src/thread/pthread_setspecific.c @@ -2,13 +2,7 @@ int pthread_setspecific(pthread_key_t k, const void *x) { - struct pthread *self = pthread_self(); - /* Handle the case of the main thread */ - if (!self->tsd) { - if (!x) return 0; - if (!(self->tsd = calloc(sizeof(void *), PTHREAD_KEYS_MAX))) - return ENOMEM; - } + struct pthread *self = __pthread_self(); /* Avoid unnecessary COW */ if (self->tsd[k] != x) { self->tsd[k] = (void *)x; -- cgit v1.2.1