Merge pull request #2672 from kitsunehunter/laundry-keys
[RRG-proxmark3.git] / client / deps / liblua / ldo.h
blobaeb24fe45e71a32edc0e0b6e0ac90df024420a0a
1 /*
2 ** $Id: ldo.h $
3 ** Stack and Call structure of Lua
4 ** See Copyright Notice in lua.h
5 */
7 #ifndef ldo_h
8 #define ldo_h
11 #include "llimits.h"
12 #include "lobject.h"
13 #include "lstate.h"
14 #include "lzio.h"
18 ** Macro to check stack size and grow stack if needed. Parameters
19 ** 'pre'/'pos' allow the macro to preserve a pointer into the
20 ** stack across reallocations, doing the work only when needed.
21 ** It also allows the running of one GC step when the stack is
22 ** reallocated.
23 ** 'condmovestack' is used in heavy tests to force a stack reallocation
24 ** at every check.
26 #define luaD_checkstackaux(L,n,pre,pos) \
27 if (l_unlikely(L->stack_last.p - L->top.p <= (n))) \
28 { pre; luaD_growstack(L, n, 1); pos; } \
29 else { condmovestack(L,pre,pos); }
31 /* In general, 'pre'/'pos' are empty (nothing to save) */
32 #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0)
36 #define savestack(L,pt) (cast_charp(pt) - cast_charp(L->stack.p))
37 #define restorestack(L,n) cast(StkId, cast_charp(L->stack.p) + (n))
40 /* macro to check stack size, preserving 'p' */
41 #define checkstackp(L,n,p) \
42 luaD_checkstackaux(L, n, \
43 ptrdiff_t t__ = savestack(L, p), /* save 'p' */ \
44 p = restorestack(L, t__)) /* 'pos' part: restore 'p' */
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' */
55 /* macro to check stack size and GC */
56 #define checkstackGC(L,fsize) \
57 luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0)
60 /* type of protected functions, to be ran by 'runprotected' */
61 typedef void (*Pfunc)(lua_State *L, void *ud);
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,
65 const char *mode);
66 LUAI_FUNC void luaD_hook(lua_State *L, int event, int line,
67 int fTransfer, int nTransfer);
68 LUAI_FUNC void luaD_hookcall(lua_State *L, CallInfo *ci);
69 LUAI_FUNC int luaD_pretailcall(lua_State *L, CallInfo *ci, StkId func,
70 int narg1, int delta);
71 LUAI_FUNC CallInfo *luaD_precall(lua_State *L, StkId func, int nResults);
72 LUAI_FUNC void luaD_call(lua_State *L, StkId func, int nResults);
73 LUAI_FUNC void luaD_callnoyield(lua_State *L, StkId func, int nResults);
74 LUAI_FUNC int luaD_closeprotected(lua_State *L, ptrdiff_t level, int status);
75 LUAI_FUNC int luaD_pcall(lua_State *L, Pfunc func, void *u,
76 ptrdiff_t oldtop, ptrdiff_t ef);
77 LUAI_FUNC void luaD_poscall(lua_State *L, CallInfo *ci, int nres);
78 LUAI_FUNC int luaD_reallocstack(lua_State *L, int newsize, int raiseerror);
79 LUAI_FUNC int luaD_growstack(lua_State *L, int n, int raiseerror);
80 LUAI_FUNC void luaD_shrinkstack(lua_State *L);
81 LUAI_FUNC void luaD_inctop(lua_State *L);
83 LUAI_FUNC l_noret luaD_throw(lua_State *L, int errcode);
84 LUAI_FUNC int luaD_rawrunprotected(lua_State *L, Pfunc f, void *ud);
86 #endif