]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
x64: Allow building with LUAJIT_USE_SYSMALLOC and LUAJIT_USE_VALGRIND.
authorMike Pall <mike>
Mon, 21 Apr 2014 20:26:46 +0000 (22:26 +0200)
committerMike Pall <mike>
Mon, 21 Apr 2014 20:26:46 +0000 (22:26 +0200)
Valgrind 3.9 killed MAP_32BIT support. Ugh. So now we have to rely on
undocumented behavior where Valgrind always allocates from the bottom
of memory. Alas, such a binary won't run properly without Valgrind.

src/Makefile
src/lib_aux.c
src/lj_state.c

index 9551781a78f4ff7ca76feee335b5ad9cdd01b3e1..c558003c05d8e8e9fc686e3ffce14a454129be86 100644 (file)
@@ -122,8 +122,10 @@ XCFLAGS=
 #
 # Use the system provided memory allocator (realloc) instead of the
 # bundled memory allocator. This is slower, but sometimes helpful for
-# debugging. It's helpful for Valgrind's memcheck tool, too. This option
-# cannot be enabled on x64, since the built-in allocator is mandatory.
+# debugging. This option cannot be enabled on x64, since realloc usually
+# doesn't return addresses in the right address range.
+# OTOH this option is mandatory for Valgrind's memcheck tool on x64 and
+# the only way to get useful results from it for all other architectures.
 #XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
 #
 # This define is required to run LuaJIT under Valgrind. The Valgrind
index 1b01fe0705fd0297a701316c5b7a2bcdf9a71c5e..e88dc7c28b4d7eaac71f9cd3a794f384133392e0 100644 (file)
@@ -302,7 +302,7 @@ static int panic(lua_State *L)
 
 #ifdef LUAJIT_USE_SYSMALLOC
 
-#if LJ_64
+#if LJ_64 && !defined(LUAJIT_USE_VALGRIND)
 #error "Must use builtin allocator for 64 bit target"
 #endif
 
index f972fdcedf61459523c1e714e89ba07497a2f518..b9eaef4614c7c9b65ed058049e5def247fef9c89 100644 (file)
@@ -175,7 +175,7 @@ static void close_state(lua_State *L)
     g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0);
 }
 
-#if LJ_64
+#if LJ_64 && !(defined(LUAJIT_USE_VALGRIND) && defined(LUAJIT_USE_SYSMALLOC))
 lua_State *lj_state_newstate(lua_Alloc f, void *ud)
 #else
 LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud)