Last active
October 7, 2015 08:58
-
-
Save fritzo/3138949 to your computer and use it in GitHub Desktop.
Add unlikely() and likely() wrappers in gnu C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* from the cython compiler */ | |
#ifdef __GNUC__ | |
/* Test for GCC > 2.95 */ | |
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) | |
#define likely(x) __builtin_expect(!!(x), 1) | |
#define unlikely(x) __builtin_expect(!!(x), 0) | |
#else /* __GNUC__ > 2 ... */ | |
#define likely(x) (x) | |
#define unlikely(x) (x) | |
#endif /* __GNUC__ > 2 ... */ | |
#else /* __GNUC__ */ | |
#define likely(x) (x) | |
#define unlikely(x) (x) | |
#endif /* __GNUC__ */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment