riccaticpp
Loading...
Searching...
No Matches
macros.hpp
Go to the documentation of this file.
1#ifndef INCLUDE_RICCATI_MACROS_HPP
2#define INCLUDE_RICCATI_MACROS_HPP
3
4namespace riccati {
5
6#ifdef __GNUC__
7
12#ifndef likely
13#define likely(x) __builtin_expect(!!(x), 1)
14#endif
15
16#ifndef unlikely
17#define unlikely(x) __builtin_expect(!!(x), 0)
18#endif
19
20#ifdef __has_attribute
21#if __has_attribute(noinline) && __has_attribute(cold)
22#ifndef RICCATI_COLD_PATH
28#define RICCATI_COLD_PATH __attribute__((noinline, cold))
29#endif
30#endif
31#endif
32
33#ifndef RICCATI_COLD_PATH
34#define RICCATI_COLD_PATH
35#endif
36#ifndef RICCATI_NO_INLINE
37#define RICCATI_NO_INLINE __attribute__((noinline))
38#endif
39
40#ifndef RICCATI_ALWAYS_INLINE
41#define RICCATI_ALWAYS_INLINE __attribute__((always_inline)) inline
42#endif
43
48#ifndef RICCATI_PURE
49#define RICCATI_PURE __attribute__((pure))
50#endif
51
52#else
53#define likely(x) (x)
54#define unlikely(x) (x)
55#define RICCATI_COLD_PATH
56#define RICCATI_NO_INLINE
57#define RICCATI_ALWAYS_INLINE inline
58#define RICCATI_PURE
59#endif
60
61} // namespace riccati
62
63#endif