LuaJIT/src/lj_state.h

38 lines
1.2 KiB
C
Raw Normal View History

2009-12-08 10:46:35 -08:00
/*
** State and stack handling.
2022-01-15 10:30:54 -08:00
** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h
2009-12-08 10:46:35 -08:00
*/
#ifndef _LJ_STATE_H
#define _LJ_STATE_H
#include "lj_obj.h"
#define incr_top(L) \
(++L->top >= tvref(L->maxstack) && (lj_state_growstack1(L), 0))
2009-12-08 10:46:35 -08:00
#define savestack(L, p) ((char *)(p) - mref(L->stack, char))
#define restorestack(L, n) ((TValue *)(mref(L->stack, char) + (n)))
2009-12-08 10:46:35 -08:00
LJ_FUNC void lj_state_relimitstack(lua_State *L);
LJ_FUNC void lj_state_shrinkstack(lua_State *L, MSize used);
LJ_FUNCA void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need);
LJ_FUNC void LJ_FASTCALL lj_state_growstack1(lua_State *L);
2009-12-08 10:46:35 -08:00
static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need)
{
if ((mref(L->maxstack, char) - (char *)L->top) <=
2011-08-10 06:24:43 -07:00
(ptrdiff_t)need*(ptrdiff_t)sizeof(TValue))
2009-12-08 10:46:35 -08:00
lj_state_growstack(L, need);
}
LJ_FUNC lua_State *lj_state_new(lua_State *L);
LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L);
2016-11-19 11:53:31 -08:00
#if LJ_64 && !LJ_GC64 && !(defined(LUAJIT_USE_VALGRIND) && defined(LUAJIT_USE_SYSMALLOC))
LJ_FUNC lua_State *lj_state_newstate(lua_Alloc f, void *ud);
#endif
2009-12-08 10:46:35 -08:00
#define LJ_ALLOCF_INTERNAL ((lua_Alloc)(void *)(uintptr_t)(1237<<4))
2009-12-08 10:46:35 -08:00
#endif