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