1 /* ******************************************* 1 2 * debug 3 * Part of FSE library 4 * Copyright (c) Yann Collet, Facebook, Inc. 5 * 6 * You can contact the author at : 7 * - Source repository : https://github.com/Cy 8 * 9 * This source code is licensed under both the 10 * LICENSE file in the root directory of this 11 * in the COPYING file in the root directory o 12 * You may select, at your option, one of the 13 ********************************************** 14 15 16 /* 17 * The purpose of this header is to enable deb 18 * They regroup assert(), DEBUGLOG() and RAWLO 19 * and DEBUG_STATIC_ASSERT() for compile-time. 20 * 21 * By default, DEBUGLEVEL==0, which means run- 22 * 23 * Level 1 enables assert() only. 24 * Starting level 2, traces can be generated a 25 * The higher the level, the more verbose the 26 * 27 * It's possible to dynamically adjust level u 28 * which is only declared if DEBUGLEVEL>=2, 29 * and is a global variable, not multi-thread 30 */ 31 32 #ifndef DEBUG_H_12987983217 33 #define DEBUG_H_12987983217 34 35 36 37 /* static assert is triggered at compile time, 38 * static assert only works with compile-time 39 * Also, this variant can only be used inside 40 #define DEBUG_STATIC_ASSERT(c) (void)sizeof(ch 41 42 43 /* DEBUGLEVEL is expected to be defined extern 44 * typically through compiler command line. 45 * Value must be a number. */ 46 #ifndef DEBUGLEVEL 47 # define DEBUGLEVEL 0 48 #endif 49 50 51 /* recommended values for DEBUGLEVEL : 52 * 0 : release mode, no debug, all run-time ch 53 * 1 : enables assert() only, no display 54 * 2 : reserved, for currently active debug pa 55 * 3 : events once per object lifetime (CCtx, 56 * 4 : events once per frame 57 * 5 : events once per block 58 * 6 : events once per sequence (verbose) 59 * 7+: events at every position (*very* verbos 60 * 61 * It's generally inconvenient to output trace 62 * In which case, it's possible to selectively 63 * by modifying g_debug_level. 64 */ 65 66 #if (DEBUGLEVEL>=1) 67 # define ZSTD_DEPS_NEED_ASSERT 68 # include "zstd_deps.h" 69 #else 70 # ifndef assert /* assert may be already de 71 # define assert(condition) ((void)0) /* d 72 # endif 73 #endif 74 75 #if (DEBUGLEVEL>=2) 76 # define ZSTD_DEPS_NEED_IO 77 # include "zstd_deps.h" 78 extern int g_debuglevel; /* the variable is on 79 it actually lives 80 and is shared by t 81 It's not thread-sa 82 It's useful when e 83 on selective condi 84 85 # define RAWLOG(l, ...) { 86 if (l<=g_debuglevel) { 87 ZSTD_DEBUG_PRINT(__VA_ARGS 88 } } 89 # define DEBUGLOG(l, ...) { 90 if (l<=g_debuglevel) { 91 ZSTD_DEBUG_PRINT(__FILE__ 92 ZSTD_DEBUG_PRINT(" \n"); 93 } } 94 #else 95 # define RAWLOG(l, ...) {} /* disable 96 # define DEBUGLOG(l, ...) {} /* disable 97 #endif 98 99 100 101 #endif /* DEBUG_H_12987983217 */ 102
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.