Print this page
remove support for non-ANSI compilation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/debug.h
+++ new/usr/src/uts/common/sys/debug.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
23 + *
22 24 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 25 * Use is subject to license terms.
24 26 */
25 27
26 28 /*
27 29 * Copyright (c) 2012 by Delphix. All rights reserved.
28 30 */
29 31
30 32 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
31 33 /* All Rights Reserved */
32 34
33 35 #ifndef _SYS_DEBUG_H
34 36 #define _SYS_DEBUG_H
35 37
36 38 #include <sys/isa_defs.h>
37 39 #include <sys/types.h>
38 40 #include <sys/note.h>
39 41
40 42 #ifdef __cplusplus
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
41 43 extern "C" {
42 44 #endif
43 45
44 46 /*
45 47 * ASSERT(ex) causes a panic or debugger entry if expression ex is not
46 48 * true. ASSERT() is included only for debugging, and is a no-op in
47 49 * production kernels. VERIFY(ex), on the other hand, behaves like
48 50 * ASSERT and is evaluated on both debug and non-debug kernels.
49 51 */
50 52
51 -#if defined(__STDC__)
52 53 extern int assfail(const char *, const char *, int);
53 54 #define VERIFY(EX) ((void)((EX) || assfail(#EX, __FILE__, __LINE__)))
54 55 #if DEBUG
55 56 #define ASSERT(EX) ((void)((EX) || assfail(#EX, __FILE__, __LINE__)))
56 57 #else
57 58 #define ASSERT(x) ((void)0)
58 59 #endif
59 -#else /* defined(__STDC__) */
60 -extern int assfail();
61 -#define VERIFY(EX) ((void)((EX) || assfail("EX", __FILE__, __LINE__)))
62 -#if DEBUG
63 -#define ASSERT(EX) ((void)((EX) || assfail("EX", __FILE__, __LINE__)))
64 -#else
65 -#define ASSERT(x) ((void)0)
66 -#endif
67 -#endif /* defined(__STDC__) */
68 60
69 61 /*
70 62 * Assertion variants sensitive to the compilation data model
71 63 */
72 64 #if defined(_LP64)
73 65 #define ASSERT64(x) ASSERT(x)
74 66 #define ASSERT32(x)
75 67 #else
76 68 #define ASSERT64(x)
77 69 #define ASSERT32(x) ASSERT(x)
78 70 #endif
79 71
80 72 /*
81 73 * IMPLY and EQUIV are assertions of the form:
82 74 *
83 75 * if (a) then (b)
84 76 * and
85 77 * if (a) then (b) *AND* if (b) then (a)
86 78 */
87 79 #if DEBUG
88 80 #define IMPLY(A, B) \
89 81 ((void)(((!(A)) || (B)) || \
90 82 assfail("(" #A ") implies (" #B ")", __FILE__, __LINE__)))
91 83 #define EQUIV(A, B) \
92 84 ((void)((!!(A) == !!(B)) || \
93 85 assfail("(" #A ") is equivalent to (" #B ")", __FILE__, __LINE__)))
94 86 #else
95 87 #define IMPLY(A, B) ((void)0)
96 88 #define EQUIV(A, B) ((void)0)
97 89 #endif
98 90
99 91 /*
100 92 * ASSERT3() behaves like ASSERT() except that it is an explicit conditional,
101 93 * and prints out the values of the left and right hand expressions as part of
102 94 * the panic message to ease debugging. The three variants imply the type
103 95 * of their arguments. ASSERT3S() is for signed data types, ASSERT3U() is
104 96 * for unsigned, and ASSERT3P() is for pointers. The VERIFY3*() macros
105 97 * have the same relationship as above.
106 98 */
107 99 extern void assfail3(const char *, uintmax_t, const char *, uintmax_t,
108 100 const char *, int);
109 101 #define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE) do { \
110 102 const TYPE __left = (TYPE)(LEFT); \
111 103 const TYPE __right = (TYPE)(RIGHT); \
112 104 if (!(__left OP __right)) \
113 105 assfail3(#LEFT " " #OP " " #RIGHT, \
114 106 (uintmax_t)__left, #OP, (uintmax_t)__right, \
115 107 __FILE__, __LINE__); \
116 108 _NOTE(CONSTCOND) } while (0)
117 109
118 110 #define VERIFY3S(x, y, z) VERIFY3_IMPL(x, y, z, int64_t)
119 111 #define VERIFY3U(x, y, z) VERIFY3_IMPL(x, y, z, uint64_t)
120 112 #define VERIFY3P(x, y, z) VERIFY3_IMPL(x, y, z, uintptr_t)
121 113 #define VERIFY0(x) VERIFY3_IMPL(x, ==, 0, uintmax_t)
122 114
123 115 #if DEBUG
124 116 #define ASSERT3S(x, y, z) VERIFY3_IMPL(x, y, z, int64_t)
125 117 #define ASSERT3U(x, y, z) VERIFY3_IMPL(x, y, z, uint64_t)
126 118 #define ASSERT3P(x, y, z) VERIFY3_IMPL(x, y, z, uintptr_t)
127 119 #define ASSERT0(x) VERIFY3_IMPL(x, ==, 0, uintmax_t)
128 120 #else
129 121 #define ASSERT3S(x, y, z) ((void)0)
130 122 #define ASSERT3U(x, y, z) ((void)0)
131 123 #define ASSERT3P(x, y, z) ((void)0)
132 124 #define ASSERT0(x) ((void)0)
133 125 #endif
134 126
135 127 #ifdef _KERNEL
136 128
137 129 extern void abort_sequence_enter(char *);
138 130 extern void debug_enter(char *);
139 131
140 132 #endif /* _KERNEL */
141 133
142 134 #if defined(DEBUG) && !defined(__sun)
143 135 /* CSTYLED */
144 136 #define STATIC
145 137 #else
146 138 /* CSTYLED */
147 139 #define STATIC static
148 140 #endif
149 141
150 142 #ifdef __cplusplus
151 143 }
152 144 #endif
153 145
154 146 #endif /* _SYS_DEBUG_H */
↓ open down ↓ |
77 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX