diff options
Diffstat (limited to 'lib/zstd/common/debug.h')
| -rw-r--r-- | lib/zstd/common/debug.h | 37 | 
1 files changed, 22 insertions, 15 deletions
| diff --git a/lib/zstd/common/debug.h b/lib/zstd/common/debug.h index 6dd88d1fbd02..c8a10281f112 100644 --- a/lib/zstd/common/debug.h +++ b/lib/zstd/common/debug.h @@ -1,7 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */  /* ******************************************************************   * debug   * Part of FSE library - * Copyright (c) Yann Collet, Facebook, Inc. + * Copyright (c) Meta Platforms, Inc. and affiliates.   *   * You can contact the author at :   * - Source repository : https://github.com/Cyan4973/FiniteStateEntropy @@ -33,7 +34,6 @@  #define DEBUG_H_12987983217 -  /* static assert is triggered at compile time, leaving no runtime artefact.   * static assert only works with compile-time constants.   * Also, this variant can only be used inside a function. */ @@ -82,20 +82,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 - -  #endif /* DEBUG_H_12987983217 */ | 
