diff options
author | Doug Nazar <nazard@nazar.ca> | 2019-08-18 11:50:44 -0400 |
---|---|---|
committer | Doug Nazar <nazard@nazar.ca> | 2019-08-18 11:50:44 -0400 |
commit | 9c70f4c97670ec60448224b1007e706ba75d9077 (patch) | |
tree | 21612afd86e98de5791efaac108e56e34f4040ba /orc/orcutils.h | |
parent | 520425d0a6b26841567720dd5b189af2d23ce171 (diff) | |
download | orc-9c70f4c97670ec60448224b1007e706ba75d9077.tar.gz |
orc: Add ORC_LIKELY/ORC_UNLIKELY macros
Diffstat (limited to 'orc/orcutils.h')
-rw-r--r-- | orc/orcutils.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/orc/orcutils.h b/orc/orcutils.h index dc13cd0..59c2c9e 100644 --- a/orc/orcutils.h +++ b/orc/orcutils.h @@ -167,6 +167,14 @@ typedef unsigned int orc_bool; #define ORC_GNUC_PREREQ(maj, min) 0 #endif +#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) +#define ORC_LIKELY(expr) (__builtin_expect ((expr), 1)) +#define ORC_UNLIKELY(expr) (__builtin_expect ((expr), 0)) +#else +#define ORC_LIKELY(expr) (expr) +#define ORC_UNLIKELY(expr) (expr) +#endif + #ifndef ORC_INTERNAL #if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) #define ORC_INTERNAL __attribute__((visibility("hidden"))) |