LLVM OpenMP* Runtime Library
src
kmp_debug.h
1
/*
2
* kmp_debug.h -- debug / assertion code for Assure library
3
*/
4
5
//===----------------------------------------------------------------------===//
6
//
7
// The LLVM Compiler Infrastructure
8
//
9
// This file is dual licensed under the MIT and the University of Illinois Open
10
// Source Licenses. See LICENSE.txt for details.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef KMP_DEBUG_H
15
#define KMP_DEBUG_H
16
17
#include <stdarg.h>
18
19
#ifdef __cplusplus
20
extern
"C"
{
21
#endif // __cplusplus
22
23
// -----------------------------------------------------------------------------
24
// Build-time assertion.
25
26
// New C++11 style build assert
27
#define KMP_BUILD_ASSERT(expr) static_assert(expr, "Build condition error")
28
29
// -----------------------------------------------------------------------------
30
// Run-time assertions.
31
32
extern
void
__kmp_dump_debug_buffer(
void
);
33
34
#ifdef KMP_USE_ASSERT
35
extern
int
__kmp_debug_assert(
char
const
*expr,
char
const
*file,
int
line);
36
#ifdef KMP_DEBUG
37
#define KMP_ASSERT(cond) \
38
((cond) ? 0 : __kmp_debug_assert(#cond, __FILE__, __LINE__))
39
#define KMP_ASSERT2(cond, msg) \
40
((cond) ? 0 : __kmp_debug_assert((msg), __FILE__, __LINE__))
41
#define KMP_DEBUG_ASSERT(cond) KMP_ASSERT(cond)
42
#define KMP_DEBUG_ASSERT2(cond, msg) KMP_ASSERT2(cond, msg)
43
#else
44
// Do not expose condition in release build. Use "assertion failure".
45
#define KMP_ASSERT(cond) \
46
((cond) ? 0 : __kmp_debug_assert("assertion failure", __FILE__, __LINE__))
47
#define KMP_ASSERT2(cond, msg) KMP_ASSERT(cond)
48
#define KMP_DEBUG_ASSERT(cond) 0
49
#define KMP_DEBUG_ASSERT2(cond, msg) 0
50
#endif // KMP_DEBUG
51
#else
52
#define KMP_ASSERT(cond) 0
53
#define KMP_ASSERT2(cond, msg) 0
54
#define KMP_DEBUG_ASSERT(cond) 0
55
#define KMP_DEBUG_ASSERT2(cond, msg) 0
56
#endif // KMP_USE_ASSERT
57
58
#ifdef KMP_DEBUG
59
extern
void
__kmp_debug_printf_stdout(
char
const
*format, ...);
60
#endif
61
extern
void
__kmp_debug_printf(
char
const
*format, ...);
62
63
#ifdef KMP_DEBUG
64
65
extern
int
kmp_a_debug;
66
extern
int
kmp_b_debug;
67
extern
int
kmp_c_debug;
68
extern
int
kmp_d_debug;
69
extern
int
kmp_e_debug;
70
extern
int
kmp_f_debug;
71
extern
int
kmp_diag;
72
73
#define KA_TRACE(d, x) \
74
if (kmp_a_debug >= d) { \
75
__kmp_debug_printf x; \
76
}
77
#define KB_TRACE(d, x) \
78
if (kmp_b_debug >= d) { \
79
__kmp_debug_printf x; \
80
}
81
#define KC_TRACE(d, x) \
82
if (kmp_c_debug >= d) { \
83
__kmp_debug_printf x; \
84
}
85
#define KD_TRACE(d, x) \
86
if (kmp_d_debug >= d) { \
87
__kmp_debug_printf x; \
88
}
89
#define KE_TRACE(d, x) \
90
if (kmp_e_debug >= d) { \
91
__kmp_debug_printf x; \
92
}
93
#define KF_TRACE(d, x) \
94
if (kmp_f_debug >= d) { \
95
__kmp_debug_printf x; \
96
}
97
#define K_DIAG(d, x) \
98
{ \
99
if (kmp_diag == d) { \
100
__kmp_debug_printf_stdout x; \
101
} \
102
}
103
104
#define KA_DUMP(d, x) \
105
if (kmp_a_debug >= d) { \
106
int ks; \
107
__kmp_disable(&ks); \
108
(x); \
109
__kmp_enable(ks); \
110
}
111
#define KB_DUMP(d, x) \
112
if (kmp_b_debug >= d) { \
113
int ks; \
114
__kmp_disable(&ks); \
115
(x); \
116
__kmp_enable(ks); \
117
}
118
#define KC_DUMP(d, x) \
119
if (kmp_c_debug >= d) { \
120
int ks; \
121
__kmp_disable(&ks); \
122
(x); \
123
__kmp_enable(ks); \
124
}
125
#define KD_DUMP(d, x) \
126
if (kmp_d_debug >= d) { \
127
int ks; \
128
__kmp_disable(&ks); \
129
(x); \
130
__kmp_enable(ks); \
131
}
132
#define KE_DUMP(d, x) \
133
if (kmp_e_debug >= d) { \
134
int ks; \
135
__kmp_disable(&ks); \
136
(x); \
137
__kmp_enable(ks); \
138
}
139
#define KF_DUMP(d, x) \
140
if (kmp_f_debug >= d) { \
141
int ks; \
142
__kmp_disable(&ks); \
143
(x); \
144
__kmp_enable(ks); \
145
}
146
147
#else
148
149
#define KA_TRACE(d, x)
/* nothing to do */
150
#define KB_TRACE(d, x)
/* nothing to do */
151
#define KC_TRACE(d, x)
/* nothing to do */
152
#define KD_TRACE(d, x)
/* nothing to do */
153
#define KE_TRACE(d, x)
/* nothing to do */
154
#define KF_TRACE(d, x)
/* nothing to do */
155
#define K_DIAG(d, x) \
156
{}
/* nothing to do */
157
158
#define KA_DUMP(d, x)
/* nothing to do */
159
#define KB_DUMP(d, x)
/* nothing to do */
160
#define KC_DUMP(d, x)
/* nothing to do */
161
#define KD_DUMP(d, x)
/* nothing to do */
162
#define KE_DUMP(d, x)
/* nothing to do */
163
#define KF_DUMP(d, x)
/* nothing to do */
164
165
#endif // KMP_DEBUG
166
167
#ifdef __cplusplus
168
}
// extern "C"
169
#endif // __cplusplus
170
171
#endif
/* KMP_DEBUG_H */
Generated by
1.8.13