summaryrefslogtreecommitdiff
path: root/lib/lua/includes/llimits.h
diff options
context:
space:
mode:
authorpixel <pixel>2007-07-27 10:05:52 +0000
committerpixel <pixel>2007-07-27 10:05:52 +0000
commit6c1ab7da376ae7f78a075dda5c5be0dabce20931 (patch)
treebc44e447c450c96140cf6b63c39a37afa8ba61fb /lib/lua/includes/llimits.h
parenta68385b1043a2041390f65ce5cf9ed434af5e95d (diff)
Upgrading to Lua-5.1.2
Diffstat (limited to 'lib/lua/includes/llimits.h')
-rw-r--r--lib/lua/includes/llimits.h144
1 files changed, 46 insertions, 98 deletions
diff --git a/lib/lua/includes/llimits.h b/lib/lua/includes/llimits.h
index e5f18a9..9b48bcd 100644
--- a/lib/lua/includes/llimits.h
+++ b/lib/lua/includes/llimits.h
@@ -1,5 +1,5 @@
/*
-** $Id: llimits.h,v 1.4 2004-11-27 21:46:06 pixel Exp $
+** $Id: llimits.h,v 1.5 2007-07-27 10:05:53 pixel Exp $
** Limits, basic types, and some other `installation-dependent' definitions
** See Copyright Notice in lua.h
*/
@@ -15,45 +15,13 @@
#include "lua.h"
-/*
-** try to find number of bits in an integer
-*/
-#ifndef BITS_INT
-/* avoid overflows in comparison */
-#if INT_MAX-20 < 32760
-#define BITS_INT 16
-#else
-#if INT_MAX > 2147483640L
-/* machine has at least 32 bits */
-#define BITS_INT 32
-#else
-#error "you must define BITS_INT with number of bits in an integer"
-#endif
-#endif
-#endif
+typedef LUAI_UINT32 lu_int32;
+typedef LUAI_UMEM lu_mem;
-/*
-** the following types define integer types for values that may not
-** fit in a `small int' (16 bits), but may waste space in a
-** `large long' (64 bits). The current definitions should work in
-** any machine, but may not be optimal.
-*/
-
-/* an unsigned integer to hold hash values */
-typedef unsigned int lu_hash;
-/* its signed equivalent */
-typedef int ls_hash;
+typedef LUAI_MEM l_mem;
-/* an unsigned integer big enough to count the total memory used by Lua; */
-/* it should be at least as large as size_t */
-typedef unsigned long lu_mem;
-#define MAX_LUMEM ULONG_MAX
-
-
-/* an integer big enough to count the number of strings in use */
-typedef long ls_nstr;
/* chars used as small naturals (so that `char' is reserved for characters) */
typedef unsigned char lu_byte;
@@ -61,6 +29,8 @@ typedef unsigned char lu_byte;
#define MAX_SIZET ((size_t)(~(size_t)0)-2)
+#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
+
#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
@@ -69,33 +39,30 @@ typedef unsigned char lu_byte;
** this is for hashing only; there is no problem if the integer
** cannot hold the whole pointer value
*/
-#define IntPoint(p) ((lu_hash)(p))
+#define IntPoint(p) ((unsigned int)(lu_mem)(p))
/* type to ensure maximum alignment */
-#ifndef LUSER_ALIGNMENT_T
-typedef union { double u; void *s; long l; } L_Umaxalign;
-#else
-typedef LUSER_ALIGNMENT_T L_Umaxalign;
-#endif
+typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
-/* result of `usual argument conversion' over lua_Number */
-#ifndef LUA_UACNUMBER
-typedef double l_uacNumber;
-#else
-typedef LUA_UACNUMBER l_uacNumber;
-#endif
+/* result of a `usual argument conversion' over lua_Number */
+typedef LUAI_UACNUMBER l_uacNumber;
-#ifndef lua_assert
-#define lua_assert(c) /* empty */
-#endif
+/* internal assertions for in-house debugging */
+#ifdef lua_assert
+
+#define check_exp(c,e) (lua_assert(c), (e))
+#define api_check(l,e) lua_assert(e)
+#else
+
+#define lua_assert(c) ((void)0)
+#define check_exp(c,e) (e)
+#define api_check luai_apicheck
-#ifndef check_exp
-#define check_exp(c,e) (e)
#endif
@@ -108,58 +75,24 @@ typedef LUA_UACNUMBER l_uacNumber;
#define cast(t, exp) ((t)(exp))
#endif
+#define cast_byte(i) cast(lu_byte, (i))
+#define cast_num(i) cast(lua_Number, (i))
+#define cast_int(i) cast(int, (i))
+
/*
** type for virtual-machine instructions
** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
*/
-typedef unsigned long Instruction;
-
+typedef lu_int32 Instruction;
-/* maximum depth for calls (unsigned short) */
-#ifndef LUA_MAXCALLS
-#define LUA_MAXCALLS 4096
-#endif
-
-
-/*
-** maximum depth for C calls (unsigned short): Not too big, or may
-** overflow the C stack...
-*/
-
-#ifndef LUA_MAXCCALLS
-#define LUA_MAXCCALLS 200
-#endif
-
-
-/* maximum size for the C stack */
-#ifndef LUA_MAXCSTACK
-#define LUA_MAXCSTACK 2048
-#endif
/* maximum stack for a Lua function */
#define MAXSTACK 250
-/* maximum number of variables declared in a function */
-#ifndef MAXVARS
-#define MAXVARS 200 /* arbitrary limit (<MAXSTACK) */
-#endif
-
-
-/* maximum number of upvalues per function */
-#ifndef MAXUPVALUES
-#define MAXUPVALUES 32
-#endif
-
-
-/* maximum number of parameters in a function */
-#ifndef MAXPARAMS
-#define MAXPARAMS 100 /* arbitrary limit (<MAXLOCALS) */
-#endif
-
/* minimum size for the string table (must be power of 2) */
#ifndef MINSTRTABSIZE
@@ -172,14 +105,29 @@ typedef unsigned long Instruction;
#define LUA_MINBUFFER 32
#endif
+void do_lua_lock(lua_State *);
+void do_lua_unlock(lua_State *);
-/*
-** maximum number of syntactical nested non-terminals: Not too big,
-** or may overflow the C stack...
-*/
-#ifndef LUA_MAXPARSERLEVEL
-#define LUA_MAXPARSERLEVEL 200
+#ifndef lua_lock
+#define lua_lock(L) do_lua_lock(L);
+#endif
+
+#ifndef lua_unlock
+#define lua_unlock(L) do_lua_unlock(L);
#endif
+#ifndef luai_threadyield
+#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
+#endif
+
+
+/*
+** macro to control inclusion of some hard tests on stack reallocation
+*/
+#ifndef HARDSTACKTESTS
+#define condhardstacktests(x) ((void)0)
+#else
+#define condhardstacktests(x) x
+#endif
#endif