diff options
| -rw-r--r-- | lstate.c | 9 | ||||
| -rw-r--r-- | ltests.h | 11 | ||||
| -rw-r--r-- | lua.h | 4 | ||||
| -rw-r--r-- | luaconf.h | 10 |
4 files changed, 23 insertions, 11 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); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.h,v 2.36 2014/07/23 16:47:47 roberto Exp roberto $ | 2 | ** $Id: ltests.h,v 2.37 2014/07/23 17:16:50 roberto Exp roberto $ |
| 3 | ** Internal Header for Debugging of the Lua Implementation | 3 | ** Internal Header for Debugging of the Lua Implementation |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -64,14 +64,15 @@ int lua_checkmemory (lua_State *L); | |||
| 64 | /* test for lock/unlock */ | 64 | /* test for lock/unlock */ |
| 65 | 65 | ||
| 66 | struct L_EXTRA { int lock; int *plock; }; | 66 | struct L_EXTRA { int lock; int *plock; }; |
| 67 | /* extra space before a Lua state (+1 to make it unaligned) */ | 67 | #undef LUA_EXTRASPACE |
| 68 | #define LUAI_EXTRASPACE (sizeof(struct L_EXTRA) + 1) | 68 | #define LUA_EXTRASPACE sizeof(struct L_EXTRA) |
| 69 | #define getlock(l) (cast(struct L_EXTRA *, l) - 1) | 69 | #define getlock(l) cast(struct L_EXTRA*, lua_getextraspace(l)) |
| 70 | #define luai_userstateopen(l) \ | 70 | #define luai_userstateopen(l) \ |
| 71 | (getlock(l)->lock = 0, getlock(l)->plock = &(getlock(l)->lock)) | 71 | (getlock(l)->lock = 0, getlock(l)->plock = &(getlock(l)->lock)) |
| 72 | #define luai_userstateclose(l) \ | 72 | #define luai_userstateclose(l) \ |
| 73 | lua_assert(getlock(l)->lock == 1 && getlock(l)->plock == &(getlock(l)->lock)) | 73 | lua_assert(getlock(l)->lock == 1 && getlock(l)->plock == &(getlock(l)->lock)) |
| 74 | #define luai_userstatethread(l,l1) (getlock(l1)->plock = getlock(l)->plock) | 74 | #define luai_userstatethread(l,l1) \ |
| 75 | lua_assert(getlock(l1)->plock == getlock(l)->plock) | ||
| 75 | #define luai_userstatefree(l,l1) \ | 76 | #define luai_userstatefree(l,l1) \ |
| 76 | lua_assert(getlock(l)->plock == getlock(l1)->plock) | 77 | lua_assert(getlock(l)->plock == getlock(l1)->plock) |
| 77 | #define lua_lock(l) lua_assert((*getlock(l)->plock)++ == 0) | 78 | #define lua_lock(l) lua_assert((*getlock(l)->plock)++ == 0) |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.h,v 1.309 2014/07/17 13:53:37 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.310 2014/07/22 18:07:47 roberto Exp roberto $ |
| 3 | ** Lua - A Scripting Language | 3 | ** Lua - A Scripting Language |
| 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) | 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) |
| 5 | ** See Copyright Notice at the end of this file | 5 | ** See Copyright Notice at the end of this file |
| @@ -332,6 +332,8 @@ LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); | |||
| 332 | ** =============================================================== | 332 | ** =============================================================== |
| 333 | */ | 333 | */ |
| 334 | 334 | ||
| 335 | #define lua_getextraspace(L) ((void *)((char *)(L) - LUA_EXTRASPACE)) | ||
| 336 | |||
| 335 | #define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL) | 337 | #define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL) |
| 336 | #define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL) | 338 | #define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL) |
| 337 | 339 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: luaconf.h,v 1.209 2014/06/26 18:30:27 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.210 2014/07/17 13:53:37 roberto Exp roberto $ |
| 3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -211,6 +211,14 @@ | |||
| 211 | 211 | ||
| 212 | 212 | ||
| 213 | /* | 213 | /* |
| 214 | @@ LUA_EXTRASPACE defines the size of a raw memory area associated with | ||
| 215 | ** a Lua state with very fast access. | ||
| 216 | ** CHANGE it if you need a different size. | ||
| 217 | */ | ||
| 218 | #define LUA_EXTRASPACE (sizeof(void *)) | ||
| 219 | |||
| 220 | |||
| 221 | /* | ||
| 214 | @@ LUA_QL describes how error messages quote program elements. | 222 | @@ LUA_QL describes how error messages quote program elements. |
| 215 | ** CHANGE it if you want a different appearance. | 223 | ** CHANGE it if you want a different appearance. |
| 216 | */ | 224 | */ |
