diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2008-02-11 17:17:19 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2008-02-11 17:17:19 -0200 |
commit | aec671c126ab32c22adae30c8f8084b0191cd2fb (patch) | |
tree | 50cb3024af3e7f22857883a4cbf56bdb5e379229 | |
parent | dd92af69db1f829cb6b9690026509a803e311ad0 (diff) | |
download | lua-aec671c126ab32c22adae30c8f8084b0191cd2fb.tar.gz lua-aec671c126ab32c22adae30c8f8084b0191cd2fb.tar.bz2 lua-aec671c126ab32c22adae30c8f8084b0191cd2fb.zip |
maximum C stack should reserve some values for pseudo-indices
-rw-r--r-- | luaconf.h | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.94 2008/01/02 16:36:19 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.95 2008/01/17 16:24:38 roberto Exp roberto $ |
3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -411,12 +411,20 @@ | |||
411 | /* | 411 | /* |
412 | @@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function | 412 | @@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function |
413 | @* can use. | 413 | @* can use. |
414 | ** CHANGE it if you need lots of (Lua) stack space for your C | 414 | ** CHANGE it if you need a different limit. This limit is arbitrary; |
415 | ** functions. This limit is arbitrary; its only purpose is to stop C | 415 | ** its only purpose is to stop C functions to consume unlimited stack |
416 | ** functions to consume unlimited stack space. | 416 | ** space. |
417 | */ | 417 | */ |
418 | #define LUAI_MCS_AUX ((int)(INT_MAX / (4*sizeof(LUA_NUMBER)))) | 418 | /* life is simpler if stack size fits in an int (16 is an estimate |
419 | #define LUAI_MAXCSTACK (LUAI_MCS_AUX > SHRT_MAX ? SHRT_MAX : LUAI_MCS_AUX) | 419 | for the size of a Lua value) */ |
420 | #if SHRT_MAX < (INT_MAX / 16) | ||
421 | #define LUAI_MCS_AUX SHRT_MAX | ||
422 | #else | ||
423 | #define LUAI_MCS_AUX (INT_MAX / 16) | ||
424 | #endif | ||
425 | |||
426 | /* reserve some space for pseudo-indices */ | ||
427 | #define LUAI_MAXCSTACK (LUAI_MCS_AUX - 1000) | ||
420 | 428 | ||
421 | 429 | ||
422 | 430 | ||