Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 24e592c

Browse files
committed
config: clean up some of the macro definition
Unify the definition of `_LIBUNWIND_LOG_NON_ZERO` to make it clear what it is defined to and make the definition unconditional. Reorder the debug and tracing macros to be defined in the same order. NFC. git-svn-id: https://llvm.org/svn/llvm-project/libunwind/trunk@292720 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent fa05468 commit 24e592c

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

src/config.h

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,32 @@
8585
fflush(stderr); \
8686
abort(); \
8787
} while (0)
88-
#define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
88+
89+
#define _LIBUNWIND_LOG(msg, ...) \
90+
fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
8991

9092
#if defined(_LIBUNWIND_HAS_NO_THREADS)
9193
// only used with pthread calls, not needed for the single-threaded builds
9294
#define _LIBUNWIND_LOG_NON_ZERO(x)
95+
#else
96+
#if defined(NDEBUG)
97+
#define _LIBUNWIND_LOG_NON_ZERO(x) x
98+
#else
99+
#define _LIBUNWIND_LOG_NON_ZERO(x) \
100+
do { \
101+
int _err = x; \
102+
if (_err != 0) \
103+
_LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__); \
104+
} while (0)
105+
#endif
93106
#endif
94107

95108
// Macros that define away in non-Debug builds
96109
#ifdef NDEBUG
97110
#define _LIBUNWIND_DEBUG_LOG(msg, ...)
98111
#define _LIBUNWIND_TRACE_API(msg, ...)
99-
#define _LIBUNWIND_TRACING_UNWINDING 0
112+
#define _LIBUNWIND_TRACING_UNWINDING (0)
100113
#define _LIBUNWIND_TRACE_UNWINDING(msg, ...)
101-
#ifndef _LIBUNWIND_LOG_NON_ZERO
102-
#define _LIBUNWIND_LOG_NON_ZERO(x) x
103-
#endif
104114
#else
105115
#ifdef __cplusplus
106116
extern "C" {
@@ -111,23 +121,17 @@
111121
}
112122
#endif
113123
#define _LIBUNWIND_DEBUG_LOG(msg, ...) _LIBUNWIND_LOG(msg, __VA_ARGS__)
114-
#ifndef _LIBUNWIND_LOG_NON_ZERO
115-
#define _LIBUNWIND_LOG_NON_ZERO(x) \
116-
do { \
117-
int _err = x; \
118-
if ( _err != 0 ) \
119-
_LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__); \
120-
} while (0)
121-
#endif
122-
#define _LIBUNWIND_TRACE_API(msg, ...) \
123-
do { \
124-
if ( logAPIs() ) _LIBUNWIND_LOG(msg, __VA_ARGS__); \
125-
} while(0)
126-
#define _LIBUNWIND_TRACE_UNWINDING(msg, ...) \
127-
do { \
128-
if ( logUnwinding() ) _LIBUNWIND_LOG(msg, __VA_ARGS__); \
129-
} while(0)
124+
#define _LIBUNWIND_TRACE_API(msg, ...) \
125+
do { \
126+
if (logAPIs()) \
127+
_LIBUNWIND_LOG(msg, __VA_ARGS__); \
128+
} while (0)
130129
#define _LIBUNWIND_TRACING_UNWINDING logUnwinding()
130+
#define _LIBUNWIND_TRACE_UNWINDING(msg, ...) \
131+
do { \
132+
if (logUnwinding()) \
133+
_LIBUNWIND_LOG(msg, __VA_ARGS__); \
134+
} while (0)
131135
#endif
132136

133137
#ifdef __cplusplus

0 commit comments

Comments
 (0)