mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Make the __builtin_expect argument a bool.
No significant benchmark numbers changed. All existing uses are already bools, but future uses might not be.
This commit is contained in:
1 parent
4a6907d18a
commit
198dd1cab0
3 files changed
+9
-7
No files matched your search
@@ -17,9 +17,10 @@
|
||||
|
||||
#define PUFFS_LOW_BITS(x, n) ((x) & ((1 << (n)) - 1))
|
||||
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
#define PUFFS_LIKELY(expr) (__builtin_expect((expr), 1))
|
||||
#define PUFFS_UNLIKELY(expr) (__builtin_expect((expr), 0))
|
||||
// Clang also defines "__GNUC__".
|
||||
#if defined(__GNUC__)
|
||||
#define PUFFS_LIKELY(expr) (__builtin_expect(!!(expr), 1))
|
||||
#define PUFFS_UNLIKELY(expr) (__builtin_expect(!!(expr), 0))
|
||||
#else
|
||||
#define PUFFS_LIKELY(expr) (expr)
|
||||
#define PUFFS_UNLIKELY(expr) (expr)
|
||||
|
||||
@@ -12,5 +12,5 @@ const baseHeader = "" +
|
||||
""
|
||||
|
||||
const baseImpl = "" +
|
||||
"#ifndef PUFFS_BASE_IMPL_H\n#define PUFFS_BASE_IMPL_H\n\n// Use of this source code is governed by a BSD-style license that can be found\n// in the LICENSE file.\n\n// Use switch cases for coroutine state, similar to the technique in\n// https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html\n//\n// We use a trivial macro instead of an explicit assignment and case statement\n// so that clang-format doesn't get confused by the unusual \"case\"s.\n#define PUFFS_COROUTINE_STATE(n) \\\n coro_state = n; \\\n case n:\n\n#define PUFFS_LOW_BITS(x, n) ((x) & ((1 << (n)) - 1))\n\n#if defined(__clang__) || defined(__GNUC__)\n#define PUFFS_LIKELY(expr) (__builtin_expect((expr), 1))\n#define PUFFS_UNLIKELY(expr) (__builtin_expect((expr), 0))\n#else\n#define PUFFS_LIKELY(expr) (expr)\n#define PUFFS_UNLIKELY(expr) (expr)\n#endif\n\n#endif // PUFFS_BASE_IMPL_H\n" +
|
||||
"#ifndef PUFFS_BASE_IMPL_H\n#define PUFFS_BASE_IMPL_H\n\n// Use of this source code is governed by a BSD-style license that can be found\n// in the LICENSE file.\n\n// Use switch cases for coroutine state, similar to the technique in\n// https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html\n//\n// We use a trivial macro instead of an explicit assignment and case statement\n// so that clang-format doesn't get confused by the unusual \"case\"s.\n#define PUFFS_COROUTINE_STATE(n) \\\n coro_state = n; \\\n case n:\n\n#define PUFFS_LOW_BITS(x, n) ((x) & ((1 << (n)) - 1))\n\n// Clang also defines \"__GNUC__\".\n#if defined(__GNUC__)\n#define PUFFS_LIKELY(expr) (__builtin_expect(!!(expr), 1))\n#define PUFFS_UNLIKELY(expr) (__builtin_expect(!!(expr), 0))\n#else\n#define PUFFS_LIKELY(expr) (expr)\n#define PUFFS_UNLIKELY(expr) (expr)\n#endif\n\n#endif // PUFFS_BASE_IMPL_H\n" +
|
||||
""
|
||||
+4
-3
@@ -250,9 +250,10 @@ puffs_gif_status puffs_gif_lzw_decoder_decode(puffs_gif_lzw_decoder* self,
|
||||
|
||||
#define PUFFS_LOW_BITS(x, n) ((x) & ((1 << (n)) - 1))
|
||||
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
#define PUFFS_LIKELY(expr) (__builtin_expect((expr), 1))
|
||||
#define PUFFS_UNLIKELY(expr) (__builtin_expect((expr), 0))
|
||||
// Clang also defines "__GNUC__".
|
||||
#if defined(__GNUC__)
|
||||
#define PUFFS_LIKELY(expr) (__builtin_expect(!!(expr), 1))
|
||||
#define PUFFS_UNLIKELY(expr) (__builtin_expect(!!(expr), 0))
|
||||
#else
|
||||
#define PUFFS_LIKELY(expr) (expr)
|
||||
#define PUFFS_UNLIKELY(expr) (expr)
|
||||
|
||||
Reference in new issue
Block a user