1/* $OpenBSD: _lock.h,v 1.7 2025/04/14 12:53:54 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_RECURSABLE 0x00080000 /* Lock may recurse. */
40#define LO_SLEEPABLE 0x00100000 /* Lock may be held while sleeping. */
41#define LO_UPGRADABLE 0x00200000 /* Lock may be upgraded/downgraded. */
42#define LO_DUPOK 0x00400000 /* Don't check for duplicate acquires */
43#define LO_IS_VNODE 0x00800000 /* Tell WITNESS about a VNODE lock */
44#define LO_CLASSMASK 0x0f000000 /* Class index bitmask. */
45#define LO_HASPARENT 0x40000000 /* If set, non-NULL lo_relative
46 * points to parent lock.
47 * If clear, non-NULL lo_relative
48 * points to child lock. */
49
50#define LO_CLASSSHIFT 24
51
52enum lock_class_index {
53 LO_CLASS_KERNEL_LOCK,
54 LO_CLASS_MUTEX,
55 LO_CLASS_RWLOCK,
56 LO_CLASS_RRWLOCK
57};
58
59struct 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 struct lock_object *lo_relative; /* Parent or child lock. */
64 unsigned int lo_flags;
65};
66
67struct lock_type {
68 const char *lt_name;
69};
70
71#endif /* !_SYS__LOCK_H_ */