aboutsummaryrefslogtreecommitdiff
path: root/lstate.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-11-01 17:14:01 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-11-01 17:14:01 -0300
commit9ede317c70ad82279f2e3962eb52904a17bf4b55 (patch)
treee2d60bac0e987fe2cb6da54222765a90414f3d2a /lstate.c
parentee645472ebe153e2c6669c84a632297a8110bdb6 (diff)
downloadlua-9ede317c70ad82279f2e3962eb52904a17bf4b55.tar.gz
lua-9ede317c70ad82279f2e3962eb52904a17bf4b55.tar.bz2
lua-9ede317c70ad82279f2e3962eb52904a17bf4b55.zip
Threads are created like other objects
Using a version of 'luaC_newobj' that allows offsets (extra space before the object itself).
Diffstat (limited to 'lstate.c')
-rw-r--r--lstate.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/lstate.c b/lstate.c
index c63fe867..1fbefb4b 100644
--- a/lstate.c
+++ b/lstate.c
@@ -284,18 +284,14 @@ static void close_state (lua_State *L) {
284 284
285 285
286LUA_API lua_State *lua_newthread (lua_State *L) { 286LUA_API lua_State *lua_newthread (lua_State *L) {
287 global_State *g; 287 global_State *g = G(L);
288 GCObject *o;
288 lua_State *L1; 289 lua_State *L1;
289 lua_lock(L); 290 lua_lock(L);
290 g = G(L);
291 luaC_checkGC(L); 291 luaC_checkGC(L);
292 /* create new thread */ 292 /* create new thread */
293 L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; 293 o = luaC_newobjdt(L, LUA_TTHREAD, sizeof(LX), offsetof(LX, l));
294 L1->marked = luaC_white(g); 294 L1 = gco2th(o);
295 L1->tt = LUA_VTHREAD;
296 /* link it on list 'allgc' */
297 L1->next = g->allgc;
298 g->allgc = obj2gco(L1);
299 /* anchor it on L stack */ 295 /* anchor it on L stack */
300 setthvalue2s(L, L->top.p, L1); 296 setthvalue2s(L, L->top.p, L1);
301 api_incr_top(L); 297 api_incr_top(L);