diff options
author | Thomas White <taw@physics.org> | 2014-06-24 16:39:06 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2014-06-24 16:39:06 +0200 |
commit | def8bd0c541252e7f606c9286912eb67d3ac5929 (patch) | |
tree | b9ab2a29d8382beab37eb1d31d69cd94202eebbb /libcrystfel/src/utils.h | |
parent | 7b14415fddc76710352a906c0e1a3e86273e9f08 (diff) |
Add unlikely()
Diffstat (limited to 'libcrystfel/src/utils.h')
-rw-r--r-- | libcrystfel/src/utils.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libcrystfel/src/utils.h b/libcrystfel/src/utils.h index 4478f179..2f2009d6 100644 --- a/libcrystfel/src/utils.h +++ b/libcrystfel/src/utils.h @@ -228,7 +228,6 @@ static inline int within_tolerance(double a, double b, double percent) /* Photon energy (eV) to wavelength (m) */ #define ph_eV_to_lambda(a) ph_en_to_lambda(eV_to_J(a)) -#define UNUSED __attribute__((unused)) /* ------------------------------ Message macros ---------------------------- */ @@ -261,6 +260,19 @@ extern pthread_mutex_t stderr_lock; extern char *check_prefix(char *prefix); extern char *safe_basename(const char *in); + +/* ------------------------------ Useful stuff ------------------------------ */ + +#if __GNUC__ >= 3 +#define UNUSED __attribute__((unused)) +#define likely(x) __builtin_expect (!!(x), 1) +#define unlikely(x) __builtin_expect (!!(x), 0) +#else +#define UNUSED +#define likely(x) (x) +#define unlikely(x) (x) +#endif + #ifdef __cplusplus } #endif |