4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
33 #include <sys/types.h>
40 * ASSERT(ex) causes a panic or debugger entry if expression ex is not
41 * true. ASSERT() is included only for debugging, and is a no-op in
42 * production kernels. VERIFY(ex), on the other hand, behaves like
43 * ASSERT and is evaluated on both debug and non-debug kernels.
47 extern int assfail(const char *, const char *, int);
48 #define VERIFY(EX) ((void)((EX) || assfail(#EX, __FILE__, __LINE__)))
50 #define ASSERT(EX) ((void)((EX) || assfail(#EX, __FILE__, __LINE__)))
52 #define ASSERT(x) ((void)0)
54 #else /* defined(__STDC__) */
56 #define VERIFY(EX) ((void)((EX) || assfail("EX", __FILE__, __LINE__)))
58 #define ASSERT(EX) ((void)((EX) || assfail("EX", __FILE__, __LINE__)))
60 #define ASSERT(x) ((void)0)
62 #endif /* defined(__STDC__) */
65 * Assertion variants sensitive to the compilation data model
68 #define ASSERT64(x) ASSERT(x)
72 #define ASSERT32(x) ASSERT(x)
76 * ASSERT3() behaves like ASSERT() except that it is an explicit conditional,
77 * and prints out the values of the left and right hand expressions as part of
78 * the panic message to ease debugging. The three variants imply the type
79 * of their arguments. ASSERT3S() is for signed data types, ASSERT3U() is
80 * for unsigned, and ASSERT3P() is for pointers. The VERIFY3*() macros
81 * have the same relationship as above.
83 extern void assfail3(const char *, uintmax_t, const char *, uintmax_t,
85 #define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE) do { \
86 const TYPE __left = (TYPE)(LEFT); \
87 const TYPE __right = (TYPE)(RIGHT); \
88 if (!(__left OP __right)) \
89 assfail3(#LEFT " " #OP " " #RIGHT, \
90 (uintmax_t)__left, #OP, (uintmax_t)__right, \
91 __FILE__, __LINE__); \
92 _NOTE(CONSTCOND) } while (0)
94 #define VERIFY3S(x, y, z) VERIFY3_IMPL(x, y, z, int64_t)
95 #define VERIFY3U(x, y, z) VERIFY3_IMPL(x, y, z, uint64_t)
96 #define VERIFY3P(x, y, z) VERIFY3_IMPL(x, y, z, uintptr_t)
98 #define ASSERT3S(x, y, z) VERIFY3_IMPL(x, y, z, int64_t)
99 #define ASSERT3U(x, y, z) VERIFY3_IMPL(x, y, z, uint64_t)
100 #define ASSERT3P(x, y, z) VERIFY3_IMPL(x, y, z, uintptr_t)
102 #define ASSERT3S(x, y, z) ((void)0)
103 #define ASSERT3U(x, y, z) ((void)0)
104 #define ASSERT3P(x, y, z) ((void)0)
109 extern void abort_sequence_enter(char *);
110 extern void debug_enter(char *);
114 #if defined(DEBUG) && !defined(__sun)
119 #define STATIC static
126 #endif /* _SYS_DEBUG_H */