Page MenuHomePhabricator

0001-Remove-LuaJIT-support.patch

Authored By
Anomie
Feb 2 2018, 4:13 PM
Size
4 KB
Referenced Files
None
Subscribers
None

0001-Remove-LuaJIT-support.patch

From 5dfaa6c85d605db12dcfd7a29413e347abef1119 Mon Sep 17 00:00:00 2001
From: Brad Jorsch <bjorsch@wikimedia.org>
Date: Thu, 4 Jan 2018 12:22:54 -0500
Subject: [PATCH] Remove LuaJIT support
Not used or tested by anyone we know of, and may well have bitrotted
since anyone last did so.
Change-Id: Ic8840bae9463e12a07a6087e2e7829d6483888c4
---
alloc.c | 46 ----------------------------------------------
config.m4 | 6 ++----
luasandbox.c | 3 ---
php_luasandbox.h | 3 ---
4 files changed, 2 insertions(+), 56 deletions(-)
diff --git a/alloc.c b/alloc.c
index 2f2a321..8122396 100644
--- a/alloc.c
+++ b/alloc.c
@@ -12,44 +12,19 @@
#include "php.h"
#include "php_luasandbox.h"
-#if defined(LUA_JITLIBNAME) && (SSIZE_MAX >> 32) > 0
-#define LUASANDBOX_LJ_64
-#endif
-
static inline int luasandbox_update_memory_accounting(php_luasandbox_alloc * obj,
size_t osize, size_t nsize);
-#ifdef LUASANDBOX_LJ_64
-static void *luasandbox_passthru_alloc(void *ud, void *ptr, size_t osize, size_t nsize);
-#else
static void *luasandbox_php_alloc(void *ud, void *ptr, size_t osize, size_t nsize);
-#endif
lua_State * luasandbox_alloc_new_state(php_luasandbox_alloc * alloc, php_luasandbox_obj * sandbox)
{
lua_State * L;
-#ifdef LUASANDBOX_LJ_64
- // The 64-bit version of LuaJIT needs to use its own allocator
- L = luaL_newstate();
- if (L) {
- alloc->old_alloc = lua_getallocf(L, &alloc->old_alloc_ud);
- lua_setallocf(L, luasandbox_passthru_alloc, sandbox);
- }
-#else
L = lua_newstate(luasandbox_php_alloc, sandbox);
-#endif
return L;
}
void luasandbox_alloc_delete_state(php_luasandbox_alloc * alloc, lua_State * L)
{
- // In 64-bit LuaJIT mode, restore the old allocator before calling
- // lua_close() because lua_close() actually checks that the value of the
- // function pointer is unchanged before destroying the underlying
- // allocator. If the allocator has been changed, the mmap is not freed.
-#ifdef LUASANDBOX_LJ_64
- lua_setallocf(L, alloc->old_alloc, alloc->old_alloc_ud);
-#endif
-
lua_close(L);
}
@@ -82,7 +57,6 @@ static inline int luasandbox_update_memory_accounting(php_luasandbox_alloc * all
}
/* }}} */
-#ifndef LUASANDBOX_LJ_64
/** {{{ luasandbox_php_alloc
*
* The Lua allocator function. Use PHP's request-local allocator as a backend.
@@ -113,23 +87,3 @@ static void *luasandbox_php_alloc(void *ud, void *ptr, size_t osize, size_t nsiz
return nptr;
}
/* }}} */
-#endif
-
-#ifdef LUASANDBOX_LJ_64
-/** {{{ luasandbox_passthru_alloc
- *
- * A Lua allocator function for use with LuaJIT on a 64-bit platform. Pass
- * allocation requests through to the standard allocator, which is customised
- * on this platform to always return memory from the lower 2GB of address
- * space.
- */
-static void *luasandbox_passthru_alloc(void *ud, void *ptr, size_t osize, size_t nsize)
-{
- php_luasandbox_obj * obj = (php_luasandbox_obj*)ud;
- if (!luasandbox_update_memory_accounting(&obj->alloc, osize, nsize)) {
- return NULL;
- }
- return obj->alloc.old_alloc(obj->alloc.old_alloc_ud, ptr, osize, nsize);
-}
-/* }}} */
-#endif
diff --git a/config.m4 b/config.m4
index 1f32754..2e16b02 100644
--- a/config.m4
+++ b/config.m4
@@ -11,14 +11,12 @@ if test "$PHP_LUASANDBOX" != "no"; then
m4_include([m4/pkg.m4])
PKG_PROG_PKG_CONFIG
- dnl We need lua or fallback to luajit.
+ dnl We need lua
dnl Under debian package is known as 'lua5.1'
dnl Under freebsd package is known as 'lua-5.1'
PKG_CHECK_MODULES([LUA], [lua >= 5.1 lua < 5.2],, [
PKG_CHECK_MODULES([LUA], [lua5.1],, [
- PKG_CHECK_MODULES([LUA], [lua-5.1],, [
- PKG_CHECK_MODULES([LUA], [luajit])
- ])
+ PKG_CHECK_MODULES([LUA], [lua-5.1])
])
])
diff --git a/luasandbox.c b/luasandbox.c
index e515099..2f8b5e1 100644
--- a/luasandbox.c
+++ b/luasandbox.c
@@ -709,9 +709,6 @@ PHP_METHOD(LuaSandbox, getVersionInfo)
array_init_size(return_value, 2);
compat_add_assoc_string(return_value, "LuaSandbox", LUASANDBOX_VERSION);
compat_add_assoc_string(return_value, "Lua", LUA_RELEASE);
-#ifdef LUAJIT_VERSION
- compat_add_assoc_string(return_value, "LuaJIT", LUAJIT_VERSION);
-#endif
}
/* }}} */
diff --git a/php_luasandbox.h b/php_luasandbox.h
index 355105b..2f1f067 100644
--- a/php_luasandbox.h
+++ b/php_luasandbox.h
@@ -4,9 +4,6 @@
#include <lua.h>
#include <lualib.h>
-#ifdef LUA_JITLIBNAME
-#include <luajit.h>
-#endif
#include <signal.h>
#include "luasandbox_types.h"
--
2.15.1

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5467674
Default Alt Text
0001-Remove-LuaJIT-support.patch (4 KB)

Event Timeline