llvm/openmp/runtime/src/kmp_debug.h

/*
 * kmp_debug.h -- debug / assertion code for Assure library
 */

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef KMP_DEBUG_H
#define KMP_DEBUG_H

#include <stdarg.h>

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

// -----------------------------------------------------------------------------
// Build-time assertion.

// New C++11 style build assert
#define KMP_BUILD_ASSERT(expr)

// -----------------------------------------------------------------------------
// Run-time assertions.

extern void __kmp_dump_debug_buffer(void);

#ifdef KMP_USE_ASSERT
extern int __kmp_debug_assert(char const *expr, char const *file, int line);
#ifdef KMP_DEBUG
#define KMP_ASSERT
#define KMP_ASSERT2
#define KMP_DEBUG_ASSERT
#define KMP_DEBUG_ASSERT2
#define KMP_DEBUG_USE_VAR
#else
// Do not expose condition in release build. Use "assertion failure".
#define KMP_ASSERT(cond)
#define KMP_ASSERT2(cond, msg)
#define KMP_DEBUG_ASSERT(cond)
#define KMP_DEBUG_ASSERT2(cond, msg)
#define KMP_DEBUG_USE_VAR(x)
#endif // KMP_DEBUG
#else
#define KMP_ASSERT
#define KMP_ASSERT2
#define KMP_DEBUG_ASSERT
#define KMP_DEBUG_ASSERT2
#define KMP_DEBUG_USE_VAR
#endif // KMP_USE_ASSERT

#ifdef KMP_DEBUG
extern void __kmp_debug_printf_stdout(char const *format, ...);
#endif
extern void __kmp_debug_printf(char const *format, ...);

#ifdef KMP_DEBUG

extern int kmp_a_debug;
extern int kmp_b_debug;
extern int kmp_c_debug;
extern int kmp_d_debug;
extern int kmp_e_debug;
extern int kmp_f_debug;
extern int kmp_diag;

#define KA_TRACE
#define KB_TRACE
#define KC_TRACE
#define KD_TRACE
#define KE_TRACE
#define KF_TRACE
#define K_DIAG

#define KA_DUMP
#define KB_DUMP
#define KC_DUMP
#define KD_DUMP
#define KE_DUMP
#define KF_DUMP

#else

#define KA_TRACE(d, x)
#define KB_TRACE(d, x)
#define KC_TRACE(d, x)
#define KD_TRACE(d, x)
#define KE_TRACE(d, x)
#define KF_TRACE(d, x)
#define K_DIAG(d, x)

#define KA_DUMP(d, x)
#define KB_DUMP(d, x)
#define KC_DUMP(d, x)
#define KD_DUMP(d, x)
#define KE_DUMP(d, x)
#define KF_DUMP(d, x)

#endif // KMP_DEBUG

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus

#endif /* KMP_DEBUG_H */