summaryrefslogtreecommitdiffstats
path: root/lua/llimits.h
diff options
context:
space:
mode:
Diffstat (limited to 'lua/llimits.h')
-rw-r--r--lua/llimits.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/lua/llimits.h b/lua/llimits.h
index 48dc81f..fc9de1a 100644
--- a/lua/llimits.h
+++ b/lua/llimits.h
@@ -1,5 +1,5 @@
/*
-** $Id: llimits.h,v 1.95 2011/12/06 16:58:36 roberto Exp $
+** $Id: llimits.h,v 1.99 2012/05/28 20:32:28 roberto Exp $
** Limits, basic types, and some other `installation-dependent' definitions
** See Copyright Notice in lua.h
*/
@@ -31,6 +31,8 @@ typedef unsigned char lu_byte;
#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
+#define MAX_LMEM ((l_mem) ((MAX_LUMEM >> 1) - 2))
+
#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
@@ -209,31 +211,36 @@ typedef lu_int32 Instruction;
#elif defined(LUA_IEEE754TRICK) /* }{ */
/* the next trick should work on any machine using IEEE754 with
- a 32-bit integer type */
+ a 32-bit int type */
union luai_Cast { double l_d; LUA_INT32 l_p[2]; };
#if !defined(LUA_IEEEENDIAN) /* { */
#define LUAI_EXTRAIEEE \
static const union luai_Cast ieeeendian = {-(33.0 + 6755399441055744.0)};
-#define LUA_IEEEENDIAN (ieeeendian.l_p[1] == 33)
+#define LUA_IEEEENDIANLOC (ieeeendian.l_p[1] == 33)
#else
+#define LUA_IEEEENDIANLOC LUA_IEEEENDIAN
#define LUAI_EXTRAIEEE /* empty */
#endif /* } */
#define lua_number2int32(i,n,t) \
{ LUAI_EXTRAIEEE \
volatile union luai_Cast u; u.l_d = (n) + 6755399441055744.0; \
- (i) = (t)u.l_p[LUA_IEEEENDIAN]; }
+ (i) = (t)u.l_p[LUA_IEEEENDIANLOC]; }
#define luai_hashnum(i,n) \
{ volatile union luai_Cast u; u.l_d = (n) + 1.0; /* avoid -0 */ \
(i) = u.l_p[0]; (i) += u.l_p[1]; } /* add double bits for his hash */
#define lua_number2int(i,n) lua_number2int32(i, n, int)
-#define lua_number2integer(i,n) lua_number2int32(i, n, lua_Integer)
#define lua_number2unsigned(i,n) lua_number2int32(i, n, lua_Unsigned)
+/* the trick can be expanded to lua_Integer when it is a 32-bit value */
+#if defined(LUA_IEEELL)
+#define lua_number2integer(i,n) lua_number2int32(i, n, lua_Integer)
+#endif
+
#endif /* } */