mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 23:13:00 +02:00
neutrino: add luajit
Luajit is a dynamic scripting language completely compatible to lua 5.1. the whole VM has been rewritten from the ground up
and is relentlessly optimized for performance. It combines a high-speed interpreter, written in assembler, with a state-of-the-art JIT compiler.
A substantial reduction of the overhead associated with dynamic languages allows it to break into the performance range traditionally reserved for offline,
static language compilers.
https://luajit.org/luajit.html
https://github.com/LuaJIT/LuaJIT/tree/master
There was additional code needed to enable neutrino to compile against lua 5.1. This was mostly taken from the luaposix compat-headers.
There are still some minor issue that will be easy to fix but it's up and running so damn fast!
Signed-off-by: Markus Volk <f_l_k@t-online.de>
Origin commit data
------------------
Branch: ni/coolstream
Commit: ae2df0de4f
Author: Markus Volk <f_l_k@t-online.de>
Date: 2020-09-17 (Thu, 17 Sep 2020)
------------------
This commit was generated by Migit
This commit is contained in:
21
configure.ac
21
configure.ac
@@ -260,19 +260,20 @@ AC_ARG_ENABLE(lua,
|
||||
|
||||
if test "$enable_lua" = "yes"; then
|
||||
AC_DEFINE(ENABLE_LUA, 1, [include Lua support])
|
||||
PKG_CHECK_MODULES([LUA], [lua >= 5.2], [
|
||||
echo "lua >= 5.2 found"
|
||||
], [
|
||||
PKG_CHECK_MODULES([LUA], [lua5.2 >= 5.2], [
|
||||
echo "lua5.2 found"
|
||||
], [
|
||||
PKG_CHECK_MODULES(LUA, lua, LLUA="yes", LLUA="no")
|
||||
PKG_CHECK_MODULES(luajit, luajit, LLUAJIT="yes", LLUAJIT="no")
|
||||
if test "x$LLUAJIT" = "xyes"; then
|
||||
LUA_LIBS="-lluajit-5.1"
|
||||
AC_DEFINE(LUA_COMPAT_5_2, 1, [needed for build with lua 5.1])
|
||||
elif test "x$LLUA" = "xyes"; then
|
||||
LUA_LIBS="-llua"
|
||||
AC_DEFINE(LUA_COMPAT_5_2, 0, [needed for build with lua 5.1])
|
||||
else
|
||||
echo "lualib not found, assuming static lua in linker path..."
|
||||
LUA_LIBS="-llua -ldl"
|
||||
AC_DEFINE(STATIC_LUAPOSIX, 1, [Define to 1 for static lua build.])
|
||||
])
|
||||
])
|
||||
# hack...
|
||||
AC_DEFINE(LUA_COMPAT_5_2, 1, [does not really belong in config.h, but is needed for build with lua 5.3+])
|
||||
AC_DEFINE(LUA_COMPAT_5_2, 0, [needed for build with lua 5.1])
|
||||
fi
|
||||
fi
|
||||
AM_CONDITIONAL(ENABLE_LUA, test "$enable_lua" = "yes")
|
||||
|
||||
|
@@ -31,12 +31,17 @@ extern "C"
|
||||
#include <lualib.h>
|
||||
}
|
||||
#include <pthread.h>
|
||||
#include <config.h>
|
||||
|
||||
/* wrap strerror_r(). */
|
||||
#ifndef strerror_r
|
||||
#define strerror_r __strerror_r
|
||||
#endif
|
||||
|
||||
#if LUA_COMPAT_5_2
|
||||
void lua_rawsetp (lua_State *L, int i, const void *p);
|
||||
#endif
|
||||
|
||||
#define OS_THREAD_RETURN void *
|
||||
#define INFINITE_JOIN_TIMEOUT -1
|
||||
#define JOIN_OK 0
|
||||
|
@@ -20,6 +20,10 @@
|
||||
#ifndef _LUAVIDEO_H
|
||||
#define _LUAVIDEO_H
|
||||
|
||||
#if LUA_COMPAT_5_2
|
||||
void lua_rawsetp (lua_State *L, int i, const void *p);
|
||||
#endif
|
||||
|
||||
class CLuaVideo
|
||||
{
|
||||
public:
|
||||
|
@@ -1253,4 +1253,41 @@ int CLuaInstance::scale2Res(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if LUA_COMPAT_5_2
|
||||
|
||||
void lua_pushunsigned (lua_State *L, lua_Unsigned n) {
|
||||
lua_pushnumber(L, lua_unsigned2number(n));
|
||||
}
|
||||
|
||||
|
||||
lua_Unsigned luaL_checkunsigned (lua_State *L, int i) {
|
||||
lua_Unsigned result;
|
||||
lua_Number n = lua_tonumber(L, i);
|
||||
if (n == 0 && !lua_isnumber(L, i))
|
||||
luaL_checktype(L, i, LUA_TNUMBER);
|
||||
lua_number2unsigned(result, n);
|
||||
return result;
|
||||
}
|
||||
|
||||
int lua_absindex (lua_State *L, int i) {
|
||||
if (i < 0 && i > LUA_REGISTRYINDEX)
|
||||
i += lua_gettop(L) + 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
void lua_rawgetp (lua_State *L, int i, const void *p) {
|
||||
int abs_i = lua_absindex(L, i);
|
||||
lua_pushlightuserdata(L, (void*)p);
|
||||
lua_rawget(L, abs_i);
|
||||
}
|
||||
|
||||
void lua_rawsetp (lua_State *L, int i, const void *p) {
|
||||
int abs_i = lua_absindex(L, i);
|
||||
luaL_checkstack(L, 1, "not enough stack slots");
|
||||
lua_pushlightuserdata(L, (void*)p);
|
||||
lua_insert(L, -2);
|
||||
lua_rawset(L, abs_i);
|
||||
}
|
||||
|
||||
#endif
|
||||
/* --------------------------------------------------------------- */
|
||||
|
@@ -23,6 +23,31 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#if LUA_COMPAT_5_2
|
||||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
typedef uint32_t lua_Unsigned;
|
||||
int lua_absindex (lua_State *L, int i);
|
||||
void lua_rawgetp (lua_State *L, int i, const void *p);
|
||||
void lua_rawsetp (lua_State *L, int i, const void *p);
|
||||
void lua_pushunsigned (lua_State *L, lua_Unsigned n);
|
||||
lua_Unsigned luaL_checkunsigned (lua_State *L, int i);
|
||||
#define lua_pushglobaltable(L) \
|
||||
lua_pushvalue(L, LUA_GLOBALSINDEX)
|
||||
|
||||
#define LUA_SUPUNSIGNED \
|
||||
((lua_Number)(~(lua_Unsigned)0) + 1)
|
||||
|
||||
#define lua_number2unsigned(i,n) \
|
||||
((i) = (lua_Unsigned)(n))
|
||||
|
||||
#define lua_unsigned2number(u) \
|
||||
(((u) <= (lua_Unsigned)INT_MAX) ? (lua_Number)(int)(u) : (lua_Number)(u))
|
||||
|
||||
#endif
|
||||
|
||||
//#define LUA_DEBUG printf
|
||||
#define LUA_DEBUG(...)
|
||||
|
||||
|
Reference in New Issue
Block a user