commit ff6c03433079c0ca7535bfdfd5cae6e90e0ae9da
parent 05afee0f50f64b64dbb4c0614ccf737ffdc06ab6
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Wed, 29 Oct 2014 15:07:20 -0200
configurations for types 'lu_mem'/'l_mem'/'Instruction' moved to here
(from 'luaconf.h'), as they are not needed by the API and probably
will not be changed
Diffstat:
M | llimits.h | | | 40 | ++++++++++++++++++++++++++-------------- |
1 file changed, 26 insertions(+), 14 deletions(-)
diff --git a/llimits.h b/llimits.h
@@ -1,5 +1,5 @@
/*
-** $Id: llimits.h,v 1.121 2014/10/25 11:50:46 roberto Exp roberto $
+** $Id: llimits.h,v 1.122 2014/10/27 16:29:58 roberto Exp roberto $
** Limits, basic types, and some other 'installation-dependent' definitions
** See Copyright Notice in lua.h
*/
@@ -14,13 +14,21 @@
#include "lua.h"
-
-typedef unsigned LUA_INT32 lu_int32;
-
+/*
+** 'lu_mem' and 'l_mem' are unsigned/signed integers big enough to count
+** the total memory used by Lua (in bytes). Usually, 'size_t' and
+** 'ptrdiff_t' should work, but we use 'long' for 16-bit machines.
+*/
+#if defined(LUAI_MEM) /* { external definitions? */
typedef LUAI_UMEM lu_mem;
-
typedef LUAI_MEM l_mem;
-
+#elif LUAI_BITSINT >= 32 /* }{ */
+typedef size_t lu_mem;
+typedef ptrdiff_t l_mem;
+#else /* 16-bit ints */ /* }{ */
+typedef unsigned long lu_mem;
+typedef long l_mem;
+#endif /* } */
/* chars used as small naturals (so that 'char' is reserved for characters) */
@@ -48,7 +56,7 @@ typedef unsigned char lu_byte;
** this is for hashing only; there is no problem if the integer
** cannot hold the whole pointer value
*/
-#define point2int(p) ((unsigned int)((lu_mem)(p) & UINT_MAX))
+#define point2int(p) ((unsigned int)((size_t)(p) & UINT_MAX))
@@ -149,10 +157,14 @@ typedef LUAI_UACINT l_uacInt;
/*
-** type for virtual-machine instructions
+** type for virtual-machine instructions;
** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
*/
-typedef lu_int32 Instruction;
+#if LUAI_BITSINT >= 32
+typedef unsigned int Instruction;
+#else
+typedef unsigned long Instruction;
+#endif
@@ -170,12 +182,12 @@ typedef lu_int32 Instruction;
#if !defined(lua_lock)
-#define lua_lock(L) ((void) 0)
-#define lua_unlock(L) ((void) 0)
+#define lua_lock(L) ((void) 0)
+#define lua_unlock(L) ((void) 0)
#endif
#if !defined(luai_threadyield)
-#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
+#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
#endif
@@ -201,11 +213,11 @@ typedef lu_int32 Instruction;
#endif
#if !defined(luai_userstateresume)
-#define luai_userstateresume(L,n) ((void)L)
+#define luai_userstateresume(L,n) ((void)L)
#endif
#if !defined(luai_userstateyield)
-#define luai_userstateyield(L,n) ((void)L)
+#define luai_userstateyield(L,n) ((void)L)
#endif