diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-06-20 13:43:33 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-06-20 13:43:33 -0300 |
commit | 55ac40f859ad8e28fe71a8801d49f4a4140e8aa3 (patch) | |
tree | 1a1f02de45d28c7eb8976087ade773d7937bed14 /llimits.h | |
parent | 97ef8e7bd40340d47a9789beb06f0128d7438d0a (diff) | |
download | lua-55ac40f859ad8e28fe71a8801d49f4a4140e8aa3.tar.gz lua-55ac40f859ad8e28fe71a8801d49f4a4140e8aa3.tar.bz2 lua-55ac40f859ad8e28fe71a8801d49f4a4140e8aa3.zip |
Cleaning of llimits.h
Several definitions that don't need to be "global" (that is, that
concerns only specific parts of the code) moved out of llimits.h,
to more appropriate places.
Diffstat (limited to 'llimits.h')
-rw-r--r-- | llimits.h | 144 |
1 files changed, 4 insertions, 140 deletions
@@ -46,15 +46,11 @@ typedef signed char ls_byte; | |||
46 | #define MAX_SIZET ((size_t)(~(size_t)0)) | 46 | #define MAX_SIZET ((size_t)(~(size_t)0)) |
47 | 47 | ||
48 | /* | 48 | /* |
49 | ** Maximum size for strings and userdata visible for Lua (should be | 49 | ** Maximum size for strings and userdata visible for Lua; should be |
50 | ** representable in a lua_Integer) | 50 | ** representable as a lua_Integer and as a size_t. |
51 | */ | 51 | */ |
52 | #define MAX_SIZE (sizeof(size_t) < sizeof(lua_Integer) ? MAX_SIZET \ | 52 | #define MAX_SIZE (sizeof(size_t) < sizeof(lua_Integer) ? MAX_SIZET \ |
53 | : (size_t)(LUA_MAXINTEGER)) | 53 | : cast_sizet(LUA_MAXINTEGER)) |
54 | |||
55 | |||
56 | #define MAX_INT INT_MAX /* maximum value of an int */ | ||
57 | |||
58 | 54 | ||
59 | /* | 55 | /* |
60 | ** floor of the log2 of the maximum signed value for integral type 't'. | 56 | ** floor of the log2 of the maximum signed value for integral type 't'. |
@@ -119,15 +115,6 @@ typedef LUAI_UACINT l_uacInt; | |||
119 | #define lua_longassert(c) ((void)0) | 115 | #define lua_longassert(c) ((void)0) |
120 | #endif | 116 | #endif |
121 | 117 | ||
122 | /* | ||
123 | ** assertion for checking API calls | ||
124 | */ | ||
125 | #if !defined(luai_apicheck) | ||
126 | #define luai_apicheck(l,e) ((void)l, lua_assert(e)) | ||
127 | #endif | ||
128 | |||
129 | #define api_check(l,e,msg) luai_apicheck(l,(e) && msg) | ||
130 | |||
131 | 118 | ||
132 | /* macro to avoid warnings about unused variables */ | 119 | /* macro to avoid warnings about unused variables */ |
133 | #if !defined(UNUSED) | 120 | #if !defined(UNUSED) |
@@ -196,8 +183,7 @@ typedef LUAI_UACINT l_uacInt; | |||
196 | 183 | ||
197 | 184 | ||
198 | /* | 185 | /* |
199 | ** type for virtual-machine instructions; | 186 | ** An unsigned with (at least) 4 bytes |
200 | ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) | ||
201 | */ | 187 | */ |
202 | #if LUAI_IS32INT | 188 | #if LUAI_IS32INT |
203 | typedef unsigned int l_uint32; | 189 | typedef unsigned int l_uint32; |
@@ -205,107 +191,6 @@ typedef unsigned int l_uint32; | |||
205 | typedef unsigned long l_uint32; | 191 | typedef unsigned long l_uint32; |
206 | #endif | 192 | #endif |
207 | 193 | ||
208 | typedef l_uint32 Instruction; | ||
209 | |||
210 | |||
211 | |||
212 | /* | ||
213 | ** Maximum length for short strings, that is, strings that are | ||
214 | ** internalized. (Cannot be smaller than reserved words or tags for | ||
215 | ** metamethods, as these strings must be internalized; | ||
216 | ** #("function") = 8, #("__newindex") = 10.) | ||
217 | */ | ||
218 | #if !defined(LUAI_MAXSHORTLEN) | ||
219 | #define LUAI_MAXSHORTLEN 40 | ||
220 | #endif | ||
221 | |||
222 | |||
223 | /* | ||
224 | ** Initial size for the string table (must be power of 2). | ||
225 | ** The Lua core alone registers ~50 strings (reserved words + | ||
226 | ** metaevent keys + a few others). Libraries would typically add | ||
227 | ** a few dozens more. | ||
228 | */ | ||
229 | #if !defined(MINSTRTABSIZE) | ||
230 | #define MINSTRTABSIZE 128 | ||
231 | #endif | ||
232 | |||
233 | |||
234 | /* | ||
235 | ** Size of cache for strings in the API. 'N' is the number of | ||
236 | ** sets (better be a prime) and "M" is the size of each set (M == 1 | ||
237 | ** makes a direct cache.) | ||
238 | */ | ||
239 | #if !defined(STRCACHE_N) | ||
240 | #define STRCACHE_N 53 | ||
241 | #define STRCACHE_M 2 | ||
242 | #endif | ||
243 | |||
244 | |||
245 | /* minimum size for string buffer */ | ||
246 | #if !defined(LUA_MINBUFFER) | ||
247 | #define LUA_MINBUFFER 32 | ||
248 | #endif | ||
249 | |||
250 | |||
251 | /* | ||
252 | ** Maximum depth for nested C calls, syntactical nested non-terminals, | ||
253 | ** and other features implemented through recursion in C. (Value must | ||
254 | ** fit in a 16-bit unsigned integer. It must also be compatible with | ||
255 | ** the size of the C stack.) | ||
256 | */ | ||
257 | #if !defined(LUAI_MAXCCALLS) | ||
258 | #define LUAI_MAXCCALLS 200 | ||
259 | #endif | ||
260 | |||
261 | |||
262 | /* | ||
263 | ** macros that are executed whenever program enters the Lua core | ||
264 | ** ('lua_lock') and leaves the core ('lua_unlock') | ||
265 | */ | ||
266 | #if !defined(lua_lock) | ||
267 | #define lua_lock(L) ((void) 0) | ||
268 | #define lua_unlock(L) ((void) 0) | ||
269 | #endif | ||
270 | |||
271 | /* | ||
272 | ** macro executed during Lua functions at points where the | ||
273 | ** function can yield. | ||
274 | */ | ||
275 | #if !defined(luai_threadyield) | ||
276 | #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} | ||
277 | #endif | ||
278 | |||
279 | |||
280 | /* | ||
281 | ** these macros allow user-specific actions when a thread is | ||
282 | ** created/deleted/resumed/yielded. | ||
283 | */ | ||
284 | #if !defined(luai_userstateopen) | ||
285 | #define luai_userstateopen(L) ((void)L) | ||
286 | #endif | ||
287 | |||
288 | #if !defined(luai_userstateclose) | ||
289 | #define luai_userstateclose(L) ((void)L) | ||
290 | #endif | ||
291 | |||
292 | #if !defined(luai_userstatethread) | ||
293 | #define luai_userstatethread(L,L1) ((void)L) | ||
294 | #endif | ||
295 | |||
296 | #if !defined(luai_userstatefree) | ||
297 | #define luai_userstatefree(L,L1) ((void)L) | ||
298 | #endif | ||
299 | |||
300 | #if !defined(luai_userstateresume) | ||
301 | #define luai_userstateresume(L,n) ((void)L) | ||
302 | #endif | ||
303 | |||
304 | #if !defined(luai_userstateyield) | ||
305 | #define luai_userstateyield(L,n) ((void)L) | ||
306 | #endif | ||
307 | |||
308 | |||
309 | 194 | ||
310 | /* | 195 | /* |
311 | ** The luai_num* macros define the primitive operations over numbers. | 196 | ** The luai_num* macros define the primitive operations over numbers. |
@@ -359,25 +244,4 @@ typedef l_uint32 Instruction; | |||
359 | #endif | 244 | #endif |
360 | 245 | ||
361 | 246 | ||
362 | |||
363 | |||
364 | |||
365 | /* | ||
366 | ** macro to control inclusion of some hard tests on stack reallocation | ||
367 | */ | ||
368 | #if !defined(HARDSTACKTESTS) | ||
369 | #define condmovestack(L,pre,pos) ((void)0) | ||
370 | #else | ||
371 | /* realloc stack keeping its size */ | ||
372 | #define condmovestack(L,pre,pos) \ | ||
373 | { int sz_ = stacksize(L); pre; luaD_reallocstack((L), sz_, 0); pos; } | ||
374 | #endif | ||
375 | |||
376 | #if !defined(HARDMEMTESTS) | ||
377 | #define condchangemem(L,pre,pos) ((void)0) | ||
378 | #else | ||
379 | #define condchangemem(L,pre,pos) \ | ||
380 | { if (gcrunning(G(L))) { pre; luaC_fullgc(L, 0); pos; } } | ||
381 | #endif | ||
382 | |||
383 | #endif | 247 | #endif |