diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-07-01 10:57:02 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-07-01 10:57:02 -0300 |
commit | 59a1adf194efe43741c2bb2005d93d8320a19d14 (patch) | |
tree | 4b65f62e0b6fa8701608c776b27b65e283dc9d0b /ldo.c | |
parent | cfce6f4b20afe85ede2182b3df3ab2bfcdb0e692 (diff) | |
download | lua-59a1adf194efe43741c2bb2005d93d8320a19d14.tar.gz lua-59a1adf194efe43741c2bb2005d93d8320a19d14.tar.bz2 lua-59a1adf194efe43741c2bb2005d93d8320a19d14.zip |
LUAI_MAXSTACK defined privately
LUAI_MAXSTACK is limited to INT_MAX/2, so can use INT_MAX/2 to define
pseudo-indices (LUA_REGISTRYINDEX) in 'lua.h'. A change in the maximum
stack size does not need to change the Lua-C ABI.
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -174,6 +174,20 @@ TStatus luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { | |||
174 | #define STACKERRSPACE 200 | 174 | #define STACKERRSPACE 200 |
175 | 175 | ||
176 | 176 | ||
177 | /* | ||
178 | ** LUAI_MAXSTACK limits the size of the Lua stack. | ||
179 | ** It must fit into INT_MAX/2. | ||
180 | */ | ||
181 | |||
182 | #if !defined(LUAI_MAXSTACK) | ||
183 | #if 1000000 < (INT_MAX / 2) | ||
184 | #define LUAI_MAXSTACK 1000000 | ||
185 | #else | ||
186 | #define LUAI_MAXSTACK (INT_MAX / 2u) | ||
187 | #endif | ||
188 | #endif | ||
189 | |||
190 | |||
177 | /* maximum stack size that respects size_t */ | 191 | /* maximum stack size that respects size_t */ |
178 | #define MAXSTACK_BYSIZET ((MAX_SIZET / sizeof(StackValue)) - STACKERRSPACE) | 192 | #define MAXSTACK_BYSIZET ((MAX_SIZET / sizeof(StackValue)) - STACKERRSPACE) |
179 | 193 | ||