diff options
Diffstat (limited to '')
-rw-r--r-- | src/lanes_private.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lanes_private.h b/src/lanes_private.h index 6717fe0..8143216 100644 --- a/src/lanes_private.h +++ b/src/lanes_private.h | |||
@@ -72,18 +72,24 @@ struct s_Lane | |||
72 | }; | 72 | }; |
73 | typedef struct s_Lane Lane; | 73 | typedef struct s_Lane Lane; |
74 | 74 | ||
75 | // xxh64 of string "LANE_POINTER_REGKEY" generated at https://www.pelock.com/products/hash-calculator | ||
76 | static DECLARE_CONST_UNIQUE_KEY( LANE_POINTER_REGKEY, 0xB3022205633743BC); // used as registry key | ||
77 | |||
75 | // To allow free-running threads (longer lifespan than the handle's) | 78 | // To allow free-running threads (longer lifespan than the handle's) |
76 | // 'Lane' are malloc/free'd and the handle only carries a pointer. | 79 | // 'Lane' are malloc/free'd and the handle only carries a pointer. |
77 | // This is not deep userdata since the handle's not portable among lanes. | 80 | // This is not deep userdata since the handle's not portable among lanes. |
78 | // | 81 | // |
79 | #define lua_toLane( L, i) (*((Lane**) luaL_checkudata( L, i, "Lane"))) | 82 | inline Lane* lua_toLane(lua_State* L, int i_) |
83 | { | ||
84 | return *(Lane**)(luaL_checkudata(L, i_, "Lane")); | ||
85 | } | ||
80 | 86 | ||
81 | static inline Lane* get_lane_from_registry( lua_State* L) | 87 | static inline Lane* get_lane_from_registry( lua_State* L) |
82 | { | 88 | { |
83 | Lane* s; | 89 | Lane* s; |
84 | STACK_GROW( L, 1); | 90 | STACK_GROW( L, 1); |
85 | STACK_CHECK( L, 0); | 91 | STACK_CHECK( L, 0); |
86 | REGISTRY_GET( L, CANCEL_TEST_KEY); | 92 | REGISTRY_GET( L, LANE_POINTER_REGKEY); |
87 | s = lua_touserdata( L, -1); // lightuserdata (true 's_lane' pointer) / nil | 93 | s = lua_touserdata( L, -1); // lightuserdata (true 's_lane' pointer) / nil |
88 | lua_pop( L, 1); | 94 | lua_pop( L, 1); |
89 | STACK_END( L, 0); | 95 | STACK_END( L, 0); |