diff options
author | Marek Vasut <marek.vasut@gmail.com> | 2011-10-24 23:41:42 +0000 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2011-10-27 23:54:10 +0200 |
commit | 88a85fb9f3578f513d7053ac9a3f1ff7521b2771 (patch) | |
tree | aca5840b9441d72d1cb3bd72a4eac3dd4bdb0f46 /include | |
parent | 75753699ae3ff32796e24ce48c8f4e09995c0920 (diff) | |
download | u-boot-imx-88a85fb9f3578f513d7053ac9a3f1ff7521b2771.zip u-boot-imx-88a85fb9f3578f513d7053ac9a3f1ff7521b2771.tar.gz u-boot-imx-88a85fb9f3578f513d7053ac9a3f1ff7521b2771.tar.bz2 |
DEBUG: Fix debug macros
The current implementation of debug doesn't play well with GCC4.6.
This implementation also fixes GCC4.6 complaints about unused variables
while maintaining code size.
Also, drop the debugX() as that's not used anywhere anymore.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/common.h | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/include/common.h b/include/common.h index fb41d7a..5ca8820 100644 --- a/include/common.h +++ b/include/common.h @@ -116,21 +116,27 @@ typedef volatile unsigned char vu_char; #include <flash.h> #include <image.h> -#ifdef DEBUG -#define debug(fmt,args...) printf (fmt ,##args) -#define debugX(level,fmt,args...) if (DEBUG>=level) printf(fmt,##args); -#else -#define debug(fmt,args...) -#define debugX(level,fmt,args...) -#endif /* DEBUG */ - #ifdef DEBUG -# define _DEBUG 1 +#define _DEBUG 1 #else -# define _DEBUG 0 +#define _DEBUG 0 #endif /* + * Output a debug text when condition "cond" is met. The "cond" should be + * computed by a preprocessor in the best case, allowing for the best + * optimization. + */ +#define debug_cond(cond, fmt, args...) \ + do { \ + if (cond) \ + printf(fmt, ##args); \ + } while (0) + +#define debug(fmt, args...) \ + debug_cond(_DEBUG, fmt, ##args) + +/* * An assertion is run-time check done in debug mode only. If DEBUG is not * defined then it is skipped. If DEBUG is defined and the assertion fails, * then it calls panic*( which may or may not reset/halt U-Boot (see |