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 | |
parent | 7b14415fddc76710352a906c0e1a3e86273e9f08 (diff) |
Add unlikely()
Diffstat (limited to 'libcrystfel/src')
-rw-r--r-- | libcrystfel/src/geometry.c | 2 | ||||
-rw-r--r-- | libcrystfel/src/utils.h | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c index 6ccaf3d8..c1d433c8 100644 --- a/libcrystfel/src/geometry.c +++ b/libcrystfel/src/geometry.c @@ -185,7 +185,7 @@ static Reflection *check_reflection(struct image *image, Crystal *cryst, && (fabs(rlow) > pr) && (fabs(rhigh) > pr) ) return NULL; - if ( rlow < rhigh ) { + if ( unlikely(rlow < rhigh) ) { ERROR("Reflection with rlow < rhigh!\n"); ERROR("%3i %3i %3i rlow = %e, rhigh = %e\n", h, k, l, rlow, rhigh); 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 |