src/lj_state.h - luajit-2.0-src

Functions defined

Macros defined

Source code

  1. /*
  2. ** State and stack handling.
  3. ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
  4. */

  5. #ifndef _LJ_STATE_H
  6. #define _LJ_STATE_H

  7. #include "lj_obj.h"

  8. #define incr_top(L) \
  9.   (++L->top >= tvref(L->maxstack) && (lj_state_growstack1(L), 0))

  10. #define savestack(L, p)                ((char *)(p) - mref(L->stack, char))
  11. #define restorestack(L, n)        ((TValue *)(mref(L->stack, char) + (n)))

  12. LJ_FUNC void lj_state_relimitstack(lua_State *L);
  13. LJ_FUNC void lj_state_shrinkstack(lua_State *L, MSize used);
  14. LJ_FUNCA void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need);
  15. LJ_FUNC void LJ_FASTCALL lj_state_growstack1(lua_State *L);

  16. static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need)
  17. {
  18.   if ((mref(L->maxstack, char) - (char *)L->top) <=
  19.       (ptrdiff_t)need*(ptrdiff_t)sizeof(TValue))
  20.     lj_state_growstack(L, need);
  21. }

  22. LJ_FUNC lua_State *lj_state_new(lua_State *L);
  23. LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L);
  24. #if LJ_64
  25. LJ_FUNC lua_State *lj_state_newstate(lua_Alloc f, void *ud);
  26. #endif

  27. #endif