From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 7/7] DEBUG: Fix debug macros
Date: Tue, 25 Oct 2011 11:41:42 +0200 [thread overview]
Message-ID: <1319535702-20929-8-git-send-email-marek.vasut@gmail.com> (raw)
In-Reply-To: <1319535702-20929-1-git-send-email-marek.vasut@gmail.com>
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>
---
include/common.h | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/include/common.h b/include/common.h
index a1683a2..e0d0af6 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
--
1.7.6.3
next prev parent reply other threads:[~2011-10-25 9:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-25 9:41 [U-Boot] [PATCH 0/7] CLEANUP: Cleanup of misc remaining things found Marek Vasut
2011-10-25 9:41 ` [U-Boot] [PATCH 1/7] GCC4.6: Squash warnings in LzmaTools.c Marek Vasut
2011-10-27 22:02 ` Wolfgang Denk
2011-10-25 9:41 ` [U-Boot] [PATCH 2/7] GCC4.6: Drop dead code from yaffs_guts.c Marek Vasut
2011-10-27 22:02 ` Wolfgang Denk
2011-10-25 9:41 ` [U-Boot] [PATCH 3/7] GCC4.6: Squash warnings in yaffs_guts.c Marek Vasut
2011-10-27 22:03 ` Wolfgang Denk
2011-10-25 9:41 ` [U-Boot] [PATCH 4/7] GCC4.6: Squash warning in tegra2 board.c Marek Vasut
2011-10-27 22:03 ` Wolfgang Denk
2011-10-25 9:41 ` [U-Boot] [PATCH 5/7] GCC4.6: Squash warnings in omap4 clocks.c Marek Vasut
2011-10-27 22:03 ` Wolfgang Denk
2011-10-25 9:41 ` [U-Boot] [PATCH 6/7] GCC4.6: Remove debugX() usage from spc1920 hpi Marek Vasut
2011-10-27 22:03 ` Wolfgang Denk
2011-10-25 9:41 ` Marek Vasut [this message]
2011-10-27 22:03 ` [U-Boot] [PATCH 7/7] DEBUG: Fix debug macros Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1319535702-20929-8-git-send-email-marek.vasut@gmail.com \
--to=marek.vasut@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox