public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Significance of do ... while (0)
@ 2004-12-17  4:09 krishna
  2004-12-17  4:21 ` Dave Jones
  2004-12-17  4:29 ` Mitchell Blank Jr
  0 siblings, 2 replies; 7+ messages in thread
From: krishna @ 2004-12-17  4:09 UTC (permalink / raw)
  To: Linux Kernel

Hi all,

    Can any one explain the importance of do  ... while (0)

Regards,
Krishna Chaitanya

#define STATS_SET_HIGH(x)       do { if ((x)->num_active > (x)->high_mark) \
                                        (x)->high_mark = (x)->num_active; \
                                } while (0)
#define STATS_INC_ERR(x)        ((x)->errors++)
#define STATS_SET_FREEABLE(x, i) \
                                do { if ((x)->max_freeable < i) \
                                        (x)->max_freeable = i; \
                                } while (0)
                                                                                                                              
 
#define STATS_INC_ALLOCHIT(x)   atomic_inc(&(x)->allochit)
#define STATS_INC_ALLOCMISS(x)  atomic_inc(&(x)->allocmiss)
#define STATS_INC_FREEHIT(x)    atomic_inc(&(x)->freehit)
#define STATS_INC_FREEMISS(x)   atomic_inc(&(x)->freemiss)
#else
#define STATS_INC_ACTIVE(x)     do { } while (0)
#define STATS_DEC_ACTIVE(x)     do { } while (0)
#define STATS_INC_ALLOCED(x)    do { } while (0)
#define STATS_INC_GROWN(x)      do { } while (0)
#define STATS_INC_REAPED(x)     do { } while (0)
#define STATS_SET_HIGH(x)       do { } while (0)
#define STATS_INC_ERR(x)        do { } while (0)
#define STATS_SET_FREEABLE(x, i) \
                                do { } while (0)
                                                                                                                              
 
#define STATS_INC_ALLOCHIT(x)   do { } while (0)
#define STATS_INC_ALLOCMISS(x)  do { } while (0)
#define STATS_INC_FREEHIT(x)    do { } while (0)
#define STATS_INC_FREEMISS(x)   do { } while (0)


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-12-17  8:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-17  4:09 Significance of do ... while (0) krishna
2004-12-17  4:21 ` Dave Jones
2004-12-17  4:54   ` krishna
2004-12-17  4:29 ` Mitchell Blank Jr
2004-12-17  7:44   ` Jan Engelhardt
2004-12-17  7:58     ` vlobanov
2004-12-17  8:06       ` Jan Engelhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox