]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
treewide: drop support for other lua versions
authorVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 4 Apr 2019 12:08:06 +0000 (14:08 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 13 Jun 2019 13:03:14 +0000 (15:03 +0200)
We're very much depending on LuaJIT, for years already.
The removed stuff seems very unlikely to be useful in any LuaJIT
in forseeable future.  The Lua language is effectively forked.

13 files changed:
.luacheckrc
daemon/bindings/cache.c
daemon/bindings/event.c
daemon/bindings/impl.c
daemon/bindings/impl.h
daemon/bindings/modules.c
daemon/bindings/net.c
daemon/bindings/worker.c
daemon/engine.c
daemon/ffimodule.c
daemon/lua/sandbox.lua.in
modules/bogus_log/bogus_log.c
modules/stats/stats.c

index 13d8989dad5756b35d273bad9f032af7430fcc86..837133a87769d96cb06b50fff0c44072d7c50309 100644 (file)
@@ -41,7 +41,6 @@ new_read_globals = {
        'table_print',
        '__engine',
        '_ENV',
-       '_SANDBOX',
 }
 
 new_globals = {
index f20d5d9b0c873bfbcfad2dcdb3edd4d5c704c40f..855161a74b3d477623d5561f4cb1039f592c9f4d 100644 (file)
@@ -466,7 +466,7 @@ int kr_bindings_cache(lua_State *L)
                { NULL, NULL }
        };
 
-       register_lib(L, "cache", lib);
+       luaL_register(L, "cache", lib);
        return 1;
 }
 
index 98180f758bc65c13cf80d9bf4378f75c82710be8..5a4ba633f13cdf3903c5ce5e5b855845ff4b3b2f 100644 (file)
@@ -218,7 +218,7 @@ int kr_bindings_event(lua_State *L)
                { NULL, NULL }
        };
 
-       register_lib(L, "event", lib);
+       luaL_register(L, "event", lib);
        return 1;
 }
 
index 21a8d7876eea140287fa30b8999fcd189b614e5a..624aece4560616cd6ebe54c0712f4eebe399a1c1 100644 (file)
@@ -49,24 +49,13 @@ int kr_bindings_modules (lua_State *L); /* ./modules.c */
 int kr_bindings_net     (lua_State *L); /* ./net.c     */
 int kr_bindings_worker  (lua_State *L); /* ./worker.c  */
 
-
-static void lualib(lua_State *L, const char *name, lua_CFunction lib_cb)
-{
-#if LUA_VERSION_NUM >= 502
-       luaL_requiref(L, name, lib_cb, 1);
-       lua_pop(L, 1);
-#else
-       lib_cb(L);
-#endif
-}
-
 void kr_bindings_register(lua_State *L)
 {
-       lualib(L, "modules", kr_bindings_modules);
-       lualib(L, "net",     kr_bindings_net);
-       lualib(L, "cache",   kr_bindings_cache);
-       lualib(L, "event",   kr_bindings_event);
-       lualib(L, "worker",  kr_bindings_worker);
+       kr_bindings_cache(L);
+       kr_bindings_event(L);
+       kr_bindings_modules(L);
+       kr_bindings_net(L);
+       kr_bindings_worker(L);
 }
 
 void lua_error_p(lua_State *L, const char *fmt, ...)
index 1bd0d4126c8f0fadbd6458c9965cbb2b106e4240..860bc612f021101f3cef3cbef6addf28154b6ca0 100644 (file)
 #include <lua.h>
 #include <lauxlib.h>
 
-
-/** @internal Compatibility wrapper for Lua 5.0 - 5.2
-    https://www.lua.org/manual/5.2/manual.html#luaL_newlib
- */
-#if LUA_VERSION_NUM >= 502
-#define register_lib(L, name, lib) \
-       luaL_newlib((L), (lib))
-#else
-#define lua_rawlen(L, obj) \
-       lua_objlen((L), (obj))
-#define register_lib(L, name, lib) \
-       luaL_openlib((L), (name), (lib), 0)
-#endif
-
 /** Useful to stringify #defines into error strings. */
 #define STR(s) STRINGIFY_TOKEN(s)
 #define STRINGIFY_TOKEN(s) #s
index 0177bdce5d62f08867620c01e87a21d46fbf5a70..2cd44feaa42a6bdccec51d277470a9dc038301b5 100644 (file)
@@ -85,7 +85,7 @@ int kr_bindings_modules(lua_State *L)
                { NULL, NULL }
        };
 
-       register_lib(L, "modules", lib);
+       luaL_register(L, "modules", lib);
        return 1;
 }
 
index 0d7e7d3ab761c1234f5e39b731c7263b157856ec..de7d308385fbe93351e63738fae930aecbc9bf33 100644 (file)
@@ -279,7 +279,7 @@ static int net_interfaces(lua_State *L)
                        buf[0] = '\0';
                }
                lua_pushstring(L, buf);
-               lua_rawseti(L, -2, lua_rawlen(L, -2) + 1);
+               lua_rawseti(L, -2, lua_objlen(L, -2) + 1);
                lua_setfield(L, -2, "addr");
 
                /* Hardware address. */
@@ -1030,7 +1030,7 @@ int kr_bindings_net(lua_State *L)
                { "register_endpoint_kind", net_register_endpoint_kind },
                { NULL, NULL }
        };
-       register_lib(L, "net", lib);
+       luaL_register(L, "net", lib);
        return 1;
 }
 
index 34035d2dcdb52787fe0124b66b7c1e88209e99d3..41379f45fd12e5859c734711a9c32640bce82578 100644 (file)
@@ -177,7 +177,7 @@ int kr_bindings_worker(lua_State *L)
                { "stats",    wrk_stats },
                { NULL, NULL }
        };
-       register_lib(L, "worker", lib);
+       luaL_register(L, "worker", lib);
        return 1;
 }
 
index 036b2fe517f9da9881760b7876cc05dbfe7bb66a..73823f9ff1d75be9998ac6180f6ab41e384fff19 100644 (file)
        #endif
 #endif
 
-/** @internal Compatibility wrapper for Lua < 5.2 */
-#if LUA_VERSION_NUM < 502
-#define lua_rawlen(L, obj) lua_objlen((L), (obj))
-#endif
-
 /**@internal Maximum number of incomplete TCP connections in queue.
 * Default is from Redis and Apache. */
 #ifndef TCP_BACKLOG_DEFAULT
@@ -306,7 +301,7 @@ static void l_unpack_json(lua_State *L, JsonNode *table)
                if (node->key) {
                        lua_setfield(L, -2, node->key);
                } else {
-                       lua_rawseti(L, -2, lua_rawlen(L, -2) + 1);
+                       lua_rawseti(L, -2, lua_objlen(L, -2) + 1);
                }
        }
 }
@@ -390,7 +385,7 @@ static int l_fromjson(lua_State *L)
 
 /** @internal Throw Lua error if expr is false */
 #define expr_checked(expr) \
-       if (!(expr)) { lua_pushboolean(L, false); lua_rawseti(L, -2, lua_rawlen(L, -2) + 1); continue; }
+       if (!(expr)) { lua_pushboolean(L, false); lua_rawseti(L, -2, lua_objlen(L, -2) + 1); continue; }
 
 static int l_map(lua_State *L)
 {
@@ -429,12 +424,12 @@ static int l_map(lua_State *L)
                                lua_pushlstring(L, rbuf, rlen);
                        }
                        json_delete(root_node);
-                       lua_rawseti(L, -2, lua_rawlen(L, -2) + 1);
+                       lua_rawseti(L, -2, lua_objlen(L, -2) + 1);
                        continue;
                }
                /* Didn't respond */
                lua_pushboolean(L, false);
-               lua_rawseti(L, -2, lua_rawlen(L, -2) + 1);
+               lua_rawseti(L, -2, lua_objlen(L, -2) + 1);
        }
        return 1;
 }
@@ -666,10 +661,6 @@ void engine_deinit(struct engine *engine)
 
 int engine_pcall(lua_State *L, int argc)
 {
-#if LUA_VERSION_NUM >= 502
-       lua_getglobal(L, "_SANDBOX");
-       lua_setupvalue(L, -(2 + argc), 1);
-#endif
        return lua_pcall(L, argc, LUA_MULTRET, 0);
 }
 
index e46f4f14636077c46c7a11a9dceaed0eab760e87..f9f6b01edd1bb481a4875698ede9074e26f71f73 100644 (file)
 #include "lib/module.h"
 #include "lib/layer.h"
 
-#if LUA_VERSION_NUM >= 502
-#define l_resume(L, argc) lua_resume((L), NULL, (argc))
-#else
-#define l_resume(L, argc) lua_resume((L), (argc))
-#endif
-
 /** @internal Slots for layer callbacks.
   * Each slot ID corresponds to Lua reference in module API. */
 enum {
@@ -65,7 +59,7 @@ static inline lua_State *l_ffi_preface(struct kr_module *module, const char *cal
 static void l_ffi_resume_cb(uv_idle_t *check)
 {
        lua_State *L = check->data;
-       int status = l_resume(L, 0);
+       int status = lua_resume(L, 0);
        if (status != LUA_YIELD) {
                uv_idle_stop(check); /* Stop coroutine */
                uv_close((uv_handle_t *)check, (uv_close_cb)free);
index 6d9d87826f54fa25708cd0330fe89514a022f70d..b753d177745599b056926ef394af833772b9bea4 100644 (file)
@@ -404,12 +404,8 @@ local function make_sandbox(defined)
 end
 
 -- Compatibility sandbox
-if setfenv then -- Lua 5.1 and less
-       _G = make_sandbox(getfenv(0))
-       setfenv(0, _G)
-else -- Lua 5.2+
-       _SANDBOX = make_sandbox(_ENV)
-end
+_G = make_sandbox(getfenv(0))
+setfenv(0, _G)
 
 -- Load embedded modules
 trust_anchors = require('trust_anchors')
index 09f4d68288873793e5a4950eb1dbfeed49a4b433..e67dbfe189c861cfb3497509205c641e78df3236 100644 (file)
 #include "lib/layer.h"
 #include "lib/generic/lru.h"
 
-/** @internal Compatibility wrapper for Lua < 5.2 */
-#if LUA_VERSION_NUM < 502
-#define lua_rawlen(L, obj) lua_objlen((L), (obj))
-#endif
-
 #ifdef LRU_REP_SIZE
  #define FREQUENT_COUNT LRU_REP_SIZE /* Size of frequent tables */
 #else
index add632ebab9277ddfb6ffe189260dbfd3a7f7617..361147c83ee877a6aaf96df90cc5c32b0e0835c7 100644 (file)
 #include "lib/layer.h"
 #include "lib/resolve.h"
 
-/** @internal Compatibility wrapper for Lua < 5.2 */
-#if LUA_VERSION_NUM < 502
-#define lua_rawlen(L, obj) lua_objlen((L), (obj))
-#endif
-
 /* Defaults */
 #define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, "stat",  __VA_ARGS__)
 #define FREQUENT_PSAMPLE  10 /* Sampling rate, 1 in N */