diff --git a/llimits.h b/llimits.h index c6b5b479..b7459533 100644 --- a/llimits.h +++ b/llimits.h @@ -1,5 +1,5 @@ /* -** $Id: llimits.h,v 1.76 2009/12/17 12:26:09 roberto Exp roberto $ +** $Id: llimits.h,v 1.77 2009/12/17 12:50:20 roberto Exp roberto $ ** Limits, basic types, and some other `installation-dependent' definitions ** See Copyright Notice in lua.h */ @@ -139,19 +139,19 @@ typedef lu_int32 Instruction; ** created/deleted/resumed/yielded. */ #if !defined(luai_userstateopen) -#define luai_userstateopen(L) ((void)L) +#define luai_userstateopen(L) ((void)L) #endif #if !defined(luai_userstateclose) -#define luai_userstateclose(L) ((void)L) +#define luai_userstateclose(L) ((void)L) #endif #if !defined(luai_userstatethread) -#define luai_userstatethread(L,L1) ((void)L) +#define luai_userstatethread(L,L1) ((void)L) #endif #if !defined(luai_userstatefree) -#define luai_userstatefree(L) ((void)L) +#define luai_userstatefree(L,L1) ((void)L) #endif #if !defined(luai_userstateresume) diff --git a/lstate.c b/lstate.c index 462b7db8..c3aaeaf5 100644 --- a/lstate.c +++ b/lstate.c @@ -1,5 +1,5 @@ /* -** $Id: lstate.c,v 2.80 2010/04/14 15:14:21 roberto Exp roberto $ +** $Id: lstate.c,v 2.81 2010/04/19 16:34:46 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -192,14 +192,13 @@ LUA_API lua_State *lua_newthread (lua_State *L) { setthvalue(L, L->top, L1); api_incr_top(L); preinit_state(L1, G(L)); - stack_init(L1, L); /* init stack */ L1->hookmask = L->hookmask; L1->basehookcount = L->basehookcount; L1->hook = L->hook; resethookcount(L1); - lua_assert(iswhite(obj2gco(L1))); - lua_unlock(L); luai_userstatethread(L, L1); + stack_init(L1, L); /* init stack */ + lua_unlock(L); return L1; } @@ -208,7 +207,7 @@ void luaE_freethread (lua_State *L, lua_State *L1) { LX *l = fromstate(L1); luaF_close(L1, L1->stack); /* close all upvalues for this thread */ lua_assert(L1->openupval == NULL); - luai_userstatefree(L1); + luai_userstatefree(L, L1); freestack(L1); luaM_free(L, l); } diff --git a/ltests.h b/ltests.h index 27dd9836..73676f64 100644 --- a/ltests.h +++ b/ltests.h @@ -1,5 +1,5 @@ /* -** $Id: ltests.h,v 2.30 2010/01/11 17:33:09 roberto Exp roberto $ +** $Id: ltests.h,v 2.31 2010/04/12 16:07:29 roberto Exp roberto $ ** Internal Header for Debugging of the Lua Implementation ** See Copyright Notice in lua.h */ @@ -62,6 +62,8 @@ struct L_EXTRA { int lock; int *plock; }; #define luai_userstateopen(l) \ (getlock(l)->lock = 0, getlock(l)->plock = &(getlock(l)->lock)) #define luai_userstatethread(l,l1) (getlock(l1)->plock = getlock(l)->plock) +#define luai_userstatefree(l,l1) \ + lua_assert(getlock(l)->plock == getlock(l1)->plock) #define lua_lock(l) lua_assert((*getlock(l)->plock)++ == 0) #define lua_unlock(l) lua_assert(--(*getlock(l)->plock) == 0)