# lua/lstate.h File Reference

`#include "lua.h"`
`#include "lobject.h"`
`#include "ltm.h"`
`#include "lzio.h"`

Include dependency graph for lstate.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | stringtable
struct | CallInfo
struct | global_State
struct | lua_State
union | GCObject

## Defines

#define | gt(L) (&L->l_gt)
#define | registry(L) (&G(L)->l_registry)
#define | EXTRA_STACK 5
#define | BASIC_CI_SIZE 8
#define | BASIC_STACK_SIZE (2*LUA_MINSTACK)
#define | curr_func(L) (clvalue(L->ci->func))
#define | ci_func(ci) (clvalue((ci)->func))
#define | f_isLua(ci) (!ci_func(ci)->c.isC)
#define | isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci))
#define | G(L) (L->l_G)
#define | rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts))
#define | gco2ts(o) (&rawgco2ts(o)->tsv)
#define | rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
#define | gco2u(o) (&rawgco2u(o)->uv)
#define | gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl))
#define | gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
#define | gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
#define | gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
#define | ngcotouv(o) check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv))
#define | gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
#define | obj2gco(v) (cast(GCObject *, (v)))

## Functions

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

## Define Documentation

#define BASIC_CI_SIZE 8

Definition at line 32 of file lstate.h.

Referenced by stack_init().

#define BASIC_STACK_SIZE (2*LUA_MINSTACK)

Definition at line 34 of file lstate.h.

Referenced by checkstacksizes(), and stack_init().

#define ci_func | ( | ci |  | ) | (clvalue((ci)->func))

Definition at line 60 of file lstate.h.

Referenced by currentline(), currentpc(), getfuncname(), getluaproto(), getobjname(), and traceexec().

#define curr_func | ( | L |  | ) | (clvalue(L->ci->func))

Definition at line 59 of file lstate.h.

Referenced by getcurrenv(), index2adr(), lua_replace(), and luaD_precall().

#define EXTRA_STACK 5

Definition at line 29 of file lstate.h.

Referenced by checkstacksizes(), luaD_reallocstack(), restore_stack_limit(), and stack_init().

#define f_isLua | ( | ci |  | ) | (!ci_func(ci)->c.isC)

Definition at line 61 of file lstate.h.

Referenced by callrethooks(), lua_getstack(), and resume().

#define G | ( | L |  | ) | (L->l_G)

Definition at line 129 of file lstate.h.

Referenced by atomic(), checkSizes(), close_state(), f_luaopen(), freeobj(), GCTM(), lua_atpanic(), lua_close(), lua_gc(), lua_getallocf(), lua_getmetatable(), lua_pushthread(), lua_setallocf(), lua_setmetatable(), lua_xmove(), luaC_barrierback(), luaC_barrierf(), luaC_callGCTM(), luaC_freeall(), luaC_fullgc(), luaC_link(), luaC_linkupval(), luaC_separateudata(), luaC_step(), luaD_throw(), luaE_newthread(), luaF_close(), luaF_findupval(), luaM_realloc_(), luaS_newlstr(), luaS_newudata(), luaS_resize(), luaT_gettmbyobj(), luaT_init(), luaV_concat(), markroot(), newlstr(), preinit_state(), singlestep(), and sweeplist().

#define gco2cl | ( | o |  | ) | check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl))

Definition at line 152 of file lstate.h.

Referenced by freeobj(), propagatemark(), and reallymarkobject().

#define gco2h | ( | o |  | ) | check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))

Definition at line 153 of file lstate.h.

Referenced by cleartable(), freeobj(), propagatemark(), and reallymarkobject().

#define gco2p | ( | o |  | ) | check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))

Definition at line 154 of file lstate.h.

Referenced by freeobj(), propagatemark(), and reallymarkobject().

#define gco2th | ( | o |  | ) | check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))

Definition at line 158 of file lstate.h.

Referenced by freeobj(), propagatemark(), reallymarkobject(), and sweeplist().

#define gco2ts | ( | o |  | ) | (&rawgco2ts(o)->tsv)

Definition at line 149 of file lstate.h.

Referenced by freeobj(), and luaS_resize().

#define gco2u | ( | o |  | ) | (&rawgco2u(o)->uv)

Definition at line 151 of file lstate.h.

Referenced by freeobj(), luaC_separateudata(), and reallymarkobject().

#define gco2uv | ( | o |  | ) | check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))

Definition at line 155 of file lstate.h.

Referenced by correctstack(), freeobj(), and reallymarkobject().

#define gt | ( | L |  | ) | (&L->l_gt)

Definition at line 22 of file lstate.h.

Referenced by f_luaopen(), f_parser(), getcurrenv(), index2adr(), lua_getfenv(), lua_setfenv(), luaE_newthread(), markroot(), preinit_state(), and traversestack().

#define isLua | ( | ci |  | ) | (ttisfunction((ci)->func) && f_isLua(ci))

Definition at line 62 of file lstate.h.

Referenced by addinfo(), currentpc(), getfuncname(), getluaproto(), getobjname(), and luaV_execute().

#define ngcotouv | ( | o |  | ) | check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv))

Definition at line 156 of file lstate.h.

Referenced by luaF_close(), and luaF_findupval().

#define obj2gco | ( | v |  | ) | (cast(GCObject *, (v)))

Definition at line 161 of file lstate.h.

Referenced by adjust_varargs(), atomic(), close_state(), lua_newstate(), lua_pushcclosure(), luaC_barrierback(), luaC_linkupval(), luaE_newthread(), luaF_close(), luaF_findupval(), luaF_newCclosure(), luaF_newLclosure(), luaF_newproto(), luaF_newupval(), luaH_new(), luaS_newudata(), newlstr(), remarkupvals(), and traversetable().

#define rawgco2ts | ( | o |  | ) | check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts))

Definition at line 148 of file lstate.h.

Referenced by luaS_newlstr().

#define rawgco2u | ( | o |  | ) | check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))

Definition at line 150 of file lstate.h.

Referenced by GCTM().

#define registry | ( | L |  | ) | (&G(L)->l_registry)

Definition at line 25 of file lstate.h.

Referenced by f_luaopen(), index2adr(), lua_newstate(), and markroot().

## Function Documentation

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

Definition at line 134 of file lstate.c.

References freestack(), fromstate, lua_assert, luaF_close(), luaM_freemem, lua_State::openupval, lua_State::stack, and state_size.

Referenced by freeobj().

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

Definition at line 119 of file lstate.c.

References lua_State::basehookcount, G, gt, lua_State::hook, lua_State::hookmask, iswhite, lua_assert, luaC_link(), luaM_malloc, obj2gco, preinit_state(), resethookcount, setobj2n, stack_init(), state_size, and tostate.

Referenced by lua_newthread().