2323** 'condmovestack' is used in heavy tests to force a stack reallocation
2424** at every check.
2525*/
26+
27+ #if !defined(HARDSTACKTESTS )
28+ #define condmovestack (L ,pre ,pos ) ((void)0)
29+ #else
30+ /* realloc stack keeping its size */
31+ #define condmovestack (L ,pre ,pos ) \
32+ { int sz_ = stacksize(L); pre; luaD_reallocstack((L), sz_, 0); pos; }
33+ #endif
34+
2635#define luaD_checkstackaux (L ,n ,pre ,pos ) \
2736 if (l_unlikely(L->stack_last.p - L->top.p <= (n))) \
2837 { pre; luaD_growstack(L, n, 1); pos; } \
29- else { condmovestack(L,pre,pos); }
38+ else { condmovestack(L,pre,pos); }
3039
3140/* In general, 'pre'/'pos' are empty (nothing to save) */
3241#define luaD_checkstack (L ,n ) luaD_checkstackaux(L,n,(void)0,(void)0)
4453 p = restorestack(L, t__)) /* 'pos' part: restore 'p' */
4554
4655
47- /* macro to check stack size and GC, preserving 'p' */
48- #define checkstackGCp (L ,n ,p ) \
49- luaD_checkstackaux(L, n, \
50- ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \
51- luaC_checkGC (L ), /* stack grow uses memory */ \
52- p = restorestack (L , t__ )) /* 'pos' part: restore 'p' */
53-
54-
55- /* macro to check stack size and GC */
56- #define checkstackGC (L ,fsize ) \
57- luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0)
56+ /*
57+ ** Maximum depth for nested C calls, syntactical nested non-terminals,
58+ ** and other features implemented through recursion in C. (Value must
59+ ** fit in a 16-bit unsigned integer. It must also be compatible with
60+ ** the size of the C stack.)
61+ */
62+ #if !defined(LUAI_MAXCCALLS )
63+ #define LUAI_MAXCCALLS 200
64+ #endif
5865
5966
6067/* type of protected functions, to be ran by 'runprotected' */
6168typedef void (* Pfunc ) (lua_State * L , void * ud );
6269
63- LUAI_FUNC void luaD_seterrorobj (lua_State * L , int errcode , StkId oldtop );
64- LUAI_FUNC int luaD_protectedparser (lua_State * L , ZIO * z , const char * name ,
70+ LUAI_FUNC l_noret luaD_errerr (lua_State * L );
71+ LUAI_FUNC void luaD_seterrorobj (lua_State * L , TStatus errcode , StkId oldtop );
72+ LUAI_FUNC TStatus luaD_protectedparser (lua_State * L , ZIO * z ,
73+ const char * name ,
6574 const char * mode );
6675LUAI_FUNC void luaD_hook (lua_State * L , int event , int line ,
6776 int fTransfer , int nTransfer );
@@ -71,18 +80,19 @@ LUAI_FUNC int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func,
7180LUAI_FUNC CallInfo * luaD_precall (lua_State * L , StkId func , int nResults );
7281LUAI_FUNC void luaD_call (lua_State * L , StkId func , int nResults );
7382LUAI_FUNC void luaD_callnoyield (lua_State * L , StkId func , int nResults );
74- LUAI_FUNC StkId luaD_tryfuncTM (lua_State * L , StkId func );
75- LUAI_FUNC int luaD_closeprotected ( lua_State * L , ptrdiff_t level , int status );
76- LUAI_FUNC int luaD_pcall (lua_State * L , Pfunc func , void * u ,
83+ LUAI_FUNC TStatus luaD_closeprotected (lua_State * L , ptrdiff_t level ,
84+ TStatus status );
85+ LUAI_FUNC TStatus luaD_pcall (lua_State * L , Pfunc func , void * u ,
7786 ptrdiff_t oldtop , ptrdiff_t ef );
7887LUAI_FUNC void luaD_poscall (lua_State * L , CallInfo * ci , int nres );
7988LUAI_FUNC int luaD_reallocstack (lua_State * L , int newsize , int raiseerror );
8089LUAI_FUNC int luaD_growstack (lua_State * L , int n , int raiseerror );
8190LUAI_FUNC void luaD_shrinkstack (lua_State * L );
8291LUAI_FUNC void luaD_inctop (lua_State * L );
8392
84- LUAI_FUNC l_noret luaD_throw (lua_State * L , int errcode );
85- LUAI_FUNC int luaD_rawrunprotected (lua_State * L , Pfunc f , void * ud );
93+ LUAI_FUNC l_noret luaD_throw (lua_State * L , TStatus errcode );
94+ LUAI_FUNC l_noret luaD_throwbaselevel (lua_State * L , TStatus errcode );
95+ LUAI_FUNC TStatus luaD_rawrunprotected (lua_State * L , Pfunc f , void * ud );
8696
8797#endif
8898
0 commit comments