Path: blob/main/contrib/llvm-project/openmp/runtime/src/kmp_debug.h
35258 views
/*1* kmp_debug.h -- debug / assertion code for Assure library2*/34//===----------------------------------------------------------------------===//5//6// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.7// See https://llvm.org/LICENSE.txt for license information.8// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception9//10//===----------------------------------------------------------------------===//1112#ifndef KMP_DEBUG_H13#define KMP_DEBUG_H1415#include <stdarg.h>1617#ifdef __cplusplus18extern "C" {19#endif // __cplusplus2021// -----------------------------------------------------------------------------22// Build-time assertion.2324// New C++11 style build assert25#define KMP_BUILD_ASSERT(expr) static_assert(expr, "Build condition error")2627// -----------------------------------------------------------------------------28// Run-time assertions.2930extern void __kmp_dump_debug_buffer(void);3132#ifdef KMP_USE_ASSERT33extern int __kmp_debug_assert(char const *expr, char const *file, int line);34#ifdef KMP_DEBUG35#define KMP_ASSERT(cond) \36if (!(cond)) { \37__kmp_debug_assert(#cond, __FILE__, __LINE__); \38}39#define KMP_ASSERT2(cond, msg) \40if (!(cond)) { \41__kmp_debug_assert((msg), __FILE__, __LINE__); \42}43#define KMP_DEBUG_ASSERT(cond) KMP_ASSERT(cond)44#define KMP_DEBUG_ASSERT2(cond, msg) KMP_ASSERT2(cond, msg)45#define KMP_DEBUG_USE_VAR(x) /* Nothing (it is used!) */46#else47// Do not expose condition in release build. Use "assertion failure".48#define KMP_ASSERT(cond) \49if (!(cond)) { \50__kmp_debug_assert("assertion failure", __FILE__, __LINE__); \51}52#define KMP_ASSERT2(cond, msg) KMP_ASSERT(cond)53#define KMP_DEBUG_ASSERT(cond) /* Nothing */54#define KMP_DEBUG_ASSERT2(cond, msg) /* Nothing */55#define KMP_DEBUG_USE_VAR(x) ((void)(x))56#endif // KMP_DEBUG57#else58#define KMP_ASSERT(cond) /* Nothing */59#define KMP_ASSERT2(cond, msg) /* Nothing */60#define KMP_DEBUG_ASSERT(cond) /* Nothing */61#define KMP_DEBUG_ASSERT2(cond, msg) /* Nothing */62#define KMP_DEBUG_USE_VAR(x) ((void)(x))63#endif // KMP_USE_ASSERT6465#ifdef KMP_DEBUG66extern void __kmp_debug_printf_stdout(char const *format, ...);67#endif68extern void __kmp_debug_printf(char const *format, ...);6970#ifdef KMP_DEBUG7172extern int kmp_a_debug;73extern int kmp_b_debug;74extern int kmp_c_debug;75extern int kmp_d_debug;76extern int kmp_e_debug;77extern int kmp_f_debug;78extern int kmp_diag;7980#define KA_TRACE(d, x) \81if (kmp_a_debug >= d) { \82__kmp_debug_printf x; \83}84#define KB_TRACE(d, x) \85if (kmp_b_debug >= d) { \86__kmp_debug_printf x; \87}88#define KC_TRACE(d, x) \89if (kmp_c_debug >= d) { \90__kmp_debug_printf x; \91}92#define KD_TRACE(d, x) \93if (kmp_d_debug >= d) { \94__kmp_debug_printf x; \95}96#define KE_TRACE(d, x) \97if (kmp_e_debug >= d) { \98__kmp_debug_printf x; \99}100#define KF_TRACE(d, x) \101if (kmp_f_debug >= d) { \102__kmp_debug_printf x; \103}104#define K_DIAG(d, x) \105{ \106if (kmp_diag == d) { \107__kmp_debug_printf_stdout x; \108} \109}110111#define KA_DUMP(d, x) \112if (kmp_a_debug >= d) { \113int ks; \114__kmp_disable(&ks); \115(x); \116__kmp_enable(ks); \117}118#define KB_DUMP(d, x) \119if (kmp_b_debug >= d) { \120int ks; \121__kmp_disable(&ks); \122(x); \123__kmp_enable(ks); \124}125#define KC_DUMP(d, x) \126if (kmp_c_debug >= d) { \127int ks; \128__kmp_disable(&ks); \129(x); \130__kmp_enable(ks); \131}132#define KD_DUMP(d, x) \133if (kmp_d_debug >= d) { \134int ks; \135__kmp_disable(&ks); \136(x); \137__kmp_enable(ks); \138}139#define KE_DUMP(d, x) \140if (kmp_e_debug >= d) { \141int ks; \142__kmp_disable(&ks); \143(x); \144__kmp_enable(ks); \145}146#define KF_DUMP(d, x) \147if (kmp_f_debug >= d) { \148int ks; \149__kmp_disable(&ks); \150(x); \151__kmp_enable(ks); \152}153154#else155156#define KA_TRACE(d, x) /* nothing to do */157#define KB_TRACE(d, x) /* nothing to do */158#define KC_TRACE(d, x) /* nothing to do */159#define KD_TRACE(d, x) /* nothing to do */160#define KE_TRACE(d, x) /* nothing to do */161#define KF_TRACE(d, x) /* nothing to do */162#define K_DIAG(d, x) \163{} /* nothing to do */164165#define KA_DUMP(d, x) /* nothing to do */166#define KB_DUMP(d, x) /* nothing to do */167#define KC_DUMP(d, x) /* nothing to do */168#define KD_DUMP(d, x) /* nothing to do */169#define KE_DUMP(d, x) /* nothing to do */170#define KF_DUMP(d, x) /* nothing to do */171172#endif // KMP_DEBUG173174#ifdef __cplusplus175} // extern "C"176#endif // __cplusplus177178#endif /* KMP_DEBUG_H */179180181