FreeBSD/Linux Kernel Cross Reference
sys/sys/lockdebug.h
1 /* $NetBSD: lockdebug.h,v 1.10 2008/05/31 13:15:21 ad Exp $ */
2
3 /*-
4 * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef __SYS_LOCKDEBUG_H__
33 #define __SYS_LOCKDEBUG_H__
34
35 #ifdef _KERNEL_OPT
36 #include "opt_lockdebug.h"
37 #endif
38
39 #ifndef _KERNEL
40 #error "Sorry, nothing of interest to user level programs here."
41 #endif
42
43 #define LOCKOPS_SLEEP 0
44 #define LOCKOPS_SPIN 1
45 #define LOCKOPS_CV 2
46
47 typedef struct lockops {
48 const char *lo_name;
49 int lo_type;
50 void (*lo_dump)(volatile void *);
51 } lockops_t;
52
53 #define LOCKDEBUG_ABORT(l, o, f, m) lockdebug_abort(l, o, f, m)
54
55 void lockdebug_abort(volatile void *, lockops_t *,
56 const char *, const char *);
57
58 void lockdebug_lock_print(void *, void (*)(const char *, ...));
59
60 #ifdef LOCKDEBUG
61
62 bool lockdebug_alloc(volatile void *, lockops_t *, uintptr_t);
63 void lockdebug_free(volatile void *);
64 void lockdebug_wantlock(volatile void *, uintptr_t, bool, bool);
65 void lockdebug_locked(volatile void *, void *, uintptr_t, int);
66 void lockdebug_unlocked(volatile void *, uintptr_t, int);
67 void lockdebug_barrier(volatile void *, int);
68 void lockdebug_mem_check(const char *, void *, size_t);
69 void lockdebug_wakeup(volatile void *, uintptr_t);
70
71 #define LOCKDEBUG_ALLOC(lock, ops, addr) lockdebug_alloc(lock, ops, addr)
72 #define LOCKDEBUG_FREE(dodebug, lock) \
73 if (dodebug) lockdebug_free(lock)
74 #define LOCKDEBUG_WANTLOCK(dodebug, lock, where, s, t) \
75 if (dodebug) lockdebug_wantlock(lock, where, s, t)
76 #define LOCKDEBUG_LOCKED(dodebug, lock, al, where, s) \
77 if (dodebug) lockdebug_locked(lock, al, where, s)
78 #define LOCKDEBUG_UNLOCKED(dodebug, lock, where, s) \
79 if (dodebug) lockdebug_unlocked(lock, where, s)
80 #define LOCKDEBUG_BARRIER(lock, slp) lockdebug_barrier(lock, slp)
81 #define LOCKDEBUG_MEM_CHECK(base, sz) \
82 lockdebug_mem_check(__func__, base, sz)
83 #define LOCKDEBUG_WAKEUP(dodebug, lock, where) \
84 if (dodebug) lockdebug_wakeup(lock, where)
85
86 #else /* LOCKDEBUG */
87
88 #define LOCKDEBUG_ALLOC(lock, ops, addr) false
89 #define LOCKDEBUG_FREE(dodebug, lock) /* nothing */
90 #define LOCKDEBUG_WANTLOCK(dodebug, lock, where, s, t) /* nothing */
91 #define LOCKDEBUG_LOCKED(dodebug, lock, al, where, s) /* nothing */
92 #define LOCKDEBUG_UNLOCKED(dodebug, lock, where, s) /* nothing */
93 #define LOCKDEBUG_BARRIER(lock, slp) /* nothing */
94 #define LOCKDEBUG_MEM_CHECK(base, sz) /* nothing */
95 #define LOCKDEBUG_WAKEUP(dodebug, lock, where) /* nothing */
96
97 #endif /* LOCKDEBUG */
98
99 #endif /* __SYS_LOCKDEBUG_H__ */
Cache object: 99a597f03a7e117b7333b44ef0ec0ecc
|