From f7245f66295752306ee58c1a9be0ed01b653e347 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Wed, 16 Aug 2023 09:59:15 +0200 Subject: Minor tweaks --- lanes-3.16.0-0.rockspec | 78 ------------------------------------------------- lanes-3.16.1-0.rockspec | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ src/keeper.c | 2 +- src/lanes.c | 6 ++-- src/linda.c | 6 ++-- src/state.c | 2 +- src/tools.c | 5 ++-- tests/basic.lua | 2 +- tests/linda_perf.lua | 2 -- 9 files changed, 89 insertions(+), 92 deletions(-) delete mode 100644 lanes-3.16.0-0.rockspec create mode 100644 lanes-3.16.1-0.rockspec diff --git a/lanes-3.16.0-0.rockspec b/lanes-3.16.0-0.rockspec deleted file mode 100644 index 55bbfb4..0000000 --- a/lanes-3.16.0-0.rockspec +++ /dev/null @@ -1,78 +0,0 @@ --- --- Lanes rockspec --- --- Ref: --- --- - -package = "Lanes" - -version = "3.16.0-0" - -source= { - url= "git+https://github.com/LuaLanes/lanes.git", - branch= "v3.16.0" -} - -description = { - summary= "Multithreading support for Lua", - detailed= [[ - Lua Lanes is a portable, message passing multithreading library - providing the possibility to run multiple Lua states in parallel. - ]], - license= "MIT/X11", - homepage="https://github.com/LuaLanes/lanes", - maintainer="Benoit Germain " -} - --- Q: What is the difference of "windows" and "win32"? Seems there is none; --- so should we list either one or both? --- -supported_platforms= { "win32", - "macosx", - "linux", - "freebsd", -- TBD: not tested - "msys", -- TBD: not supported by LuaRocks 1.0 (or is it?) -} - -dependencies= { - "lua >= 5.1", -- builds with either 5.1, 5.2, 5.3 and 5.4 -} - -build = { - type = "builtin", - platforms = - { - linux = - { - modules = - { - ["lanes.core"] = - { - libraries = "pthread" - }, - } - } - }, - modules = - { - ["lanes.core"] = - { - sources = - { - "src/cancel.c", - "src/compat.c", - "src/deep.c", - "src/keeper.c", - "src/lanes.c", - "src/linda.c", - "src/tools.c", - "src/state.c", - "src/threading.c", - "src/universe.c" - }, - incdirs = { "src"}, - }, - lanes = "src/lanes.lua" - } -} diff --git a/lanes-3.16.1-0.rockspec b/lanes-3.16.1-0.rockspec new file mode 100644 index 0000000..65115a1 --- /dev/null +++ b/lanes-3.16.1-0.rockspec @@ -0,0 +1,78 @@ +-- +-- Lanes rockspec +-- +-- Ref: +-- +-- + +package = "Lanes" + +version = "3.16.1-0" + +source= { + url= "git+https://github.com/LuaLanes/lanes.git", + branch= "v3.16.1" +} + +description = { + summary= "Multithreading support for Lua", + detailed= [[ + Lua Lanes is a portable, message passing multithreading library + providing the possibility to run multiple Lua states in parallel. + ]], + license= "MIT/X11", + homepage="https://github.com/LuaLanes/lanes", + maintainer="Benoit Germain " +} + +-- Q: What is the difference of "windows" and "win32"? Seems there is none; +-- so should we list either one or both? +-- +supported_platforms= { "win32", + "macosx", + "linux", + "freebsd", -- TBD: not tested + "msys", -- TBD: not supported by LuaRocks 1.0 (or is it?) +} + +dependencies= { + "lua >= 5.1", -- builds with either 5.1, 5.2, 5.3 and 5.4 +} + +build = { + type = "builtin", + platforms = + { + linux = + { + modules = + { + ["lanes.core"] = + { + libraries = "pthread" + }, + } + } + }, + modules = + { + ["lanes.core"] = + { + sources = + { + "src/cancel.c", + "src/compat.c", + "src/deep.c", + "src/keeper.c", + "src/lanes.c", + "src/linda.c", + "src/tools.c", + "src/state.c", + "src/threading.c", + "src/universe.c" + }, + incdirs = { "src"}, + }, + lanes = "src/lanes.lua" + } +} diff --git a/src/keeper.c b/src/keeper.c index f4dde0a..8aa734a 100644 --- a/src/keeper.c +++ b/src/keeper.c @@ -612,7 +612,7 @@ void close_keepers( Universe* U) // free the keeper bookkeeping structure { AllocatorDefinition* const allocD = &U->internal_allocator; - allocD->allocF( allocD->allocUD, U->keepers, sizeof( Keepers) + (nbKeepers - 1) * sizeof( Keeper), 0); + (void) allocD->allocF( allocD->allocUD, U->keepers, sizeof( Keepers) + (nbKeepers - 1) * sizeof( Keeper), 0); U->keepers = NULL; } } diff --git a/src/lanes.c b/src/lanes.c index 0aab244..d2c95ee 100644 --- a/src/lanes.c +++ b/src/lanes.c @@ -255,7 +255,7 @@ static void lane_cleanup( Lane* s) { AllocatorDefinition* const allocD = &s->U->internal_allocator; - allocD->allocF(allocD->allocUD, s, sizeof(Lane), 0); + (void) allocD->allocF(allocD->allocUD, s, sizeof(Lane), 0); } } @@ -1225,10 +1225,10 @@ LUAG_FUNC( lane_new) // 's' is allocated from heap, not Lua, since its life span may surpass the handle's (if free running thread) // // a Lane full userdata needs a single uservalue - ud = lua_newuserdatauv( L, sizeof( Lane*), 1); // func libs priority globals package required gc_cb lane + ud = lua_newuserdatauv( L, sizeof( Lane*), 1); // func libs priority globals package required gc_cb lane { AllocatorDefinition* const allocD = &U->internal_allocator; - s = *ud = (Lane*)allocD->allocF(allocD->allocUD, NULL, 0, sizeof(Lane)); + s = *ud = (Lane*) allocD->allocF(allocD->allocUD, NULL, 0, sizeof(Lane)); } if( s == NULL) { diff --git a/src/linda.c b/src/linda.c index 390816b..8b59790 100644 --- a/src/linda.c +++ b/src/linda.c @@ -797,8 +797,7 @@ static void* linda_id( lua_State* L, DeepOp op_) { Universe* const U = universe_get(L); AllocatorDefinition* const allocD = &U->internal_allocator; - - s = (struct s_Linda*)allocD->allocF(allocD->allocUD, NULL, 0, sizeof(struct s_Linda) + name_len); // terminating 0 is already included + s = (struct s_Linda*) allocD->allocF(allocD->allocUD, NULL, 0, sizeof(struct s_Linda) + name_len); // terminating 0 is already included } if( s) { @@ -835,8 +834,7 @@ static void* linda_id( lua_State* L, DeepOp op_) { Universe* const U = universe_get(L); AllocatorDefinition* const allocD = &U->internal_allocator; - - allocD->allocF(allocD->allocUD, linda, sizeof(struct s_Linda) + strlen(linda->name), 0); + (void) allocD->allocF(allocD->allocUD, linda, sizeof(struct s_Linda) + strlen(linda->name), 0); } return NULL; } diff --git a/src/state.c b/src/state.c index ef70842..21ca397 100644 --- a/src/state.c +++ b/src/state.c @@ -259,7 +259,7 @@ lua_State* create_state( Universe* U, lua_State* from_) lua_pushcclosure( from_, U->provide_allocator, 0); lua_call( from_, 0, 1); { - AllocatorDefinition* def = lua_touserdata( from_, -1); + AllocatorDefinition* const def = lua_touserdata( from_, -1); L = lua_newstate( def->allocF, def->allocUD); } lua_pop( from_, 1); diff --git a/src/tools.c b/src/tools.c index 5a6ae92..80e0f71 100644 --- a/src/tools.c +++ b/src/tools.c @@ -155,6 +155,7 @@ void luaG_dump( lua_State* L) // ################################################################################################ +// same as PUC-Lua l_alloc static void* libc_lua_Alloc(void* ud, void* ptr, size_t osize, size_t nsize) { (void)ud; (void)osize; /* not used */ @@ -182,7 +183,7 @@ static void* protected_lua_Alloc( void *ud, void *ptr, size_t osize, size_t nsiz static int luaG_provide_protected_allocator( lua_State* L) { Universe* U = universe_get( L); - AllocatorDefinition* def = lua_newuserdatauv( L, sizeof(AllocatorDefinition), 0); + AllocatorDefinition* const def = lua_newuserdatauv( L, sizeof(AllocatorDefinition), 0); def->allocF = protected_lua_Alloc; def->allocUD = &U->protected_allocator; return 1; @@ -236,7 +237,7 @@ void initialize_allocator_function( Universe* U, lua_State* L) lua_getfield( L, -1, "internal_allocator"); // settings "libc"|"allocator" { char const* allocator = lua_tostring( L, -1); - if (stricmp(allocator, "libc") == 0) + if (strcmp(allocator, "libc") == 0) { U->internal_allocator.allocF = libc_lua_Alloc; U->internal_allocator.allocUD = NULL; diff --git a/tests/basic.lua b/tests/basic.lua index 7bbcbb3..385e22f 100644 --- a/tests/basic.lua +++ b/tests/basic.lua @@ -7,7 +7,7 @@ -- - ... -- -local require_lanes_result_1, require_lanes_result_2 = require "lanes".configure{ with_timers = false} +local require_lanes_result_1, require_lanes_result_2 = require "lanes".configure{ with_timers = false, internal_allocator = "libc"} print( "require_lanes_result:", require_lanes_result_1, require_lanes_result_2) local lanes = require_lanes_result_1 diff --git a/tests/linda_perf.lua b/tests/linda_perf.lua index fa2d633..a170b01 100644 --- a/tests/linda_perf.lua +++ b/tests/linda_perf.lua @@ -78,7 +78,6 @@ end local tests1 = { - --[[ { 10000, 2000000, 0}, { 10000, 2000000, 1}, { 10000, 2000000, 2}, @@ -88,7 +87,6 @@ local tests1 = { 10000, 2000000, 13}, { 10000, 2000000, 21}, { 10000, 2000000, 44}, - --]] } print "############################################\ntests #1" for k, v in pairs( tests1) do -- cgit v1.2.3-55-g6feb