lkml.org 
[lkml]   [2004]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectSignificance of do ... while (0)
    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)

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 14:08    [W:0.021 / U:1.180 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site