2 * kmp_debug.h -- debug / assertion code for Assure library
5 //===----------------------------------------------------------------------===//
7 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
8 // See https://llvm.org/LICENSE.txt for license information.
9 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11 //===----------------------------------------------------------------------===//
22 // -----------------------------------------------------------------------------
23 // Build-time assertion.
25 // New C++11 style build assert
26 #define KMP_BUILD_ASSERT(expr) static_assert(expr, "Build condition error")
28 // -----------------------------------------------------------------------------
29 // Run-time assertions.
31 extern void __kmp_dump_debug_buffer(void);
34 extern int __kmp_debug_assert(char const *expr
, char const *file
, int line
);
36 #define KMP_ASSERT(cond) \
38 __kmp_debug_assert(#cond, __FILE__, __LINE__); \
40 #define KMP_ASSERT2(cond, msg) \
42 __kmp_debug_assert((msg), __FILE__, __LINE__); \
44 #define KMP_DEBUG_ASSERT(cond) KMP_ASSERT(cond)
45 #define KMP_DEBUG_ASSERT2(cond, msg) KMP_ASSERT2(cond, msg)
46 #define KMP_DEBUG_USE_VAR(x) /* Nothing (it is used!) */
48 // Do not expose condition in release build. Use "assertion failure".
49 #define KMP_ASSERT(cond) \
51 __kmp_debug_assert("assertion failure", __FILE__, __LINE__); \
53 #define KMP_ASSERT2(cond, msg) KMP_ASSERT(cond)
54 #define KMP_DEBUG_ASSERT(cond) /* Nothing */
55 #define KMP_DEBUG_ASSERT2(cond, msg) /* Nothing */
56 #define KMP_DEBUG_USE_VAR(x) ((void)(x))
59 #define KMP_ASSERT(cond) /* Nothing */
60 #define KMP_ASSERT2(cond, msg) /* Nothing */
61 #define KMP_DEBUG_ASSERT(cond) /* Nothing */
62 #define KMP_DEBUG_ASSERT2(cond, msg) /* Nothing */
63 #define KMP_DEBUG_USE_VAR(x) ((void)(x))
64 #endif // KMP_USE_ASSERT
67 extern void __kmp_debug_printf_stdout(char const *format
, ...);
69 extern void __kmp_debug_printf(char const *format
, ...);
73 extern int kmp_a_debug
;
74 extern int kmp_b_debug
;
75 extern int kmp_c_debug
;
76 extern int kmp_d_debug
;
77 extern int kmp_e_debug
;
78 extern int kmp_f_debug
;
81 #define KA_TRACE(d, x) \
82 if (kmp_a_debug >= d) { \
83 __kmp_debug_printf x; \
85 #define KB_TRACE(d, x) \
86 if (kmp_b_debug >= d) { \
87 __kmp_debug_printf x; \
89 #define KC_TRACE(d, x) \
90 if (kmp_c_debug >= d) { \
91 __kmp_debug_printf x; \
93 #define KD_TRACE(d, x) \
94 if (kmp_d_debug >= d) { \
95 __kmp_debug_printf x; \
97 #define KE_TRACE(d, x) \
98 if (kmp_e_debug >= d) { \
99 __kmp_debug_printf x; \
101 #define KF_TRACE(d, x) \
102 if (kmp_f_debug >= d) { \
103 __kmp_debug_printf x; \
105 #define K_DIAG(d, x) \
107 if (kmp_diag == d) { \
108 __kmp_debug_printf_stdout x; \
112 #define KA_DUMP(d, x) \
113 if (kmp_a_debug >= d) { \
115 __kmp_disable(&ks); \
119 #define KB_DUMP(d, x) \
120 if (kmp_b_debug >= d) { \
122 __kmp_disable(&ks); \
126 #define KC_DUMP(d, x) \
127 if (kmp_c_debug >= d) { \
129 __kmp_disable(&ks); \
133 #define KD_DUMP(d, x) \
134 if (kmp_d_debug >= d) { \
136 __kmp_disable(&ks); \
140 #define KE_DUMP(d, x) \
141 if (kmp_e_debug >= d) { \
143 __kmp_disable(&ks); \
147 #define KF_DUMP(d, x) \
148 if (kmp_f_debug >= d) { \
150 __kmp_disable(&ks); \
157 #define KA_TRACE(d, x) /* nothing to do */
158 #define KB_TRACE(d, x) /* nothing to do */
159 #define KC_TRACE(d, x) /* nothing to do */
160 #define KD_TRACE(d, x) /* nothing to do */
161 #define KE_TRACE(d, x) /* nothing to do */
162 #define KF_TRACE(d, x) /* nothing to do */
163 #define K_DIAG(d, x) \
164 {} /* nothing to do */
166 #define KA_DUMP(d, x) /* nothing to do */
167 #define KB_DUMP(d, x) /* nothing to do */
168 #define KC_DUMP(d, x) /* nothing to do */
169 #define KD_DUMP(d, x) /* nothing to do */
170 #define KE_DUMP(d, x) /* nothing to do */
171 #define KF_DUMP(d, x) /* nothing to do */
177 #endif // __cplusplus
179 #endif /* KMP_DEBUG_H */