aboutsummaryrefslogtreecommitdiff
path: root/src/lanes.c
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2022-02-21 11:30:51 +0100
committerBenoit Germain <bnt.germain@gmail.com>2022-02-21 11:30:51 +0100
commitbaf5414b853524bb20df2b92e4b4e13bb1e425cd (patch)
treef66565c529558cbc7a23cfd6e503193c8f5e7b9d /src/lanes.c
parenta147fa3aaf2a60252bd9cfd609ee7b65725d0ce8 (diff)
downloadlanes-baf5414b853524bb20df2b92e4b4e13bb1e425cd.tar.gz
lanes-baf5414b853524bb20df2b92e4b4e13bb1e425cd.tar.bz2
lanes-baf5414b853524bb20df2b92e4b4e13bb1e425cd.zip
Make allocator threadsafe by default when running LuaJIT, because LuaJIT allocator is not
Diffstat (limited to 'src/lanes.c')
-rw-r--r--src/lanes.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lanes.c b/src/lanes.c
index bf0f0a3..f702685 100644
--- a/src/lanes.c
+++ b/src/lanes.c
@@ -254,14 +254,14 @@ static void lane_cleanup( Lane* s)
254#endif // HAVE_LANE_TRACKING 254#endif // HAVE_LANE_TRACKING
255 255
256 // don't hijack the state allocator when running LuaJIT because it looks like LuaJIT does not expect it and might invalidate the memory unexpectedly 256 // don't hijack the state allocator when running LuaJIT because it looks like LuaJIT does not expect it and might invalidate the memory unexpectedly
257#if LUAJIT_FLAVOR == 0 257#if USE_LUA_STATE_ALLOCATOR
258 { 258 {
259 AllocatorDefinition* const allocD = &s->U->protected_allocator.definition; 259 AllocatorDefinition* const allocD = &s->U->protected_allocator.definition;
260 allocD->allocF(allocD->allocUD, s, sizeof(Lane), 0); 260 allocD->allocF(allocD->allocUD, s, sizeof(Lane), 0);
261 } 261 }
262#else // LUAJIT_FLAVOR 262#else // USE_LUA_STATE_ALLOCATOR
263 free(s); 263 free(s);
264#endif // LUAJIT_FLAVOR 264#endif // USE_LUA_STATE_ALLOCATOR
265} 265}
266 266
267/* 267/*
@@ -1231,14 +1231,14 @@ LUAG_FUNC( lane_new)
1231 // a Lane full userdata needs a single uservalue 1231 // a Lane full userdata needs a single uservalue
1232 ud = lua_newuserdatauv( L, sizeof( Lane*), 1); // func libs priority globals package required gc_cb lane 1232 ud = lua_newuserdatauv( L, sizeof( Lane*), 1); // func libs priority globals package required gc_cb lane
1233 // don't hijack the state allocator when running LuaJIT because it looks like LuaJIT does not expect it and might invalidate the memory unexpectedly 1233 // don't hijack the state allocator when running LuaJIT because it looks like LuaJIT does not expect it and might invalidate the memory unexpectedly
1234#if LUAJIT_FLAVOR == 0 1234#if USE_LUA_STATE_ALLOCATOR
1235 { 1235 {
1236 AllocatorDefinition* const allocD = &U->protected_allocator.definition; 1236 AllocatorDefinition* const allocD = &U->protected_allocator.definition;
1237 s = *ud = (Lane*)allocD->allocF(allocD->allocUD, NULL, 0, sizeof(Lane)); 1237 s = *ud = (Lane*)allocD->allocF(allocD->allocUD, NULL, 0, sizeof(Lane));
1238 } 1238 }
1239#else // LUAJIT_FLAVOR 1239#else // USE_LUA_STATE_ALLOCATOR
1240 s = *ud = (Lane*) malloc(sizeof(Lane)); 1240 s = *ud = (Lane*) malloc(sizeof(Lane));
1241#endif // LUAJIT_FLAVOR 1241#endif // USE_LUA_STATE_ALLOCATOR
1242 if( s == NULL) 1242 if( s == NULL)
1243 { 1243 {
1244 return luaL_error( L, "could not create lane: out of memory"); 1244 return luaL_error( L, "could not create lane: out of memory");