diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-04-29 09:17:07 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-04-29 09:17:07 +0200 |
commit | 80672df530bff762047134c58c061e83ba082487 (patch) | |
tree | c18b977c62b98ac154d67927a0d2e8bc56fe5358 | |
parent | 28c7e6b487242f76cc4a945cc462612f90caee7e (diff) | |
download | lanes-3.17.0.tar.gz lanes-3.17.0.tar.bz2 lanes-3.17.0.zip |
remove uintptr_t againv3.17.0
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | src/deep.c | 4 | ||||
-rw-r--r-- | src/keeper.c | 8 | ||||
-rw-r--r-- | src/keeper.h | 6 | ||||
-rw-r--r-- | src/linda.c | 10 | ||||
-rw-r--r-- | src/uniquekey.h | 4 |
6 files changed, 20 insertions, 16 deletions
@@ -1,5 +1,9 @@ | |||
1 | CHANGES: | 1 | CHANGES: |
2 | 2 | ||
3 | CHANGE 162: BGe 29-Apr-24 | ||
4 | * remove uintptr_t again. I love optional stuff in standard headers | ||
5 | * expose nil sentinel as lanes.null | ||
6 | |||
3 | CHANGE 161: BGe 15-Apr-24 | 7 | CHANGE 161: BGe 15-Apr-24 |
4 | * fix keeper state stack accumulating garbage in case of transfer errors | 8 | * fix keeper state stack accumulating garbage in case of transfer errors |
5 | 9 | ||
@@ -236,7 +236,7 @@ char const* push_deep_proxy( Universe* U, lua_State* L, DeepPrelude* prelude, in | |||
236 | *proxy = prelude; | 236 | *proxy = prelude; |
237 | 237 | ||
238 | // Get/create metatable for 'idfunc' (in this state) | 238 | // Get/create metatable for 'idfunc' (in this state) |
239 | lua_pushlightuserdata( L, (void*)(uintptr_t)(prelude->idfunc)); // DPC proxy idfunc | 239 | lua_pushlightuserdata(L, (void*) prelude->idfunc); // DPC proxy idfunc |
240 | get_deep_lookup( L); // DPC proxy metatable? | 240 | get_deep_lookup( L); // DPC proxy metatable? |
241 | 241 | ||
242 | if( lua_isnil( L, -1)) // // No metatable yet. | 242 | 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 | |||
278 | 278 | ||
279 | // Memorize for later rounds | 279 | // Memorize for later rounds |
280 | lua_pushvalue( L, -1); // DPC proxy metatable metatable | 280 | lua_pushvalue( L, -1); // DPC proxy metatable metatable |
281 | lua_pushlightuserdata( L, (void*)(uintptr_t)(prelude->idfunc)); // DPC proxy metatable metatable idfunc | 281 | lua_pushlightuserdata(L, (void*) prelude->idfunc); // DPC proxy metatable metatable idfunc |
282 | set_deep_lookup( L); // DPC proxy metatable | 282 | set_deep_lookup( L); // DPC proxy metatable |
283 | 283 | ||
284 | // 2 - cause the target state to require the module that exported the idfunc | 284 | // 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_) | |||
189 | STACK_END( L, 1); | 189 | STACK_END( L, 1); |
190 | } | 190 | } |
191 | 191 | ||
192 | int keeper_push_linda_storage( Universe* U, lua_State* L, void* ptr_, uintptr_t magic_) | 192 | int keeper_push_linda_storage(Universe* U, lua_State* L, void* ptr_, uint_t magic_) |
193 | { | 193 | { |
194 | Keeper* const K = which_keeper( U->keepers, magic_); | 194 | Keeper* const K = which_keeper( U->keepers, magic_); |
195 | lua_State* const KL = K ? K->L : NULL; | 195 | lua_State* const KL = K ? K->L : NULL; |
@@ -731,7 +731,7 @@ void init_keepers( Universe* U, lua_State* L) | |||
731 | } | 731 | } |
732 | 732 | ||
733 | // should be called only when inside a keeper_acquire/keeper_release pair (see linda_protected_call) | 733 | // should be called only when inside a keeper_acquire/keeper_release pair (see linda_protected_call) |
734 | Keeper* which_keeper(Keepers* keepers_, uintptr_t magic_) | 734 | Keeper* which_keeper(Keepers* keepers_, uint_t magic_) |
735 | { | 735 | { |
736 | int const nbKeepers = keepers_->nb_keepers; | 736 | int const nbKeepers = keepers_->nb_keepers; |
737 | if (nbKeepers) | 737 | if (nbKeepers) |
@@ -742,7 +742,7 @@ Keeper* which_keeper(Keepers* keepers_, uintptr_t magic_) | |||
742 | return NULL; | 742 | return NULL; |
743 | } | 743 | } |
744 | 744 | ||
745 | Keeper* keeper_acquire( Keepers* keepers_, uintptr_t magic_) | 745 | Keeper* keeper_acquire(Keepers* keepers_, uint_t magic_) |
746 | { | 746 | { |
747 | int const nbKeepers = keepers_->nb_keepers; | 747 | int const nbKeepers = keepers_->nb_keepers; |
748 | // can be 0 if this happens during main state shutdown (lanes is being GC'ed -> no keepers) | 748 | // 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_) | |||
755 | * Pointers are often aligned by 8 or so - ignore the low order bits | 755 | * Pointers are often aligned by 8 or so - ignore the low order bits |
756 | * have to cast to unsigned long to avoid compilation warnings about loss of data when converting pointer-to-integer | 756 | * have to cast to unsigned long to avoid compilation warnings about loss of data when converting pointer-to-integer |
757 | */ | 757 | */ |
758 | unsigned int i = (unsigned int)((magic_ >> KEEPER_MAGIC_SHIFT) % nbKeepers); | 758 | uint_t i = (uint_t) ((magic_ >> KEEPER_MAGIC_SHIFT) % nbKeepers); |
759 | Keeper* K = &keepers_->keeper_array[i]; | 759 | Keeper* K = &keepers_->keeper_array[i]; |
760 | 760 | ||
761 | MUTEX_LOCK( &K->keeper_cs); | 761 | 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; | |||
30 | void init_keepers( Universe* U, lua_State* L); | 30 | void init_keepers( Universe* U, lua_State* L); |
31 | void close_keepers( Universe* U); | 31 | void close_keepers( Universe* U); |
32 | 32 | ||
33 | Keeper* which_keeper( Keepers* keepers_, uintptr_t magic_); | 33 | Keeper* which_keeper(Keepers* keepers_, uint_t magic_); |
34 | Keeper* keeper_acquire( Keepers* keepers_, uintptr_t magic_); | 34 | Keeper* keeper_acquire(Keepers* keepers_, uint_t magic_); |
35 | #define KEEPER_MAGIC_SHIFT 3 | 35 | #define KEEPER_MAGIC_SHIFT 3 |
36 | void keeper_release( Keeper* K_); | 36 | void keeper_release( Keeper* K_); |
37 | void keeper_toggle_nil_sentinels( lua_State* L, int val_i_, LookupMode const mode_); | 37 | void keeper_toggle_nil_sentinels( lua_State* L, int val_i_, LookupMode const mode_); |
38 | int keeper_push_linda_storage( Universe* U, lua_State* L, void* ptr_, uintptr_t magic_); | 38 | int keeper_push_linda_storage(Universe* U, lua_State* L, void* ptr_, uint_t magic_); |
39 | 39 | ||
40 | // crc64/we of string "NIL_SENTINEL" generated at http://www.nitrxgen.net/hashgen/ | 40 | // crc64/we of string "NIL_SENTINEL" generated at http://www.nitrxgen.net/hashgen/ |
41 | static DECLARE_CONST_UNIQUE_KEY( NIL_SENTINEL, 0x7eaafa003a1d11a1); | 41 | 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 | |||
52 | SIGNAL_T read_happened; | 52 | SIGNAL_T read_happened; |
53 | SIGNAL_T write_happened; | 53 | SIGNAL_T write_happened; |
54 | Universe* U; // the universe this linda belongs to | 54 | Universe* U; // the universe this linda belongs to |
55 | uintptr_t group; // a group to control keeper allocation between lindas | 55 | uint_t group; // a group to control keeper allocation between lindas |
56 | enum e_cancel_request simulate_cancel; | 56 | enum e_cancel_request simulate_cancel; |
57 | char name[1]; | 57 | char name[1]; |
58 | }; | 58 | }; |
59 | #define LINDA_KEEPER_HASHSEED( linda) (linda->group ? linda->group : (uintptr_t)linda) | 59 | #define LINDA_KEEPER_HASHSEED(linda) (linda->group ? linda->group : (uint_t)(ptrdiff_t) linda) |
60 | 60 | ||
61 | static void* linda_id( lua_State*, DeepOp); | 61 | static void* linda_id( lua_State*, DeepOp); |
62 | 62 | ||
@@ -766,7 +766,7 @@ static void* linda_id( lua_State* L, DeepOp op_) | |||
766 | struct s_Linda* s; | 766 | struct s_Linda* s; |
767 | size_t name_len = 0; | 767 | size_t name_len = 0; |
768 | char const* linda_name = NULL; | 768 | char const* linda_name = NULL; |
769 | unsigned long linda_group = 0; | 769 | uint_t linda_group = 0; |
770 | // should have a string and/or a number of the stack as parameters (name and group) | 770 | // should have a string and/or a number of the stack as parameters (name and group) |
771 | switch( lua_gettop( L)) | 771 | switch( lua_gettop( L)) |
772 | { | 772 | { |
@@ -780,13 +780,13 @@ static void* linda_id( lua_State* L, DeepOp op_) | |||
780 | } | 780 | } |
781 | else | 781 | else |
782 | { | 782 | { |
783 | linda_group = (unsigned long) lua_tointeger( L, -1); | 783 | linda_group = (uint_t) lua_tointeger(L, -1); |
784 | } | 784 | } |
785 | break; | 785 | break; |
786 | 786 | ||
787 | case 2: // 2 parameters, a name and group, in that order | 787 | case 2: // 2 parameters, a name and group, in that order |
788 | linda_name = lua_tolstring( L, -2, &name_len); | 788 | linda_name = lua_tolstring( L, -2, &name_len); |
789 | linda_group = (unsigned long) lua_tointeger( L, -1); | 789 | linda_group = (uint_t) lua_tointeger(L, -1); |
790 | break; | 790 | break; |
791 | } | 791 | } |
792 | 792 | ||
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 | |||
11 | typedef struct s_UniqueKey UniqueKey; | 11 | typedef struct s_UniqueKey UniqueKey; |
12 | 12 | ||
13 | #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 | 13 | #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 |
14 | #define MAKE_UNIQUE_KEY( p_) ((void*)((uintptr_t)(p_) & 0x7fffffffffffull)) | 14 | #define MAKE_UNIQUE_KEY(p_) ((void*) ((ptrdiff_t) (p_) &0x7fffffffffffull)) |
15 | #else // LUAJIT_FLAVOR() | 15 | #else // LUAJIT_FLAVOR() |
16 | #define MAKE_UNIQUE_KEY( p_) ((void*)(uintptr_t)(p_)) | 16 | #define MAKE_UNIQUE_KEY(p_) ((void*) (ptrdiff_t) (p_)) |
17 | #endif // LUAJIT_FLAVOR() | 17 | #endif // LUAJIT_FLAVOR() |
18 | 18 | ||
19 | #define DECLARE_UNIQUE_KEY( name_) UniqueKey name_ | 19 | #define DECLARE_UNIQUE_KEY( name_) UniqueKey name_ |