xref: /titanic_51/usr/src/lib/libnsl/include/mt.h (revision bbaa8b60dd95d714741fc474adad3cf710ef4efd)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_LIBNSL_INCLUDE_MT_H
28 #define	_LIBNSL_INCLUDE_MT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Threading and mutual exclusion declarations of primitives used for
34  *	MT operation of libnsl code.
35  *
36  * Note: These primitives are designed to achieve the effect of avoiding a
37  *	 deadlock possibility by an interface operation being called from
38  *	 a signal handler while holding a lock.
39  * Note: the sig_*() functions use the _sigoff() and _sigon() consolidation
40  *       private interfaces provided by libc to defer all asynchronously
41  *       generated signals for the duration of holding the lock.  Unlike
42  *	 blocking all signals with sigprocmask() or thr_sigsetmask(),
43  *	 _sigoff() allows signals with default dispositions to exercise
44  *	 their default actions (killing the process, stopping the process).
45  */
46 
47 #include <thread.h>
48 #include <pthread.h>
49 #include <signal.h>
50 #include <synch.h>
51 
52 #ifdef	__cplusplus
53 extern "C" {
54 #endif
55 
56 extern sigset_t fillset;	/* for actually blocking all signals */
57 
58 extern void sig_mutex_lock(mutex_t *);
59 extern void sig_mutex_unlock(mutex_t *);
60 extern void sig_rw_rdlock(rwlock_t *);
61 extern void sig_rw_wrlock(rwlock_t *);
62 extern void sig_rw_unlock(rwlock_t *);
63 
64 extern void _sigoff(void);
65 extern void _sigon(void);
66 
67 extern void *thr_get_storage(pthread_key_t *, size_t, void(*)(void *));
68 
69 #ifdef	__cplusplus
70 }
71 #endif
72 
73 #endif	/* _LIBNSL_INCLUDE_MT_H */
74