diff options
author | Benoit Germain <b n t DOT g e r m a i n AT g m a i l DOT c o m> | 2018-10-30 14:18:10 +0100 |
---|---|---|
committer | Benoit Germain <b n t DOT g e r m a i n AT g m a i l DOT c o m> | 2018-10-30 14:18:10 +0100 |
commit | d82bf70e9db3a25ec451b599660f3a837f21caee (patch) | |
tree | e9e861252a118c8c66e874fedb93c2a32733aa0f /src/universe.c | |
parent | ea9e8a3af1c2357c454ef18c8136c14a22b8675a (diff) | |
download | lanes-d82bf70e9db3a25ec451b599660f3a837f21caee.tar.gz lanes-d82bf70e9db3a25ec451b599660f3a837f21caee.tar.bz2 lanes-d82bf70e9db3a25ec451b599660f3a837f21caee.zip |
Improve LuaJIT-x64 compatibility
Restrict internal "light userdata constants" to 47 significant bits when
compiling against LuaJIT-x64
Diffstat (limited to '')
-rw-r--r-- | src/universe.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/universe.c b/src/universe.c index 8bcdcfe..ca94930 100644 --- a/src/universe.c +++ b/src/universe.c | |||
@@ -31,9 +31,10 @@ THE SOFTWARE. | |||
31 | #include "universe.h" | 31 | #include "universe.h" |
32 | #include "compat.h" | 32 | #include "compat.h" |
33 | #include "macros_and_utils.h" | 33 | #include "macros_and_utils.h" |
34 | #include "uniquekey.h" | ||
34 | 35 | ||
35 | // crc64/we of string "UNIVERSE_REGKEY" generated at https://www.nitrxgen.net/hashgen/ | 36 | // crc64/we of string "UNIVERSE_REGKEY" generated at http://www.nitrxgen.net/hashgen/ |
36 | static void* const UNIVERSE_REGKEY = ((void*)0x9f877b2cf078f17f); | 37 | static DECLARE_UNIQUE_KEY( UNIVERSE_REGKEY, 0x9f877b2cf078f17f); |
37 | 38 | ||
38 | // ################################################################################################ | 39 | // ################################################################################################ |
39 | 40 | ||
@@ -41,7 +42,7 @@ Universe* universe_create( lua_State* L) | |||
41 | { | 42 | { |
42 | Universe* U = (Universe*) lua_newuserdata( L, sizeof(Universe)); // universe | 43 | Universe* U = (Universe*) lua_newuserdata( L, sizeof(Universe)); // universe |
43 | memset( U, 0, sizeof( Universe)); | 44 | memset( U, 0, sizeof( Universe)); |
44 | lua_pushlightuserdata( L, UNIVERSE_REGKEY); // universe UNIVERSE_REGKEY | 45 | push_unique_key( L, UNIVERSE_REGKEY); // universe UNIVERSE_REGKEY |
45 | lua_pushvalue( L, -2); // universe UNIVERSE_REGKEY universe | 46 | lua_pushvalue( L, -2); // universe UNIVERSE_REGKEY universe |
46 | lua_rawset( L, LUA_REGISTRYINDEX); // universe | 47 | lua_rawset( L, LUA_REGISTRYINDEX); // universe |
47 | return U; | 48 | return U; |
@@ -52,7 +53,7 @@ Universe* universe_create( lua_State* L) | |||
52 | void universe_store( lua_State* L, Universe* U) | 53 | void universe_store( lua_State* L, Universe* U) |
53 | { | 54 | { |
54 | STACK_CHECK( L); | 55 | STACK_CHECK( L); |
55 | lua_pushlightuserdata( L, UNIVERSE_REGKEY); | 56 | push_unique_key( L, UNIVERSE_REGKEY); |
56 | lua_pushlightuserdata( L, U); | 57 | lua_pushlightuserdata( L, U); |
57 | lua_rawset( L, LUA_REGISTRYINDEX); | 58 | lua_rawset( L, LUA_REGISTRYINDEX); |
58 | STACK_END( L, 0); | 59 | STACK_END( L, 0); |
@@ -65,7 +66,7 @@ Universe* universe_get( lua_State* L) | |||
65 | Universe* universe; | 66 | Universe* universe; |
66 | STACK_GROW( L, 2); | 67 | STACK_GROW( L, 2); |
67 | STACK_CHECK( L); | 68 | STACK_CHECK( L); |
68 | lua_pushlightuserdata( L, UNIVERSE_REGKEY); | 69 | push_unique_key( L, UNIVERSE_REGKEY); |
69 | lua_rawget( L, LUA_REGISTRYINDEX); | 70 | lua_rawget( L, LUA_REGISTRYINDEX); |
70 | universe = lua_touserdata( L, -1); // NULL if nil | 71 | universe = lua_touserdata( L, -1); // NULL if nil |
71 | lua_pop( L, 1); | 72 | lua_pop( L, 1); |