summaryrefslogtreecommitdiff
path: root/llimits.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-05-30 11:25:52 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-05-30 11:25:52 -0300
commit34aa0c5bd7493b6e01983df28f04af46a3d99967 (patch)
treeeb58cf48a015be8b9b9c0b3f8c1da14d39f8a065 /llimits.h
parent97e394ba1805fbe394a5704de660403901559e54 (diff)
downloadlua-github-34aa0c5bd7493b6e01983df28f04af46a3d99967.tar.gz
new macros 'likely'/'unlikely' with hints for jump predictions
(used only in errors for now)
Diffstat (limited to 'llimits.h')
-rw-r--r--llimits.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/llimits.h b/llimits.h
index 9a3ae8d0..725d7c8b 100644
--- a/llimits.h
+++ b/llimits.h
@@ -1,5 +1,5 @@
/*
-** $Id: llimits.h,v 1.148 2017/12/28 11:51:00 roberto Exp roberto $
+** $Id: llimits.h,v 1.149 2018/01/28 15:13:26 roberto Exp roberto $
** Limits, basic types, and some other 'installation-dependent' definitions
** See Copyright Notice in lua.h
*/
@@ -131,8 +131,26 @@ typedef LUAI_UACINT l_uacInt;
/*
+** macros to improve jump prediction (used mainly for error handling)
+*/
+#if !defined(likely)
+
+#if defined(__GNUC__)
+#define likely(x) (__builtin_expect(((x) != 0), 1))
+#define unlikely(x) (__builtin_expect(((x) != 0), 0))
+#else
+#define likely(x) (x)
+#define unlikely(x) (x)
+#endif
+
+#endif
+
+
+/*
** non-return type
*/
+#if !defined(l_noret)
+
#if defined(__GNUC__)
#define l_noret void __attribute__((noreturn))
#elif defined(_MSC_VER) && _MSC_VER >= 1200
@@ -141,6 +159,7 @@ typedef LUAI_UACINT l_uacInt;
#define l_noret void
#endif
+#endif
/*