# lstate.c File Reference

`#include <stddef.h>`
`#include "lua.h"`
`#include "ldebug.h"`
`#include "ldo.h"`
`#include "lfunc.h"`
`#include "lgc.h"`
`#include "llex.h"`
`#include "lmem.h"`
`#include "lstate.h"`
`#include "lstring.h"`
`#include "ltable.h"`
`#include "ltm.h"`

## Classes
struct | LG
## Defines
#define | lstate_c
#define | LUA_CORE
#define | state_size(x) (sizeof(x) + LUAI_EXTRASPACE)
#define | fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE)
#define | tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE))
## Functions
static void | stack_init (lua_State *L1, lua_State *L)
static void | freestack (lua_State *L, lua_State *L1)
static void | f_luaopen (lua_State *L, void *ud)
static void | preinit_state (lua_State *L, global_State *g)
static void | close_state (lua_State *L)
lua_State * | luaE_newthread (lua_State *L)
void | luaE_freethread (lua_State *L, lua_State *L1)
LUA_API lua_State * | lua_newstate (lua_Alloc f, void *ud)
static void | callallgcTM (lua_State *L, void *ud)
LUA_API void | lua_close (lua_State *L)

## Define Documentation

#define fromstate | ( | l |  | ) | (cast(lu_byte *, (l)) - LUAI_EXTRASPACE)

#define lstate_c

#define LUA_CORE

#define state_size | ( | x |  | ) | (sizeof(x) + LUAI_EXTRASPACE)

#define tostate | ( | l |  | ) | (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE))

## Function Documentation

static void callallgcTM | ( | lua_State * | L,
|  | void * | ud |
| ) |  |  | `[static]`

static void close_state | ( | lua_State * | L | ) | `[static]`

static void f_luaopen | ( | lua_State * | L,
|  | void * | ud |
| ) |  |  | `[static]`

static void freestack | ( | lua_State * | L,
|  | lua_State * | L1 |
| ) |  |  | `[static]`

LUA_API void lua_close | ( | lua_State * | L | ) |

LUA_API lua_State* lua_newstate | ( | lua_Alloc | f,
|  | void * | ud |
| ) |  |  |

void luaE_freethread | ( | lua_State * | L,
|  | lua_State * | L1 |
| ) |  |  |

lua_State* luaE_newthread | ( | lua_State * | L | ) |

static void preinit_state | ( | lua_State * | L,
|  | global_State * | g |
| ) |  |  | `[static]`

static void stack_init | ( | lua_State * | L1,
|  | lua_State * | L |
| ) |  |  | `[static]`