4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
33 thr_get_storage(pthread_key_t
*keyp
, size_t size
, void (*destructor
)(void *))
37 if (pthread_key_create_once_np(keyp
, destructor
) != 0)
39 addr
= pthread_getspecific(*keyp
);
40 if (addr
== NULL
&& size
!= 0) {
41 addr
= calloc(1, size
);
42 if (addr
!= NULL
&& pthread_setspecific(*keyp
, addr
) != 0) {
52 * sig_mutex_lock() and sig_mutex_unlock() are the same
53 * as mutex_lock() and mutex_unlock() except that all
54 * signals are deferred while the lock is held. Likewise
55 * for sig_rw_rdlock(), sig_rw_wrlock() and sig_rw_unlock().
57 * _sigoff() and _sigon() are consolidation-private
58 * interfaces in libc that defer and enable signals.
59 * Calls to these can nest but must be balanced, so
60 * nested calls to these functions work properly.
64 sig_mutex_lock(mutex_t
*mp
)
67 (void) mutex_lock(mp
);
71 sig_mutex_unlock(mutex_t
*mp
)
73 (void) mutex_unlock(mp
);
78 sig_rw_rdlock(rwlock_t
*rwlp
)
81 (void) rw_rdlock(rwlp
);
85 sig_rw_wrlock(rwlock_t
*rwlp
)
88 (void) rw_wrlock(rwlp
);
92 sig_rw_unlock(rwlock_t
*rwlp
)
94 (void) rw_unlock(rwlp
);