aboutsummaryrefslogtreecommitdiff
path: root/luaconf.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-02-24 11:14:44 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-02-24 11:14:44 -0300
commit59c88f846d1dcd901a4420651aedf27816618923 (patch)
tree0e76a066c383cbc99cc2f60b8b4f97c5df45e479 /luaconf.h
parentc03c527fd207b4ad8f5a8e0f4f2c176bd227c979 (diff)
downloadlua-59c88f846d1dcd901a4420651aedf27816618923.tar.gz
lua-59c88f846d1dcd901a4420651aedf27816618923.tar.bz2
lua-59c88f846d1dcd901a4420651aedf27816618923.zip
Broadening the use of branch hints
More uses of macros 'likely'/'unlikely' (renamed to 'l_likely'/'l_unlikely'), both in range (extended to the libraries) and in scope (extended to hooks, stack growth).
Diffstat (limited to 'luaconf.h')
-rw-r--r--luaconf.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/luaconf.h b/luaconf.h
index a44858c4..ae73e2fd 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -660,6 +660,26 @@
660#define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) 660#define lua_getlocaledecpoint() (localeconv()->decimal_point[0])
661#endif 661#endif
662 662
663
664/*
665** macros to improve jump prediction, used mostly for error handling
666** and debug facilities.
667*/
668#if (defined(LUA_CORE) || defined(LUA_LIB)) && !defined(l_likely)
669
670#include <stdio.h>
671#if defined(__GNUC__)
672#define l_likely(x) (__builtin_expect(((x) != 0), 1))
673#define l_unlikely(x) (__builtin_expect(((x) != 0), 0))
674#else
675#define l_likely(x) (x)
676#define l_unlikely(x) (x)
677#endif
678
679#endif
680
681
682
663/* }================================================================== */ 683/* }================================================================== */
664 684
665 685