Nicolas Bernard's Toolbox - Misc.

Mostly tips collected around.

Download: nbmisc.h

nbmisc.h

  1: #ifndef _NBMISC_H_
  2: #define _NBMISC_H_
  3: 
  4: 
  5: /* Can be used in conditions.
  6:     * See http://kerneltrap.org/node/4705
  7:       and "Other Builtins" in gcc documentation */
  8: // beware __GNUC__ indicates GNU C extensions, not gcc
  9: #if __GNUC__ >= 3
 10: #define likely(x)       __builtin_expect((x),1)
 11: #define unlikely(x)     __builtin_expect((x),0)
 12: #else
 13: #define likely(x)       (x)
 14: #define unlikely(x)     (x)
 15: #endif
 16: 
 17: 
 18: #endif /* ! _NBMISC_H_ */