From c14832dcb2b1004eb58eb12fdf26f466193988ab Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Wed, 28 Dec 2016 05:07:56 +0200 Subject: [PATCH] Add DUK_UNPREDICTABLE() placeholder --- config/compilers/compiler_clang.h.in | 5 +++++ config/compilers/compiler_emscripten.h.in | 5 +++++ config/compilers/compiler_gcc.h.in | 1 + config/header-snippets/compiler_fillins.h.in | 3 +++ 4 files changed, 14 insertions(+) diff --git a/config/compilers/compiler_clang.h.in b/config/compilers/compiler_clang.h.in index c36caee8..b42ac903 100644 --- a/config/compilers/compiler_clang.h.in +++ b/config/compilers/compiler_clang.h.in @@ -17,6 +17,11 @@ #define DUK_USE_BRANCH_HINTS #define DUK_LIKELY(x) __builtin_expect((x), 1) #define DUK_UNLIKELY(x) __builtin_expect((x), 0) +#if defined(__clang__) && defined(__has_builtin) +#if __has_builtin(__builtin_unpredictable) +#define DUK_UNPREDICTABLE() do { __builtin_unpredictable(); } while (0) +#endif +#endif #if defined(DUK_F_C99) || defined(DUK_F_CPP11) #define DUK_NOINLINE __attribute__((noinline)) diff --git a/config/compilers/compiler_emscripten.h.in b/config/compilers/compiler_emscripten.h.in index 3aed2367..45cca2a1 100644 --- a/config/compilers/compiler_emscripten.h.in +++ b/config/compilers/compiler_emscripten.h.in @@ -9,6 +9,11 @@ #define DUK_USE_BRANCH_HINTS #define DUK_LIKELY(x) __builtin_expect((x), 1) #define DUK_UNLIKELY(x) __builtin_expect((x), 0) +#if defined(__clang__) && defined(__has_builtin) +#if __has_builtin(__builtin_unpredictable) +#define DUK_UNPREDICTABLE() do { __builtin_unpredictable(); } while (0) +#endif +#endif #if defined(DUK_F_C99) || defined(DUK_F_CPP11) #define DUK_NOINLINE __attribute__((noinline)) diff --git a/config/compilers/compiler_gcc.h.in b/config/compilers/compiler_gcc.h.in index a6261836..c040595e 100644 --- a/config/compilers/compiler_gcc.h.in +++ b/config/compilers/compiler_gcc.h.in @@ -24,6 +24,7 @@ #define DUK_LIKELY(x) __builtin_expect((x), 1) #define DUK_UNLIKELY(x) __builtin_expect((x), 0) #endif +/* XXX: equivalent of clang __builtin_unpredictable? */ #if (defined(DUK_F_C99) || defined(DUK_F_CPP11)) && \ defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 30101) diff --git a/config/header-snippets/compiler_fillins.h.in b/config/header-snippets/compiler_fillins.h.in index 25cc33a2..c5ff17ff 100644 --- a/config/header-snippets/compiler_fillins.h.in +++ b/config/header-snippets/compiler_fillins.h.in @@ -66,6 +66,9 @@ #if !defined(DUK_UNLIKELY) #define DUK_UNLIKELY(x) (x) #endif +#if !defined(DUK_UNPREDICTABLE) +#define DUK_UNPREDICTABLE(x) (x) +#endif #if !defined(DUK_NOINLINE) #define DUK_NOINLINE /*nop*/