Fix missing import in finiterectlat-scatter.py
[qpms.git] / qpms / optim.h
blob6484700033bec3b3c38cc3689afff8ca72e3a4e8
1 /** \file optim.h
2 * \brief Macros for compiler optimisation.
3 */
4 #ifndef QPMS_OPTIM_H
5 #define QPMS_OPTIM_H
8 #if ((defined __GNUC__) || (defined __clang__)) && !(defined QPMS_NO_BUILTIN_EXPECT)
9 /// Wrapper over gcc's and clang's __builtin_expect.
10 /** If expands to __builtin_expect if gcc or clang are used,
11 * else expands only to the first argument.
13 #define QPMS_EXPECT(exp, c) __builtin_expect(exp, c)
14 #define QPMS_LIKELY(x) __builtin_expect(!!(x), 1)
15 #define QPMS_UNLIKELY(x) __builtin_expect(!!(x), 0)
16 #else
17 #define QPMS_LIKELY(x) (x)
18 #define QPMS_UNLIKELY(x)
19 #define QPMS_EXPECT(exp,c) (exp)
20 #endif
22 #if (defined(__GNUC__) && __GNUC__ >= 3) || \
23 (defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 2 && __GNUC_MINOR__ >= 8)
24 // TODO clang
25 #define QPMS_NORETURN __attribute__((noreturn))
26 #endif
28 #endif // OPTIM_H