aboutsummaryrefslogtreecommitdiff
path: root/lib/common/debug.h
diff options
context:
space:
mode:
authorYann Collet <Cyan4973@users.noreply.github.com>2024-03-21 15:05:51 -0700
committerGitHub <noreply@github.com>2024-03-21 15:05:51 -0700
commit794ea1b0afca0f020f4e57b6732332231fb23c70 (patch)
tree1d0c369da267aca0921dfe2f16dfee5404abe20b /lib/common/debug.h
parent63779c798237346c2b245c546c40b72a5a5913fe (diff)
parent78f732cfdd65bccc76d7da2ae103e141e5ca5742 (diff)
downloadzstd-794ea1b0afca0f020f4e57b6732332231fb23c70.tar.gz
Merge pull request #3984 from facebook/devupstream-release
v1.5.6
Diffstat (limited to 'lib/common/debug.h')
-rw-r--r--lib/common/debug.h31
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/common/debug.h b/lib/common/debug.h
index 0e9817ea..a16b69e5 100644
--- a/lib/common/debug.h
+++ b/lib/common/debug.h
@@ -85,18 +85,27 @@ extern int g_debuglevel; /* the variable is only declared,
It's useful when enabling very verbose levels
on selective conditions (such as position in src) */
-# define RAWLOG(l, ...) { \
- if (l<=g_debuglevel) { \
- ZSTD_DEBUG_PRINT(__VA_ARGS__); \
- } }
-# define DEBUGLOG(l, ...) { \
- if (l<=g_debuglevel) { \
- ZSTD_DEBUG_PRINT(__FILE__ ": " __VA_ARGS__); \
- ZSTD_DEBUG_PRINT(" \n"); \
- } }
+# define RAWLOG(l, ...) \
+ do { \
+ if (l<=g_debuglevel) { \
+ ZSTD_DEBUG_PRINT(__VA_ARGS__); \
+ } \
+ } while (0)
+
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+#define LINE_AS_STRING TOSTRING(__LINE__)
+
+# define DEBUGLOG(l, ...) \
+ do { \
+ if (l<=g_debuglevel) { \
+ ZSTD_DEBUG_PRINT(__FILE__ ":" LINE_AS_STRING ": " __VA_ARGS__); \
+ ZSTD_DEBUG_PRINT(" \n"); \
+ } \
+ } while (0)
#else
-# define RAWLOG(l, ...) {} /* disabled */
-# define DEBUGLOG(l, ...) {} /* disabled */
+# define RAWLOG(l, ...) do { } while (0) /* disabled */
+# define DEBUGLOG(l, ...) do { } while (0) /* disabled */
#endif