import less(1)
[unleashed/tickless.git] / usr / src / lib / libc / port / nsl / mt.h
blobd72a4ec5cff45175605d1a0d09e172ce1464b85a
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _LIBNSL_INCLUDE_MT_H
28 #define _LIBNSL_INCLUDE_MT_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 * Threading and mutual exclusion declarations of primitives used for
34 * MT operation of libnsl code.
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).
47 #include <thread.h>
48 #include <pthread.h>
49 #include <signal.h>
50 #include <synch.h>
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
56 extern sigset_t fillset; /* for actually blocking all signals */
59 * sig_mutex_lock() and sig_mutex_unlock() are the same
60 * as mutex_lock() and mutex_unlock() except that all
61 * signals are deferred while the lock is held. Likewise
62 * for sig_rw_rdlock(), sig_rw_wrlock() and sig_rw_unlock().
64 * _sigoff() and _sigon() are consolidation-private
65 * interfaces in libc that defer and enable signals.
66 * Calls to these can nest but must be balanced, so
67 * nested calls to these functions work properly.
70 /* provided by libc in mtlib.h, but avoiding that include in nsl for now */
71 extern void sig_mutex_lock(mutex_t *);
72 extern void sig_mutex_unlock(mutex_t *);
74 extern void _sigoff(void);
75 extern void _sigon(void);
77 #define sig_rw_rdlock(rwlp) do { _sigoff(); (void) rw_rdlock(rwlp); } while(0)
78 #define sig_rw_wrlock(rwlp) do { _sigoff(); (void) rw_wrlock(rwlp); } while(0)
79 #define sig_rw_unlock(rwlp) do { (void) rw_unlock(rwlp); _sigon(); } while(0)
81 extern void *thr_get_storage(pthread_key_t *, size_t, void(*)(void *));
83 #ifdef __cplusplus
85 #endif
87 #endif /* _LIBNSL_INCLUDE_MT_H */