Merge from vendor branch GCC:
[dragonfly.git] / share / man / man9 / KASSERT.9
1 .\"
2 .\" Copyright (c) 2004 The DragonFly Project.  All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to The DragonFly Project
5 .\" by Hiten Pandya <hmp@backplane.com>.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\"
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in
15 .\"    the documentation and/or other materials provided with the
16 .\"    distribution.
17 .\" 3. Neither the name of The DragonFly Project nor the names of its
18 .\"    contributors may be used to endorse or promote products derived
19 .\"    from this software without specific, prior written permission.
20 .\"
21 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25 .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" SUCH DAMAGE.
33 .\"
34 .\" Copyright (c) 2000 Jonathan M. Bresler
35 .\"
36 .\" All rights reserved.
37 .\"
38 .\" This program is free software.
39 .\"
40 .\" Redistribution and use in source and binary forms, with or without
41 .\" modification, are permitted provided that the following conditions
42 .\" are met:
43 .\" 1. Redistributions of source code must retain the above copyright
44 .\"    notice, this list of conditions and the following disclaimer.
45 .\" 2. Redistributions in binary form must reproduce the above copyright
46 .\"    notice, this list of conditions and the following disclaimer in the
47 .\"    documentation and/or other materials provided with the distribution.
48 .\"
49 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
50 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
51 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
52 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
53 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
54 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
55 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
56 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
57 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
58 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59 .\"
60 .\" $FreeBSD: src/share/man/man9/KASSERT.9,v 1.1.2.4 2001/07/21 09:16:54 schweikh Exp $
61 .\" $DragonFly: src/share/man/man9/KASSERT.9,v 1.6 2005/08/01 01:49:17 swildner Exp $
62 .\"
63 .Dd May 10, 2004
64 .Os
65 .Dt KASSERT 9
66 .Sh NAME
67 .Nm KASSERT ,
68 .Nm KKASSERT
69 .Nd kernel expression verification macros
70 .Sh SYNOPSIS
71 .Cd options INVARIANTS
72 .Fn KASSERT expression "const char *msg"
73 .Fn KKASSERT expression
74 .Sh DESCRIPTION
75 The macros described in this manual page are no-op unless the kernel
76 is compiled with
77 .Cd "options INVARIANTS" .
78 .Pp
79 The
80 .Fn KASSERT
81 macro tests the given
82 .Ar expression
83 and if it is false,
84 the
85 .Xr panic 9
86 function is called to display
87 .Fa msg
88 and terminate the running system.
89 .Pp
90 The
91 .Fn KKASSERT
92 macro is similar to
93 .Fn KASSERT ,
94 except it does not require a description message but instead
95 displays
96 .Fa expression
97 and terminates the running system.
98 .Sh EXAMPLES
99 The kernel function
100 .Fn vput
101 must not be called with a NULL pointer.
102 .Bd -literal -offset indent
103 void
104 vput(struct vnode *vp)
105 {
106         struct thread *td = curthread;
107
108         KASSERT(vp != NULL, ("vput: null vp"));
109         ...
110 }
111 .Ed
112 .Sh SEE ALSO
113 .Xr config 8 ,
114 .Xr panic 9 ,
115 .Sh AUTHORS
116 .An -nosplit
117 This manual page was written by
118 .An Jonathan M. Bresler
119 .Aq jmb@FreeBSD.org
120 and modified for
121 .Dx
122 by
123 .An Hiten Pandya Aq hmp@dragonflybsd.org .