xref: /openbsd/sys/sys/_lock.h (revision 8c00de5e)
1 /*	$OpenBSD: _lock.h,v 1.4 2019/04/23 13:35:12 visa Exp $	*/
2 
3 /*-
4  * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. Berkeley Software Design Inc's name may not be used to endorse or
15  *    promote products derived from this software without specific prior
16  *    written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  * $FreeBSD: head/sys/sys/_lock.h 179025 2008-05-15 20:10:06Z attilio $
31  */
32 
33 #ifndef _SYS__LOCK_H_
34 #define	_SYS__LOCK_H_
35 
36 #define	LO_CLASSFLAGS	0x0000ffff	/* Class specific flags. */
37 #define	LO_INITIALIZED	0x00010000	/* Lock has been initialized. */
38 #define	LO_WITNESS	0x00020000	/* Should witness monitor this lock. */
39 #define	LO_QUIET	0x00040000	/* Don't log locking operations. */
40 #define	LO_RECURSABLE	0x00080000	/* Lock may recurse. */
41 #define	LO_SLEEPABLE	0x00100000	/* Lock may be held while sleeping. */
42 #define	LO_UPGRADABLE	0x00200000	/* Lock may be upgraded/downgraded. */
43 #define	LO_DUPOK	0x00400000	/* Don't check for duplicate acquires */
44 #define	LO_IS_VNODE	0x00800000	/* Tell WITNESS about a VNODE lock */
45 #define	LO_CLASSMASK	0x0f000000	/* Class index bitmask. */
46 #define	LO_NOPROFILE	0x10000000	/* Don't profile this lock */
47 #define	LO_NEW		0x20000000	/* Don't check for double-init */
48 
49 #define	LO_CLASSSHIFT		24
50 
51 enum lock_class_index {
52 	LO_CLASS_KERNEL_LOCK,
53 	LO_CLASS_SCHED_LOCK,
54 	LO_CLASS_MUTEX,
55 	LO_CLASS_RWLOCK,
56 	LO_CLASS_RRWLOCK
57 };
58 
59 struct lock_object {
60 	const struct lock_type	*lo_type;
61 	const char		*lo_name;	/* Individual lock name. */
62 	struct witness		*lo_witness;	/* Data for witness. */
63 	unsigned int		 lo_flags;
64 };
65 
66 struct lock_type {
67 	const char		*lt_name;
68 };
69 
70 #endif /* !_SYS__LOCK_H_ */
71