2 ** $Id: llimits.h,v 1.52 2003/02/20 19:33:23 roberto Exp $
3 ** Limits, basic types, and some other `installation-dependent' definitions
4 ** See Copyright Notice in lua.h
19 ** try to find number of bits in an integer
22 /* avoid overflows in comparison */
23 #if INT_MAX-20 < 32760
26 #if INT_MAX > 2147483640L
27 /* machine has at least 32 bits */
30 #error "you must define BITS_INT with number of bits in an integer"
37 ** the following types define integer types for values that may not
38 ** fit in a `small int' (16 bits), but may waste space in a
39 ** `large long' (64 bits). The current definitions should work in
40 ** any machine, but may not be optimal.
43 /* an unsigned integer to hold hash values */
44 typedef unsigned int lu_hash;
45 /* its signed equivalent */
48 /* an unsigned integer big enough to count the total memory used by Lua; */
49 /* it should be at least as large as size_t */
50 typedef unsigned long lu_mem;
52 #define MAX_LUMEM ULONG_MAX
55 /* an integer big enough to count the number of strings in use */
58 /* chars used as small naturals (so that `char' is reserved for characters) */
59 typedef unsigned char lu_byte;
62 #define MAX_SIZET ((size_t)(~(size_t)0)-2)
65 #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
68 ** conversion of pointer to integer
69 ** this is for hashing only; there is no problem if the integer
70 ** cannot hold the whole pointer value
72 #define IntPoint(p) ((lu_hash)(p))
76 /* type to ensure maximum alignment */
77 #ifndef LUSER_ALIGNMENT_T
78 typedef union { double u; void *s; long l; } L_Umaxalign;
80 typedef LUSER_ALIGNMENT_T L_Umaxalign;
84 /* result of `usual argument conversion' over lua_Number */
86 typedef double l_uacNumber;
88 typedef LUA_UACNUMBER l_uacNumber;
93 #define lua_assert(c) /* empty */
98 #define check_exp(c,e) (e)
103 #define UNUSED(x) ((void)(x)) /* to avoid warnings */
108 #define cast(t, exp) ((t)(exp))
114 ** type for virtual-machine instructions
115 ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
117 typedef unsigned long Instruction;
120 /* maximum depth for calls (unsigned short) */
122 #define LUA_MAXCALLS 4096
127 ** maximum depth for C calls (unsigned short): Not too big, or may
128 ** overflow the C stack...
131 #ifndef LUA_MAXCCALLS
132 #define LUA_MAXCCALLS 200
136 /* maximum size for the C stack */
137 #ifndef LUA_MAXCSTACK
138 #define LUA_MAXCSTACK 2048
142 /* maximum stack for a Lua function */
146 /* maximum number of variables declared in a function */
148 #define MAXVARS 200 /* arbitrary limit (<MAXSTACK) */
152 /* maximum number of upvalues per function */
154 #define MAXUPVALUES 32
158 /* maximum number of parameters in a function */
160 #define MAXPARAMS 100 /* arbitrary limit (<MAXLOCALS) */
164 /* minimum size for the string table (must be power of 2) */
165 #ifndef MINSTRTABSIZE
166 #define MINSTRTABSIZE 32
170 /* minimum size for string buffer */
171 #ifndef LUA_MINBUFFER
172 #define LUA_MINBUFFER 32
177 ** maximum number of syntactical nested non-terminals: Not too big,
178 ** or may overflow the C stack...
180 #ifndef LUA_MAXPARSERLEVEL
181 #define LUA_MAXPARSERLEVEL 200