From 80672df530bff762047134c58c061e83ba082487 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 29 Apr 2024 09:17:07 +0200 Subject: remove uintptr_t again --- src/deep.c | 4 ++-- src/keeper.c | 8 ++++---- src/keeper.h | 6 +++--- src/linda.c | 10 +++++----- src/uniquekey.h | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/deep.c b/src/deep.c index a1f078a..f3e6fd3 100644 --- a/src/deep.c +++ b/src/deep.c @@ -236,7 +236,7 @@ char const* push_deep_proxy( Universe* U, lua_State* L, DeepPrelude* prelude, in *proxy = prelude; // Get/create metatable for 'idfunc' (in this state) - lua_pushlightuserdata( L, (void*)(uintptr_t)(prelude->idfunc)); // DPC proxy idfunc + lua_pushlightuserdata(L, (void*) prelude->idfunc); // DPC proxy idfunc get_deep_lookup( L); // DPC proxy metatable? if( lua_isnil( L, -1)) // // No metatable yet. @@ -278,7 +278,7 @@ char const* push_deep_proxy( Universe* U, lua_State* L, DeepPrelude* prelude, in // Memorize for later rounds lua_pushvalue( L, -1); // DPC proxy metatable metatable - lua_pushlightuserdata( L, (void*)(uintptr_t)(prelude->idfunc)); // DPC proxy metatable metatable idfunc + lua_pushlightuserdata(L, (void*) prelude->idfunc); // DPC proxy metatable metatable idfunc set_deep_lookup( L); // DPC proxy metatable // 2 - cause the target state to require the module that exported the idfunc diff --git a/src/keeper.c b/src/keeper.c index 1522718..2a966ef 100644 --- a/src/keeper.c +++ b/src/keeper.c @@ -189,7 +189,7 @@ static void push_table( lua_State* L, int idx_) STACK_END( L, 1); } -int keeper_push_linda_storage( Universe* U, lua_State* L, void* ptr_, uintptr_t magic_) +int keeper_push_linda_storage(Universe* U, lua_State* L, void* ptr_, uint_t magic_) { Keeper* const K = which_keeper( U->keepers, magic_); lua_State* const KL = K ? K->L : NULL; @@ -731,7 +731,7 @@ void init_keepers( Universe* U, lua_State* L) } // should be called only when inside a keeper_acquire/keeper_release pair (see linda_protected_call) -Keeper* which_keeper(Keepers* keepers_, uintptr_t magic_) +Keeper* which_keeper(Keepers* keepers_, uint_t magic_) { int const nbKeepers = keepers_->nb_keepers; if (nbKeepers) @@ -742,7 +742,7 @@ Keeper* which_keeper(Keepers* keepers_, uintptr_t magic_) return NULL; } -Keeper* keeper_acquire( Keepers* keepers_, uintptr_t magic_) +Keeper* keeper_acquire(Keepers* keepers_, uint_t magic_) { int const nbKeepers = keepers_->nb_keepers; // can be 0 if this happens during main state shutdown (lanes is being GC'ed -> no keepers) @@ -755,7 +755,7 @@ Keeper* keeper_acquire( Keepers* keepers_, uintptr_t magic_) * Pointers are often aligned by 8 or so - ignore the low order bits * have to cast to unsigned long to avoid compilation warnings about loss of data when converting pointer-to-integer */ - unsigned int i = (unsigned int)((magic_ >> KEEPER_MAGIC_SHIFT) % nbKeepers); + uint_t i = (uint_t) ((magic_ >> KEEPER_MAGIC_SHIFT) % nbKeepers); Keeper* K = &keepers_->keeper_array[i]; MUTEX_LOCK( &K->keeper_cs); diff --git a/src/keeper.h b/src/keeper.h index 7c55809..7e3bde8 100644 --- a/src/keeper.h +++ b/src/keeper.h @@ -30,12 +30,12 @@ typedef struct s_Keepers Keepers; void init_keepers( Universe* U, lua_State* L); void close_keepers( Universe* U); -Keeper* which_keeper( Keepers* keepers_, uintptr_t magic_); -Keeper* keeper_acquire( Keepers* keepers_, uintptr_t magic_); +Keeper* which_keeper(Keepers* keepers_, uint_t magic_); +Keeper* keeper_acquire(Keepers* keepers_, uint_t magic_); #define KEEPER_MAGIC_SHIFT 3 void keeper_release( Keeper* K_); void keeper_toggle_nil_sentinels( lua_State* L, int val_i_, LookupMode const mode_); -int keeper_push_linda_storage( Universe* U, lua_State* L, void* ptr_, uintptr_t magic_); +int keeper_push_linda_storage(Universe* U, lua_State* L, void* ptr_, uint_t magic_); // crc64/we of string "NIL_SENTINEL" generated at http://www.nitrxgen.net/hashgen/ static DECLARE_CONST_UNIQUE_KEY( NIL_SENTINEL, 0x7eaafa003a1d11a1); diff --git a/src/linda.c b/src/linda.c index d92f5f2..3e189f2 100644 --- a/src/linda.c +++ b/src/linda.c @@ -52,11 +52,11 @@ struct s_Linda SIGNAL_T read_happened; SIGNAL_T write_happened; Universe* U; // the universe this linda belongs to - uintptr_t group; // a group to control keeper allocation between lindas + uint_t group; // a group to control keeper allocation between lindas enum e_cancel_request simulate_cancel; char name[1]; }; -#define LINDA_KEEPER_HASHSEED( linda) (linda->group ? linda->group : (uintptr_t)linda) +#define LINDA_KEEPER_HASHSEED(linda) (linda->group ? linda->group : (uint_t)(ptrdiff_t) linda) static void* linda_id( lua_State*, DeepOp); @@ -766,7 +766,7 @@ static void* linda_id( lua_State* L, DeepOp op_) struct s_Linda* s; size_t name_len = 0; char const* linda_name = NULL; - unsigned long linda_group = 0; + uint_t linda_group = 0; // should have a string and/or a number of the stack as parameters (name and group) switch( lua_gettop( L)) { @@ -780,13 +780,13 @@ static void* linda_id( lua_State* L, DeepOp op_) } else { - linda_group = (unsigned long) lua_tointeger( L, -1); + linda_group = (uint_t) lua_tointeger(L, -1); } break; case 2: // 2 parameters, a name and group, in that order linda_name = lua_tolstring( L, -2, &name_len); - linda_group = (unsigned long) lua_tointeger( L, -1); + linda_group = (uint_t) lua_tointeger(L, -1); break; } diff --git a/src/uniquekey.h b/src/uniquekey.h index 7162753..c6a24a2 100644 --- a/src/uniquekey.h +++ b/src/uniquekey.h @@ -11,9 +11,9 @@ struct s_UniqueKey typedef struct s_UniqueKey UniqueKey; #if LUAJIT_FLAVOR() == 64 // building against LuaJIT headers for 64 bits, light userdata is restricted to 47 significant bits, because LuaJIT uses the other bits for internal optimizations -#define MAKE_UNIQUE_KEY( p_) ((void*)((uintptr_t)(p_) & 0x7fffffffffffull)) +#define MAKE_UNIQUE_KEY(p_) ((void*) ((ptrdiff_t) (p_) &0x7fffffffffffull)) #else // LUAJIT_FLAVOR() -#define MAKE_UNIQUE_KEY( p_) ((void*)(uintptr_t)(p_)) +#define MAKE_UNIQUE_KEY(p_) ((void*) (ptrdiff_t) (p_)) #endif // LUAJIT_FLAVOR() #define DECLARE_UNIQUE_KEY( name_) UniqueKey name_ -- cgit v1.2.3-55-g6feb