xref: /freebsd/sys/contrib/openzfs/module/lua/ldo.h (revision c03c5b1c)
1*eda14cbcSMatt Macy /*
2*eda14cbcSMatt Macy ** $Id: ldo.h,v 2.20.1.1 2013/04/12 18:48:47 roberto Exp $
3*eda14cbcSMatt Macy ** Stack and Call structure of Lua
4*eda14cbcSMatt Macy ** See Copyright Notice in lua.h
5*eda14cbcSMatt Macy */
6*eda14cbcSMatt Macy 
7*eda14cbcSMatt Macy #ifndef ldo_h
8*eda14cbcSMatt Macy #define ldo_h
9*eda14cbcSMatt Macy 
10*eda14cbcSMatt Macy 
11*eda14cbcSMatt Macy #include "lobject.h"
12*eda14cbcSMatt Macy #include "lstate.h"
13*eda14cbcSMatt Macy #include "lzio.h"
14*eda14cbcSMatt Macy 
15*eda14cbcSMatt Macy 
16*eda14cbcSMatt Macy #define luaD_checkstack(L,n)	if (L->stack_last - L->top <= (n)) \
17*eda14cbcSMatt Macy 				    luaD_growstack(L, n); else condmovestack(L);
18*eda14cbcSMatt Macy 
19*eda14cbcSMatt Macy 
20*eda14cbcSMatt Macy #define incr_top(L) {L->top++; luaD_checkstack(L,0);}
21*eda14cbcSMatt Macy 
22*eda14cbcSMatt Macy #define savestack(L,p)		((char *)(p) - (char *)L->stack)
23*eda14cbcSMatt Macy #define restorestack(L,n)	((TValue *)((char *)L->stack + (n)))
24*eda14cbcSMatt Macy 
25*eda14cbcSMatt Macy 
26*eda14cbcSMatt Macy /* type of protected functions, to be ran by `runprotected' */
27*eda14cbcSMatt Macy typedef void (*Pfunc) (lua_State *L, void *ud);
28*eda14cbcSMatt Macy 
29*eda14cbcSMatt Macy LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
30*eda14cbcSMatt Macy                                                   const char *mode);
31*eda14cbcSMatt Macy LUAI_FUNC void luaD_hook (lua_State *L, int event, int line);
32*eda14cbcSMatt Macy LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
33*eda14cbcSMatt Macy LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults,
34*eda14cbcSMatt Macy                                         int allowyield);
35*eda14cbcSMatt Macy LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
36*eda14cbcSMatt Macy                                         ptrdiff_t oldtop, ptrdiff_t ef);
37*eda14cbcSMatt Macy LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
38*eda14cbcSMatt Macy LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
39*eda14cbcSMatt Macy LUAI_FUNC void luaD_growstack (lua_State *L, int n);
40*eda14cbcSMatt Macy LUAI_FUNC void luaD_shrinkstack (lua_State *L);
41*eda14cbcSMatt Macy 
42*eda14cbcSMatt Macy LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
43*eda14cbcSMatt Macy LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
44*eda14cbcSMatt Macy 
45*eda14cbcSMatt Macy #endif
46