xref: /titanic_51/usr/src/uts/common/sys/t_lock.h (revision 1e49577a7fcde812700ded04431b49d67cc57d6d)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
37 
38 #ifndef	_ASM
39 #include <sys/machlock.h>
40 #include <sys/param.h>
41 #include <sys/mutex.h>
42 #include <sys/rwlock.h>
43 #include <sys/semaphore.h>
44 #include <sys/condvar.h>
45 #endif	/* _ASM */
46 
47 #ifdef	__cplusplus
48 extern "C" {
49 #endif
50 
51 #ifndef	_ASM
52 
53 /*
54  * Mutual exclusion locks described in common/sys/mutex.h.
55  *
56  * Semaphores described in common/sys/semaphore.h.
57  *
58  * Readers/Writer locks described in common/sys/rwlock.h.
59  *
60  * Condition variables described in common/sys/condvar.h
61  */
62 
63 #if defined(_KERNEL)
64 
65 extern int ncpus;
66 
67 /*
68  * Dispatcher lock type, macros and routines.
69  *
70  * disp_lock_t is defined in machlock.h
71  */
72 extern	void	disp_lock_enter(disp_lock_t *);
73 extern	void	disp_lock_exit(disp_lock_t *);
74 extern	void	disp_lock_exit_nopreempt(disp_lock_t *);
75 extern	void	disp_lock_enter_high(disp_lock_t *);
76 extern	void	disp_lock_exit_high(disp_lock_t *);
77 extern	void	disp_lock_init(disp_lock_t *lp, char *name);
78 extern	void	disp_lock_destroy(disp_lock_t *lp);
79 
80 #define	DISP_LOCK_INIT(lp)	LOCK_INIT_CLEAR((lock_t *)(lp))
81 #define	DISP_LOCK_HELD(lp)	LOCK_HELD((lock_t *)(lp))
82 #define	DISP_LOCK_DESTROY(lp)	ASSERT(!DISP_LOCK_HELD(lp))
83 
84 /*
85  * The following definitions are for assertions which can be checked
86  * statically by tools like lock_lint.  You can also define your own
87  * run-time test for each.  If you don't, we define them to 1 so that
88  * such assertions simply pass.
89  */
90 #ifndef NO_LOCKS_HELD
91 #define	NO_LOCKS_HELD	1
92 #endif
93 #ifndef NO_COMPETING_THREADS
94 #define	NO_COMPETING_THREADS	1
95 #endif
96 
97 #endif	/* defined(_KERNEL) */
98 
99 #endif	/* _ASM */
100 
101 #ifdef	__cplusplus
102 }
103 #endif
104 
105 #endif	/* _SYS_T_LOCK_H */
106