diff options
Diffstat (limited to 'usr/src/lib/libnsl/common/common.c')
-rw-r--r-- | usr/src/lib/libnsl/common/common.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/usr/src/lib/libnsl/common/common.c b/usr/src/lib/libnsl/common/common.c index 5442fe1ad9..ea9779646b 100644 --- a/usr/src/lib/libnsl/common/common.c +++ b/usr/src/lib/libnsl/common/common.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -21,7 +20,7 @@ */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -33,26 +32,14 @@ void * thr_get_storage(pthread_key_t *keyp, size_t size, void (*destructor)(void *)) { - extern mutex_t tsd_lock; - pthread_key_t key; void *addr; - if ((key = *keyp) == 0) { - (void) mutex_lock(&tsd_lock); - if ((key = *keyp) == 0) { - if (pthread_key_create(keyp, destructor) != 0) { - (void) mutex_unlock(&tsd_lock); - return (NULL); - } - key = *keyp; - } - (void) mutex_unlock(&tsd_lock); - } - - addr = pthread_getspecific(key); + if (pthread_key_create_once_np(keyp, destructor) != 0) + return (NULL); + addr = pthread_getspecific(*keyp); if (addr == NULL && size != 0) { addr = calloc(1, size); - if (addr != NULL && pthread_setspecific(key, addr) != 0) { + if (addr != NULL && pthread_setspecific(*keyp, addr) != 0) { free(addr); return (NULL); } |