aboutsummaryrefslogtreecommitdiff
path: root/src/uniquekey.h
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2022-02-17 16:30:36 +0100
committerBenoit Germain <bnt.germain@gmail.com>2022-02-17 16:30:36 +0100
commitc2f88350772c01631ea3b7d60e56cea335c458b7 (patch)
treeb4fcc4bebb094190b0dc13561ab24c1593da86f7 /src/uniquekey.h
parent2c0000d5169cacf950d06637ada1a371cf382896 (diff)
downloadlanes-c2f88350772c01631ea3b7d60e56cea335c458b7.tar.gz
lanes-c2f88350772c01631ea3b7d60e56cea335c458b7.tar.bz2
lanes-c2f88350772c01631ea3b7d60e56cea335c458b7.zip
NEVER use allocator obtained from lua_getallocf to allocate stuff manually when compiling for LuaJIT
Diffstat (limited to '')
-rw-r--r--src/uniquekey.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/uniquekey.h b/src/uniquekey.h
index ff3d45d..a72426c 100644
--- a/src/uniquekey.h
+++ b/src/uniquekey.h
@@ -1,7 +1,7 @@
1#if !defined __LANES_UNIQUEKEY_H__ 1#if !defined __LANES_UNIQUEKEY_H__
2#define __LANES_UNIQUEKEY_H__ 1 2#define __LANES_UNIQUEKEY_H__ 1
3 3
4#include "lualib.h" 4#include "macros_and_utils.h"
5 5
6// Lua light userdata can hold a pointer. 6// Lua light userdata can hold a pointer.
7struct s_UniqueKey 7struct s_UniqueKey
@@ -10,11 +10,11 @@ struct s_UniqueKey
10}; 10};
11typedef struct s_UniqueKey UniqueKey; 11typedef struct s_UniqueKey UniqueKey;
12 12
13#if defined(LUA_JITLIBNAME) && (defined(__x86_64__) || defined(_M_X64) || defined(__LP64__)) // building against LuaJIT headers, light userdata is restricted to 47 significant bits. 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*)((ptrdiff_t)(p_) & 0x7fffffffffffull)) 14#define MAKE_UNIQUE_KEY( p_) ((void*)((ptrdiff_t)(p_) & 0x7fffffffffffull))
15#else // LUA_JITLIBNAME 15#else // LUAJIT_FLAVOR
16#define MAKE_UNIQUE_KEY( p_) ((void*)(ptrdiff_t)(p_)) 16#define MAKE_UNIQUE_KEY( p_) ((void*)(ptrdiff_t)(p_))
17#endif // LUA_JITLIBNAME 17#endif // LUAJIT_FLAVOR
18 18
19#define DECLARE_UNIQUE_KEY( name_) UniqueKey name_ 19#define DECLARE_UNIQUE_KEY( name_) UniqueKey name_
20#define DECLARE_CONST_UNIQUE_KEY( name_, p_) UniqueKey const name_ = { MAKE_UNIQUE_KEY( p_)} 20#define DECLARE_CONST_UNIQUE_KEY( name_, p_) UniqueKey const name_ = { MAKE_UNIQUE_KEY( p_)}