From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Mon, 24 Oct 2011 10:21:15 +0200 Subject: [U-Boot] [PATCH 01/39] DEBUG: Fix debug macros In-Reply-To: References: <1319242654-15534-1-git-send-email-marek.vasut@gmail.com> <1319242654-15534-2-git-send-email-marek.vasut@gmail.com> Message-ID: <201110241021.15442.marek.vasut@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Monday, October 24, 2011 06:31:19 AM Simon Glass wrote: > Hi Marek, > > On Fri, Oct 21, 2011 at 5:16 PM, Marek Vasut wrote: > > 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. > > > > Signed-off-by: Mike Frysinger > > Signed-off-by: Marek Vasut > > Cc: Wolfgang Denk > > Cc: Simon Glass > > --- > > include/common.h | 20 ++++++++++++-------- > > 1 files changed, 12 insertions(+), 8 deletions(-) > > > > diff --git a/include/common.h b/include/common.h > > index eb19a44..c3b23551 100644 > > --- a/include/common.h > > +++ b/include/common.h > > @@ -116,20 +116,24 @@ typedef volatile unsigned char vu_char; > > #include > > #include > > > > -#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 > > #else > > # define _DEBUG 0 > > #endif > > > > +#define debug_cond(cond, fmt, args...) \ > > Yes this is much nicer. Could perhaps add a little comment about how > to use this and to avoid putting debug() inside #ifdef? > > > + do { \ > > + if (cond) \ > > + printf(fmt, ##args); \ > > + } while (0) > > + > > +#define debug(fmt, args...) \ > > + debug_cond(_DEBUG, fmt, ##args) > > + > > +#define debugX(level, fmt, args...) \ > > + debug_cond((_DEBUG && DEBUG >= (level)), 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, -- > > 1.7.6.3 Done, I pushed new patchset right now to git://git.denx.de/u-boot-marex.git , "debug" branch. It's around 50 patches now.