mirror of
https://github.com/facebook/zstd
synced 2026-08-22 22:32:07 -04:00
compiler: honour LIKELY/UNLIKELY under clang-cl
Same __GNUC__ gate as TARGET_ATTRIBUTE. clang-cl supports __builtin_expect, so test for it with __has_builtin and keep __GNUC__ as a fallback. Without this, every branch hint in the library is discarded under clang-cl.
This commit is contained in:
parent
b81b64a961
commit
4afc10ef28
1 changed files with 10 additions and 1 deletions
|
|
@ -201,7 +201,16 @@
|
|||
* If you can remove a LIKELY/UNLIKELY annotation without speed changes in gcc
|
||||
* and clang, please do.
|
||||
*/
|
||||
#if defined(__GNUC__)
|
||||
#if defined(__has_builtin)
|
||||
# if __has_builtin(__builtin_expect)
|
||||
# define ZSTD_HAS_BUILTIN_EXPECT 1
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(ZSTD_HAS_BUILTIN_EXPECT) && defined(__GNUC__)
|
||||
# define ZSTD_HAS_BUILTIN_EXPECT 1
|
||||
#endif
|
||||
|
||||
#if defined(ZSTD_HAS_BUILTIN_EXPECT)
|
||||
#define LIKELY(x) (__builtin_expect((x), 1))
|
||||
#define UNLIKELY(x) (__builtin_expect((x), 0))
|
||||
#else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue