Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ALMOST_ALWAYS/ALMOST_NEVER (likely/unlikely early support)
- #ifdef __has_cpp_attribute
- #if __has_cpp_attribute(likely)
- #define ALMOST_ALWAYS(expr) (expr) [[likely]]
- #endif
- #if __has_cpp_attribute(unlikely)
- #define ALMOST_NEVER(expr) (expr) [[unlikely]]
- #endif
- #endif
- #ifndef ALMOST_ALWAYS
- #if defined(__builtin_expect)
- #define ALMOST_ALWAYS(expr) (__builtin_expect(static_cast<bool>(expr), 1))
- #else
- #define ALMOST_ALWAYS(expr) (expr)
- #endif
- #endif
- #ifndef ALMOST_NEVER
- #if defined(__builtin_expect)
- #define ALMOST_NEVER(expr) (__builtin_expect(static_cast<bool>(expr), 0))
- #else
- #define ALMOST_NEVER(expr) (expr)
- #endif
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement