Support branch prediction helpers on clang compiles (#491)

This commit is contained in:
Ebrahim Byagowi 2017-06-02 21:53:10 +04:30 committed by Behdad Esfahbod
parent 7dba30639a
commit 76c4873e8c
1 changed files with 3 additions and 4 deletions

View File

@ -74,10 +74,9 @@ extern "C" void hb_free_impl(void *ptr);
/* Compiler attributes */ /* Compiler attributes */
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) #if (defined(__GNUC__) || defined(__clang__)) && defined(__OPTIMIZE__)
#define _HB_BOOLEAN_EXPR(expr) ((expr) ? 1 : 0) #define likely(expr) (__builtin_expect (!!(expr), 1))
#define likely(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 1)) #define unlikely(expr) (__builtin_expect (!!(expr), 0))
#define unlikely(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 0))
#else #else
#define likely(expr) (expr) #define likely(expr) (expr)
#define unlikely(expr) (expr) #define unlikely(expr) (expr)