[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.4.3 (rc2) now available
- From: Andrew Gierth <andrew@...>
- Date: Mon, 15 Mar 2021 15:37:32 +0000
The use of defined(__GNUC__) alone for the conditional for
__builtin_expect is ugly; there may be non-gcc compilers that support it
too.
You could do something like:
#ifdef __has_builtin
#define luai_has_builtin(x) __has_builtin(x)
#else
#define luai_has_builtin(x) 0
#endif
#if luai_has_builtin(__builtin_expect) || (__GNUC__ >= 3)
#define luai_likely(x) (__builtin_expect(((x) != 0), 1))
#define luai_unlikely(x) (__builtin_expect(((x) != 0), 0))
#else
#define luai_likely(x) ((x) != 0)
#define luai_unlikely(x) ((x) != 0)
#endif
--
Andrew.