xref: /illumos-gate/usr/src/uts/common/sys/t_lock.h (revision fb3b6bbf2c922827ddf076fbf2172d96c58a71de)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1991-1998 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 /*
28  * t_lock.h:	Prototypes for disp_locks, plus include files
29  *		that describe the interfaces to kernel synch.
30  *		objects.
31  */
32 
33 #ifndef _SYS_T_LOCK_H
34 #define	_SYS_T_LOCK_H
35 
36 #ifndef	_ASM
37 #include <sys/machlock.h>
38 #include <sys/param.h>
39 #include <sys/mutex.h>
40 #include <sys/rwlock.h>
41 #include <sys/semaphore.h>
42 #include <sys/condvar.h>
43 #endif	/* _ASM */
44 
45 #ifdef	__cplusplus
46 extern "C" {
47 #endif
48 
49 #ifndef	_ASM
50 
51 /*
52  * Mutual exclusion locks described in common/sys/mutex.h.
53  *
54  * Semaphores described in common/sys/semaphore.h.
55  *
56  * Readers/Writer locks described in common/sys/rwlock.h.
57  *
58  * Condition variables described in common/sys/condvar.h
59  */
60 
61 #if defined(_KERNEL)
62 
63 extern int ncpus;
64 
65 /*
66  * Dispatcher lock type, macros and routines.
67  *
68  * disp_lock_t is defined in machlock.h
69  */
70 extern	void	disp_lock_enter(disp_lock_t *);
71 extern	void	disp_lock_exit(disp_lock_t *);
72 extern	void	disp_lock_exit_nopreempt(disp_lock_t *);
73 extern	void	disp_lock_enter_high(disp_lock_t *);
74 extern	void	disp_lock_exit_high(disp_lock_t *);
75 extern	void	disp_lock_init(disp_lock_t *lp, char *name);
76 extern	void	disp_lock_destroy(disp_lock_t *lp);
77 
78 #define	DISP_LOCK_INIT(lp)	LOCK_INIT_CLEAR((lock_t *)(lp))
79 #define	DISP_LOCK_HELD(lp)	LOCK_HELD((lock_t *)(lp))
80 #define	DISP_LOCK_DESTROY(lp)	ASSERT(!DISP_LOCK_HELD(lp))
81 
82 /*
83  * The following definitions are for assertions which can be checked
84  * statically by tools like lock_lint.  You can also define your own
85  * run-time test for each.  If you don't, we define them to 1 so that
86  * such assertions simply pass.
87  */
88 #ifndef NO_LOCKS_HELD
89 #define	NO_LOCKS_HELD	1
90 #endif
91 #ifndef NO_COMPETING_THREADS
92 #define	NO_COMPETING_THREADS	1
93 #endif
94 
95 #endif	/* defined(_KERNEL) */
96 
97 #endif	/* _ASM */
98 
99 #ifdef	__cplusplus
100 }
101 #endif
102 
103 #endif	/* _SYS_T_LOCK_H */
104