sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
ldo.h
Go to the documentation of this file.
1/*
2** $Id: ldo.h $
3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h
5*/
6
11#ifndef ldo_h
12#define ldo_h
13
14
15#include "llimits.h"
16#include "lobject.h"
17#include "lstate.h"
18#include "lzio.h"
19
20
21/*
22** Macro to check stack size and grow stack if needed. Parameters
23** 'pre'/'pos' allow the macro to preserve a pointer into the
24** stack across reallocations, doing the work only when needed.
25** It also allows the running of one GC step when the stack is
26** reallocated.
27** 'condmovestack' is used in heavy tests to force a stack reallocation
28** at every check.
29*/
30#define luaD_checkstackaux(L,n,pre,pos) \
31 if (l_unlikely(L->stack_last.p - L->top.p <= (n))) \
32 { pre; luaD_growstack(L, n, 1); pos; } \
33 else { condmovestack(L,pre,pos); }
34
35/* In general, 'pre'/'pos' are empty (nothing to save) */
36#define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0)
37
38
39
40#define savestack(L,pt) (cast_charp(pt) - cast_charp(L->stack.p))
41#define restorestack(L,n) cast(StkId, cast_charp(L->stack.p) + (n))
42
43
44/* macro to check stack size, preserving 'p' */
45#define checkstackp(L,n,p) \
46 luaD_checkstackaux(L, n, \
47 ptrdiff_t t__ = savestack(L, p), /* save 'p' */ \
48 p = restorestack(L, t__)) /* 'pos' part: restore 'p' */
49
50
51/* macro to check stack size and GC, preserving 'p' */
52#define checkstackGCp(L,n,p) \
53 luaD_checkstackaux(L, n, \
54 ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \
55 luaC_checkGC(L), /* stack grow uses memory */ \
56 p = restorestack(L, t__)) /* 'pos' part: restore 'p' */
57
58
59/* macro to check stack size and GC */
60#define checkstackGC(L,fsize) \
61 luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0)
62
63
64/* type of protected functions, to be ran by 'runprotected' */
65typedef void (*Pfunc) (lua_State *L, void *ud);
66
67LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
68LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
69 const char *mode);
70LUAI_FUNC void luaD_hook (lua_State *L, int event, int line,
71 int fTransfer, int nTransfer);
72LUAI_FUNC void luaD_hookcall (lua_State *L, CallInfo *ci);
73LUAI_FUNC int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func,
74 int narg1, int delta);
75LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults);
76LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
77LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults);
78LUAI_FUNC StkId luaD_tryfuncTM (lua_State *L, StkId func);
79LUAI_FUNC int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status);
80LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
81 ptrdiff_t oldtop, ptrdiff_t ef);
82LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, int nres);
83LUAI_FUNC int luaD_reallocstack (lua_State *L, int newsize, int raiseerror);
84LUAI_FUNC int luaD_growstack (lua_State *L, int n, int raiseerror);
85LUAI_FUNC void luaD_shrinkstack (lua_State *L);
86LUAI_FUNC void luaD_inctop (lua_State *L);
87
88LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
89LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
90
91#endif
92