rename (un)likely (#11391)
This commit is contained in:
parent
d7d88ae218
commit
55af21c662
2 changed files with 6 additions and 6 deletions
|
|
@ -466,16 +466,16 @@ struct TFrame_ {
|
||||||
#define NIM_POSIX_INIT __attribute__((constructor))
|
#define NIM_POSIX_INIT __attribute__((constructor))
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# define likely(x) __builtin_expect(x, 1)
|
# define NIM_LIKELY(x) __builtin_expect(x, 1)
|
||||||
# define unlikely(x) __builtin_expect(x, 0)
|
# define NIM_UNLIKELY(x) __builtin_expect(x, 0)
|
||||||
/* We need the following for the posix wrapper. In particular it will give us
|
/* We need the following for the posix wrapper. In particular it will give us
|
||||||
POSIX_SPAWN_USEVFORK: */
|
POSIX_SPAWN_USEVFORK: */
|
||||||
# ifndef _GNU_SOURCE
|
# ifndef _GNU_SOURCE
|
||||||
# define _GNU_SOURCE
|
# define _GNU_SOURCE
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define likely(x) (x)
|
# define NIM_LIKELY(x) (x)
|
||||||
# define unlikely(x) (x)
|
# define NIM_UNLIKELY(x) (x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0 // defined(__GNUC__) || defined(__clang__)
|
#if 0 // defined(__GNUC__) || defined(__clang__)
|
||||||
|
|
|
||||||
|
|
@ -3387,8 +3387,8 @@ else:
|
||||||
|
|
||||||
|
|
||||||
when not defined(JS):
|
when not defined(JS):
|
||||||
proc likelyProc(val: bool): bool {.importc: "likely", nodecl, nosideeffect.}
|
proc likelyProc(val: bool): bool {.importc: "NIM_LIKELY", nodecl, nosideeffect.}
|
||||||
proc unlikelyProc(val: bool): bool {.importc: "unlikely", nodecl, nosideeffect.}
|
proc unlikelyProc(val: bool): bool {.importc: "NIM_UNLIKELY", nodecl, nosideeffect.}
|
||||||
|
|
||||||
template likely*(val: bool): bool =
|
template likely*(val: bool): bool =
|
||||||
## Hints the optimizer that `val` is likely going to be true.
|
## Hints the optimizer that `val` is likely going to be true.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue