Last active
July 29, 2021 18:24
-
-
Save nddrylliog/8722197 to your computer and use it in GitHub Desktop.
LuaJIT modifications needed to re-enable custom 64-bit allocators.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/lib_aux.c b/src/lib_aux.c | |
index 05fa6b1..c618094 100644 | |
--- a/src/lib_aux.c | |
+++ b/src/lib_aux.c | |
@@ -346,9 +346,11 @@ LUALIB_API lua_State *luaL_newstate(void) | |
#if LJ_64 | |
LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) | |
{ | |
- UNUSED(f); UNUSED(ud); | |
- fputs("Must use luaL_newstate() for 64 bit target\n", stderr); | |
- return NULL; | |
+ /* Re-enable custom 64-bit allocators */ | |
+ lua_State *L; | |
+ L = lj_state_newstate(f, ud); | |
+ if (L) G(L)->panic = panic; | |
+ return L; | |
} | |
#endif | |
Old gist, I know - but I don't quite understand why they're using signed memory offsets. I understand that using signed types gives you trapability whereas unsigned will silently overflow, but that's a poor reason to use signed types for memory offsets, especially when it cuts out a widely used architecture.
Further, the mmap
implementation they provide simply does not work on the three machines I tried it on. I have no idea how they got it to work elsewhere. It receives a failure code from the call to mmap()
and it doesn't specify why it fails.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cf. http://hacksoflife.blogspot.fr/2012/12/integrating-luajit-with-x-plane-64-bit.html for an explanation.
Mostly: