diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-24 11:00:16 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-24 11:00:16 -0300 |
commit | baa0e234564a5ceca4211486d1cc70be55a070a2 (patch) | |
tree | 3531beba9d415363ff80140b68c369a5646d75ff /lstate.c | |
parent | 55a710545c811f3ccb6aea6232657015f474139f (diff) | |
download | lua-baa0e234564a5ceca4211486d1cc70be55a070a2.tar.gz lua-baa0e234564a5ceca4211486d1cc70be55a070a2.tar.bz2 lua-baa0e234564a5ceca4211486d1cc70be55a070a2.zip |
better support for extra user space associated with a Lua state
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.122 2014/07/18 12:17:54 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.123 2014/07/18 13:36:14 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -53,9 +53,7 @@ | |||
53 | ** thread state + extra space | 53 | ** thread state + extra space |
54 | */ | 54 | */ |
55 | typedef struct LX { | 55 | typedef struct LX { |
56 | #if defined(LUAI_EXTRASPACE) | 56 | lu_byte extra_[LUA_EXTRASPACE]; |
57 | char buff[LUAI_EXTRASPACE]; | ||
58 | #endif | ||
59 | lua_State l; | 57 | lua_State l; |
60 | } LX; | 58 | } LX; |
61 | 59 | ||
@@ -263,6 +261,7 @@ LUA_API lua_State *lua_newthread (lua_State *L) { | |||
263 | /* link it on list 'allgc' */ | 261 | /* link it on list 'allgc' */ |
264 | L1->next = g->allgc; | 262 | L1->next = g->allgc; |
265 | g->allgc = obj2gco(L1); | 263 | g->allgc = obj2gco(L1); |
264 | /* anchor it on L stack */ | ||
266 | setthvalue(L, L->top, L1); | 265 | setthvalue(L, L->top, L1); |
267 | api_incr_top(L); | 266 | api_incr_top(L); |
268 | preinit_thread(L1, g); | 267 | preinit_thread(L1, g); |
@@ -270,6 +269,8 @@ LUA_API lua_State *lua_newthread (lua_State *L) { | |||
270 | L1->basehookcount = L->basehookcount; | 269 | L1->basehookcount = L->basehookcount; |
271 | L1->hook = L->hook; | 270 | L1->hook = L->hook; |
272 | resethookcount(L1); | 271 | resethookcount(L1); |
272 | /* initialize L1 extra space */ | ||
273 | memcpy(lua_getextraspace(L1), lua_getextraspace(L), LUA_EXTRASPACE); | ||
273 | luai_userstatethread(L, L1); | 274 | luai_userstatethread(L, L1); |
274 | stack_init(L1, L); /* init stack */ | 275 | stack_init(L1, L); /* init stack */ |
275 | lua_unlock(L); | 276 | lua_unlock(L); |