diff options
author | Nicolas Noble <nicolasnoble@users.noreply.github.com> | 2019-07-31 10:04:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-31 10:04:53 -0700 |
commit | 588128ccce25625f9e630e80142e244637517ef7 (patch) | |
tree | dae34c0361588a2b047f7fc156aeceeb27f22c53 /upb/port_def.inc | |
parent | f3514c0600d14d5c53ee7411f3fb0f9d38110257 (diff) | |
parent | 401285b2f16f3eb098a9306e59b803f4ae9891bc (diff) |
Merge pull request #197 from veblush/likely
Make UPB_LIKELY compatible with non-GNUC
Diffstat (limited to 'upb/port_def.inc')
-rw-r--r-- | upb/port_def.inc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/upb/port_def.inc b/upb/port_def.inc index 0650920..3e0a7f4 100644 --- a/upb/port_def.inc +++ b/upb/port_def.inc @@ -52,7 +52,13 @@ #endif /* Hints to the compiler about likely/unlikely branches. */ +#ifdef __GNUC__ #define UPB_LIKELY(x) __builtin_expect((x),1) +#define UPB_UNLIKELY(x) __builtin_expect((x),0) +#else +#define UPB_LIKELY(x) (x) +#define UPB_UNLIKELY(x) (x) +#endif /* Define UPB_BIG_ENDIAN manually if you're on big endian and your compiler * doesn't provide these preprocessor symbols. */ |