rpm  4.5
llimits.h
Go to the documentation of this file.
1 /*
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
5 */
6 
7 #ifndef llimits_h
8 #define llimits_h
9 
10 
11 #include <limits.h>
12 #include <stddef.h>
13 
14 
15 #include "lua.h"
16 
17 
18 /*
19 ** try to find number of bits in an integer
20 */
21 #ifndef BITS_INT
22 /* avoid overflows in comparison */
23 #if INT_MAX-20 < 32760
24 #define BITS_INT 16
25 #else
26 #if INT_MAX > 2147483640L
27 /* machine has at least 32 bits */
28 #define BITS_INT 32
29 #else
30 #error "you must define BITS_INT with number of bits in an integer"
31 #endif
32 #endif
33 #endif
34 
35 
36 /*
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.
41 */
42 
43 /* an unsigned integer to hold hash values */
44 typedef unsigned int lu_hash;
45 /* its signed equivalent */
46 typedef int ls_hash;
47 
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;
51 
52 #define MAX_LUMEM ULONG_MAX
53 
54 
55 /* an integer big enough to count the number of strings in use */
56 typedef long ls_nstr;
57 
58 /* chars used as small naturals (so that `char' is reserved for characters) */
59 typedef unsigned char lu_byte;
60 
61 
62 #define MAX_SIZET ((size_t)(~(size_t)0)-2)
63 
64 
65 #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
66 
67 /*
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
71 */
72 #define IntPoint(p) ((lu_hash)(p))
73 
74 
75 
76 /* type to ensure maximum alignment */
77 #ifndef LUSER_ALIGNMENT_T
78 typedef union { double u; void *s; long l; } L_Umaxalign;
79 #else
80 typedef LUSER_ALIGNMENT_T L_Umaxalign;
81 #endif
82 
83 
84 /* result of `usual argument conversion' over lua_Number */
85 #ifndef LUA_UACNUMBER
86 typedef double l_uacNumber;
87 #else
88 typedef LUA_UACNUMBER l_uacNumber;
89 #endif
90 
91 
92 #ifndef lua_assert
93 #define lua_assert(c) /* empty */
94 #endif
95 
96 
97 #ifndef check_exp
98 #define check_exp(c,e) (e)
99 #endif
100 
101 
102 #ifndef UNUSED
103 #define UNUSED(x) ((void)(x)) /* to avoid warnings */
104 #endif
105 
106 
107 #ifndef cast
108 #define cast(t, exp) ((t)(exp))
109 #endif
110 
111 
112 
113 /*
114 ** type for virtual-machine instructions
115 ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
116 */
117 typedef unsigned long Instruction;
118 
119 
120 /* maximum depth for calls (unsigned short) */
121 #ifndef LUA_MAXCALLS
122 #define LUA_MAXCALLS 4096
123 #endif
124 
125 
126 /*
127 ** maximum depth for C calls (unsigned short): Not too big, or may
128 ** overflow the C stack...
129 */
130 
131 #ifndef LUA_MAXCCALLS
132 #define LUA_MAXCCALLS 200
133 #endif
134 
135 
136 /* maximum size for the C stack */
137 #ifndef LUA_MAXCSTACK
138 #define LUA_MAXCSTACK 2048
139 #endif
140 
141 
142 /* maximum stack for a Lua function */
143 #define MAXSTACK 250
144 
145 
146 /* maximum number of variables declared in a function */
147 #ifndef MAXVARS
148 #define MAXVARS 200 /* arbitrary limit (<MAXSTACK) */
149 #endif
150 
151 
152 /* maximum number of upvalues per function */
153 #ifndef MAXUPVALUES
154 #define MAXUPVALUES 32
155 #endif
156 
157 
158 /* maximum number of parameters in a function */
159 #ifndef MAXPARAMS
160 #define MAXPARAMS 100 /* arbitrary limit (<MAXLOCALS) */
161 #endif
162 
163 
164 /* minimum size for the string table (must be power of 2) */
165 #ifndef MINSTRTABSIZE
166 #define MINSTRTABSIZE 32
167 #endif
168 
169 
170 /* minimum size for string buffer */
171 #ifndef LUA_MINBUFFER
172 #define LUA_MINBUFFER 32
173 #endif
174 
175 
176 /*
177 ** maximum number of syntactical nested non-terminals: Not too big,
178 ** or may overflow the C stack...
179 */
180 #ifndef LUA_MAXPARSERLEVEL
181 #define LUA_MAXPARSERLEVEL 200
182 #endif
183 
184 
185 #endif