Uses of "likely" in macros active to all users

The use of 'l_likely' in auxlib macros 'luaL_argcheck' and
'luaL_argexpected' should not be restricted to Lua's own code.
For that, 'l_likely' was renamed to 'luai_likely' to be exported
to external code.
This commit is contained in:
Roberto Ierusalimschy
2021-03-09 12:50:59 -03:00
parent 511d53a826
commit a7b8b27dd3
2 changed files with 15 additions and 12 deletions

View File

@@ -665,20 +665,26 @@
** macros to improve jump prediction, used mostly for error handling
** and debug facilities.
*/
#if (defined(LUA_CORE) || defined(LUA_LIB)) && !defined(l_likely)
#if !defined(luai_likely)
#include <stdio.h>
#if defined(__GNUC__)
#define l_likely(x) (__builtin_expect(((x) != 0), 1))
#define l_unlikely(x) (__builtin_expect(((x) != 0), 0))
#define luai_likely(x) (__builtin_expect(((x) != 0), 1))
#define luai_unlikely(x) (__builtin_expect(((x) != 0), 0))
#else
#define l_likely(x) (x)
#define l_unlikely(x) (x)
#define luai_likely(x) (x)
#define luai_unlikely(x) (x)
#endif
#endif
#if defined(LUA_CORE) || defined(LUA_LIB)
/* shorter names for Lua's own use */
#define l_likely(x) luai_likely(x)
#define l_unlikely(x) luai_unlikely(x)
#endif
/* }================================================================== */