[clang] Handle __declspec() attributes in using
[llvm-project.git] / compiler-rt / lib / orc / debug.h
blob4605d441c7cbb4301029ba41ee450a096b948f36
1 //===- debug.h - Debugging output utilities ---------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file is a part of the ORC runtime support library.
11 //===----------------------------------------------------------------------===//
13 #ifndef ORC_RT_DEBUG_H
14 #define ORC_RT_DEBUG_H
16 #include <atomic>
18 #ifndef NDEBUG
20 namespace __orc_rt {
22 extern std::atomic<const char *> DebugTypes;
23 extern char DebugTypesAll;
24 extern char DebugTypesNone;
26 const char *initializeDebug();
27 bool debugTypeEnabled(const char *Type, const char *Types);
28 void printdbg(const char *format, ...);
30 } // namespace __orc_rt
32 #define ORC_RT_DEBUG_WITH_TYPE(TYPE, X) \
33 do { \
34 const char *Types = \
35 ::__orc_rt::DebugTypes.load(std::memory_order_relaxed); \
36 if (!Types) \
37 Types = initializeDebug(); \
38 if (Types == &DebugTypesNone) \
39 break; \
40 if (Types == &DebugTypesAll || \
41 ::__orc_rt::debugTypeEnabled(TYPE, Types)) { \
42 X; \
43 } \
44 } while (false)
46 #else
48 #define ORC_RT_DEBUG_WITH_TYPE(TYPE, X) \
49 do { \
50 } while (false)
52 #endif // !NDEBUG
54 #define ORC_RT_DEBUG(X) ORC_RT_DEBUG_WITH_TYPE(DEBUG_TYPE, X)
56 #endif // ORC_RT_COMMON_H