Eliminate use of lightuserdata derived from static data pointers.

Required for >47 bit VA, e.g. ARM64.
This commit is contained in:
Mike Pall 2016-11-24 19:14:17 +01:00
parent 81259898ea
commit d7243e1de0
2 changed files with 5 additions and 6 deletions

View File

@ -283,13 +283,13 @@ LJLIB_CF(debug_setuservalue)
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
static const char KEY_HOOK = 'h'; #define KEY_HOOK ((void *)0x3004)
static void hookf(lua_State *L, lua_Debug *ar) static void hookf(lua_State *L, lua_Debug *ar)
{ {
static const char *const hooknames[] = static const char *const hooknames[] =
{"call", "return", "line", "count", "tail return"}; {"call", "return", "line", "count", "tail return"};
lua_pushlightuserdata(L, (void *)&KEY_HOOK); lua_pushlightuserdata(L, KEY_HOOK);
lua_rawget(L, LUA_REGISTRYINDEX); lua_rawget(L, LUA_REGISTRYINDEX);
if (lua_isfunction(L, -1)) { if (lua_isfunction(L, -1)) {
lua_pushstring(L, hooknames[(int)ar->event]); lua_pushstring(L, hooknames[(int)ar->event]);
@ -334,7 +334,7 @@ LJLIB_CF(debug_sethook)
count = luaL_optint(L, arg+3, 0); count = luaL_optint(L, arg+3, 0);
func = hookf; mask = makemask(smask, count); func = hookf; mask = makemask(smask, count);
} }
lua_pushlightuserdata(L, (void *)&KEY_HOOK); lua_pushlightuserdata(L, KEY_HOOK);
lua_pushvalue(L, arg+1); lua_pushvalue(L, arg+1);
lua_rawset(L, LUA_REGISTRYINDEX); lua_rawset(L, LUA_REGISTRYINDEX);
lua_sethook(L, func, mask, count); lua_sethook(L, func, mask, count);
@ -349,7 +349,7 @@ LJLIB_CF(debug_gethook)
if (hook != NULL && hook != hookf) { /* external hook? */ if (hook != NULL && hook != hookf) { /* external hook? */
lua_pushliteral(L, "external hook"); lua_pushliteral(L, "external hook");
} else { } else {
lua_pushlightuserdata(L, (void *)&KEY_HOOK); lua_pushlightuserdata(L, KEY_HOOK);
lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */ lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */
} }
lua_pushstring(L, unmakemask(mask, buff)); lua_pushstring(L, unmakemask(mask, buff));

View File

@ -399,8 +399,7 @@ static int lj_cf_package_loader_preload(lua_State *L)
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
static const int sentinel_ = 0; #define sentinel ((void *)0x4004)
#define sentinel ((void *)&sentinel_)
static int lj_cf_package_require(lua_State *L) static int lj_cf_package_require(lua_State *L)
{ {