summaryrefslogtreecommitdiff
path: root/src/thread/pthread_setspecific.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-03-03 18:30:44 -0500
committerRich Felker <dalias@aerifal.cx>2011-03-03 18:30:44 -0500
commitb480808a6a511c9350a6559b63938ac261c83a76 (patch)
treee5479cfec9500cc5cd2db4466d7bab2847d64735 /src/thread/pthread_setspecific.c
parenta53d2f3425aa32b5770b03acbab12d1df3af7226 (diff)
downloadmusl-b480808a6a511c9350a6559b63938ac261c83a76.tar.gz
optimize POSIX TSD for fast pthread_getspecific
Diffstat (limited to 'src/thread/pthread_setspecific.c')
-rw-r--r--src/thread/pthread_setspecific.c8
1 files changed, 1 insertions, 7 deletions
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;