aboutsummaryrefslogtreecommitdiff
path: root/src/uniquekey.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/uniquekey.h')
-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_)}