blob: 71b0b8c8b9d72bf441a88ff7d029456be18e4738 [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001From ae82de664a6ba6ab2654adf9bed81f22b6fdc19d Mon Sep 17 00:00:00 2001
2From: Evgeni Golov <evgeni@golov.de>
3Date: Sun, 27 Aug 2017 13:51:19 +0200
4Subject: [PATCH] fix build with LuaJIT 2.1 betas
5
6LuaJIT 2.1 drops some compat symbols [1]. And while I think that this is
7wrong, as it breaks compatibility with Lua 5.1 [2], it is quite easy to
8adopt the code to work with both versions (2.0 and 2.1) of LuaJIT and
9remain Lua 5.1 compatible.
10
11[1] https://github.com/LuaJIT/LuaJIT/commit/dc320ca70f2c5bb3977b82853bcee6dad2523d01
12[2] https://github.com/LuaJIT/LuaJIT/issues/325
13
14Upstream-Status: Submitted [https://github.com/LuaJIT/LuaJIT/issues/325]
15Signed-off-by: Evgeni Golov <evgeni@golov.de>
16sysdig-CLA-1.0-signed-off-by: Evgeni Golov <evgeni@golov.de>
17---
18 CMakeLists.txt | 2 +-
19 userspace/libsinsp/chisel.cpp | 6 +++---
20 userspace/libsinsp/lua_parser.cpp | 2 +-
21 userspace/libsinsp/lua_parser_api.cpp | 2 +-
22 4 files changed, 6 insertions(+), 6 deletions(-)
23
24diff --git a/CMakeLists.txt b/CMakeLists.txt
25index d7020493..33e524f5 100644
26--- a/CMakeLists.txt
27+++ b/CMakeLists.txt
28@@ -140,7 +140,7 @@ option(USE_BUNDLED_DEPS "Enable bundled dependencies instead of using the system
29 option(USE_BUNDLED_LUAJIT "Enable building of the bundled LuaJIT" ${USE_BUNDLED_DEPS})
30
31 if(NOT USE_BUNDLED_LUAJIT)
32- find_path(LUAJIT_INCLUDE luajit.h PATH_SUFFIXES luajit-2.0 luajit)
33+ find_path(LUAJIT_INCLUDE luajit.h PATH_SUFFIXES luajit-2.1 luajit-2.0 luajit)
34 find_library(LUAJIT_LIB NAMES luajit luajit-5.1)
35 if(LUAJIT_INCLUDE AND LUAJIT_LIB)
36 message(STATUS "Found LuaJIT: include: ${LUAJIT_INCLUDE}, lib: ${LUAJIT_LIB}")
37diff --git a/userspace/libsinsp/chisel.cpp b/userspace/libsinsp/chisel.cpp
38index 0a6e3cf8..0c2e255a 100644
39--- a/userspace/libsinsp/chisel.cpp
40+++ b/userspace/libsinsp/chisel.cpp
41@@ -98,7 +98,7 @@ void lua_stackdump(lua_State *L)
42 // Lua callbacks
43 ///////////////////////////////////////////////////////////////////////////////
44 #ifdef HAS_LUA_CHISELS
45-const static struct luaL_reg ll_sysdig [] =
46+const static struct luaL_Reg ll_sysdig [] =
47 {
48 {"set_filter", &lua_cbacks::set_global_filter},
49 {"set_snaplen", &lua_cbacks::set_snaplen},
50@@ -134,7 +134,7 @@ const static struct luaL_reg ll_sysdig [] =
51 {NULL,NULL}
52 };
53
54-const static struct luaL_reg ll_chisel [] =
55+const static struct luaL_Reg ll_chisel [] =
56 {
57 {"request_field", &lua_cbacks::request_field},
58 {"set_filter", &lua_cbacks::set_filter},
59@@ -146,7 +146,7 @@ const static struct luaL_reg ll_chisel [] =
60 {NULL,NULL}
61 };
62
63-const static struct luaL_reg ll_evt [] =
64+const static struct luaL_Reg ll_evt [] =
65 {
66 {"field", &lua_cbacks::field},
67 {"get_num", &lua_cbacks::get_num},
68diff --git a/userspace/libsinsp/lua_parser.cpp b/userspace/libsinsp/lua_parser.cpp
69index 0e26617d..78810d96 100644
70--- a/userspace/libsinsp/lua_parser.cpp
71+++ b/userspace/libsinsp/lua_parser.cpp
72@@ -32,7 +32,7 @@ extern "C" {
73 #include "lauxlib.h"
74 }
75
76-const static struct luaL_reg ll_filter [] =
77+const static struct luaL_Reg ll_filter [] =
78 {
79 {"rel_expr", &lua_parser_cbacks::rel_expr},
80 {"bool_op", &lua_parser_cbacks::bool_op},
81diff --git a/userspace/libsinsp/lua_parser_api.cpp b/userspace/libsinsp/lua_parser_api.cpp
82index c89e9126..e0169fe1 100644
83--- a/userspace/libsinsp/lua_parser_api.cpp
84+++ b/userspace/libsinsp/lua_parser_api.cpp
85@@ -266,7 +266,7 @@ int lua_parser_cbacks::rel_expr(lua_State *ls)
86 string err = "Got non-table as in-expression operand\n";
87 throw sinsp_exception("parser API error");
88 }
89- int n = luaL_getn(ls, 4); /* get size of table */
90+ int n = (int)lua_objlen(ls, 4); /* get size of table */
91 for (i=1; i<=n; i++)
92 {
93 lua_rawgeti(ls, 4, i);
94--
952.25.1
96