aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-extended/sysdig/sysdig/0001-libsinsp-Port-to-build-with-lua-5.2.patch
blob: 8fec0ca59f26ae36caf59f70dafbdd0ad95cb019 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
From c2782a6ca968190e221c25b0890600ba8cd43798 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 23 Oct 2015 00:23:15 -0700
Subject: [PATCH] libsinsp: Port to build with lua >= 5.2

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 userspace/libsinsp/chisel.cpp | 40 +++++++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 11 deletions(-)

diff --git a/userspace/libsinsp/chisel.cpp b/userspace/libsinsp/chisel.cpp
index 3cfbd8d..2db9348 100644
--- a/userspace/libsinsp/chisel.cpp
+++ b/userspace/libsinsp/chisel.cpp
@@ -94,7 +94,7 @@ void lua_stackdump(lua_State *L)
 // Lua callbacks
 ///////////////////////////////////////////////////////////////////////////////
 #ifdef HAS_LUA_CHISELS
-const static struct luaL_reg ll_sysdig [] = 
+const static struct luaL_Reg ll_sysdig [] =
 {
 	{"set_filter", &lua_cbacks::set_global_filter},
 	{"set_snaplen", &lua_cbacks::set_snaplen},
@@ -120,7 +120,7 @@ const static struct luaL_reg ll_sysdig [] =
 	{NULL,NULL}
 };
 
-const static struct luaL_reg ll_chisel [] = 
+const static struct luaL_Reg ll_chisel [] =
 {
 	{"request_field", &lua_cbacks::request_field},
 	{"set_filter", &lua_cbacks::set_filter},
@@ -131,7 +131,7 @@ const static struct luaL_reg ll_chisel [] =
 	{NULL,NULL}
 };
 
-const static struct luaL_reg ll_evt [] = 
+const static struct luaL_Reg ll_evt [] =
 {
 	{"field", &lua_cbacks::field},
 	{"get_num", &lua_cbacks::get_num},
@@ -853,10 +853,28 @@ bool sinsp_chisel::parse_view_info(lua_State *ls, OUT chisel_desc* cd)
 
 
 #ifdef HAS_LUA_CHISELS
+static void chisel_lua_registerlib(lua_State *L, const char *libname,
+				const luaL_Reg *l, int ind)
+{
+#if LUA_VERSION_NUM >= 502
+	if (libname)
+	{
+		lua_newtable(L);
+		luaL_setfuncs(L, l, ind);
+		lua_pushvalue(L, -1);
+		lua_setglobal(L, libname);
+	}
+	else
+		luaL_setfuncs(L, l, ind);
+#else
+	luaL_register(L, libname, l);
+#endif
+}
+
 // Initializes a lua chisel
 bool sinsp_chisel::init_lua_chisel(chisel_desc &cd, string const &fpath)
 {
-	lua_State* ls = lua_open();
+	lua_State* ls = luaL_newstate();
 	if(ls == NULL)
 	{
 		return false;
@@ -867,9 +885,9 @@ bool sinsp_chisel::init_lua_chisel(chisel_desc &cd, string const &fpath)
 	//
 	// Load our own lua libs
 	//
-	luaL_openlib(ls, "sysdig", ll_sysdig, 0);
-	luaL_openlib(ls, "chisel", ll_chisel, 0);
-	luaL_openlib(ls, "evt", ll_evt, 0);
+	chisel_lua_registerlib(ls, "sysdig", ll_sysdig, 0);
+	chisel_lua_registerlib(ls, "chisel", ll_chisel, 0);
+	chisel_lua_registerlib(ls, "evt", ll_evt, 0);
 
 	//
 	// Add our chisel paths to package.path
@@ -1111,16 +1129,16 @@ void sinsp_chisel::load(string cmdstr)
 	//
 	// Open the script
 	//
-	m_ls = lua_open();
+	m_ls = luaL_newstate();
  
 	luaL_openlibs(m_ls);
 
 	//
 	// Load our own lua libs
 	//
-	luaL_openlib(m_ls, "sysdig", ll_sysdig, 0);
-	luaL_openlib(m_ls, "chisel", ll_chisel, 0);
-	luaL_openlib(m_ls, "evt", ll_evt, 0);
+	chisel_lua_registerlib(m_ls, "sysdig", ll_sysdig, 0);
+	chisel_lua_registerlib(m_ls, "chisel", ll_chisel, 0);
+	chisel_lua_registerlib(m_ls, "evt", ll_evt, 0);
 
 	//
 	// Add our chisel paths to package.path
-- 
2.6.2