misc: define SPOT_LIKELY and SPOT_UNLIKELY

* src/misc/common.hh: Here.
* src/misc/intvcmp2.cc, src/misc/intvcomp.cc: Adjust to use them.
This commit is contained in:
Alexandre Duret-Lutz 2014-10-30 09:58:12 +01:00
parent 923785f76a
commit f0fd654c1f
3 changed files with 30 additions and 37 deletions

View file

@ -23,6 +23,14 @@
#ifndef SPOT_MISC_COMMON_HH
# define SPOT_MISC_COMMON_HH
#ifdef __GNUC__
#define SPOT_LIKELY(expr) __builtin_expect(!!(expr), 1)
#define SPOT_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
#else
#define SPOT_LIKELY(expr) (expr)
#define SPOT_UNLIKELY(expr) (expr)
#endif
#ifdef __GNUC__
#define SPOT_DEPRECATED __attribute__ ((deprecated))
#elif defined(_MSC_VER)