On Thu, Feb 06, 2020 at 07:18:48PM +0100, Klemens Nanni wrote:
> sparc64 does not have luajit suppport which blocked my update to 5.0.3;
> I #ifdef'd the bits in src/scripting.c but afaik there were issues with
> dependent ports on such recent redis versions -- rspamd was probably one
> of them.
Found the diffs, but I have currently no way and/or time to test this.

One disables luajit on sparc64, the other removes tests for it, but that
(test) approach is obviously not suitable for all other arches that have
luajit.
$OpenBSD$

luajit is not available on sparc64.

Index: src/scripting.c
--- src/scripting.c.orig
+++ src/scripting.c
@@ -830,10 +830,12 @@ void luaLoadLib(lua_State *lua, const char *libname, l
   lua_call(lua, 1, 0);
 }
 
+#ifdef LUAJIT_H
 LUALIB_API int (luaopen_cjson) (lua_State *L);
 LUALIB_API int (luaopen_struct) (lua_State *L);
 LUALIB_API int (luaopen_cmsgpack) (lua_State *L);
 LUALIB_API int (luaopen_bit) (lua_State *L);
+#endif /* LUAJIT_H */
 
 void luaLoadLibraries(lua_State *lua) {
     luaLoadLib(lua, "", luaopen_base);
@@ -841,10 +843,12 @@ void luaLoadLibraries(lua_State *lua) {
     luaLoadLib(lua, LUA_STRLIBNAME, luaopen_string);
     luaLoadLib(lua, LUA_MATHLIBNAME, luaopen_math);
     luaLoadLib(lua, LUA_DBLIBNAME, luaopen_debug);
+#ifdef LUAJIT_H
     luaLoadLib(lua, "cjson", luaopen_cjson);
     luaLoadLib(lua, "struct", luaopen_struct);
     luaLoadLib(lua, "cmsgpack", luaopen_cmsgpack);
     luaLoadLib(lua, "bit", luaopen_bit);
+#endif /* LUAJIT_H */
 
 #if 0 /* Stuff that we don't load currently, for sandboxing concerns. */
     luaLoadLib(lua, LUA_LOADLIBNAME, luaopen_package);
$OpenBSD$

Remove tests for luajit functions.

Index: tests/unit/scripting.tcl
--- tests/unit/scripting.tcl.orig
+++ tests/unit/scripting.tcl
@@ -187,75 +187,6 @@ start_server {tags {"scripting"}} {
         set e
     } {*against a key*}
 
-    test {EVAL - JSON numeric decoding} {
-        # We must return the table as a string because otherwise
-        # Redis converts floats to ints and we get 0 and 1023 instead
-        # of 0.0003 and 1023.2 as the parsed output.
-        r eval {return
-                 table.concat(
-                   cjson.decode(
-                    "[0.0, -5e3, -1, 0.3e-3, 1023.2, 0e10]"), " ")
-        } 0
-    } {0 -5000 -1 0.0003 1023.2 0}
-
-    test {EVAL - JSON string decoding} {
-        r eval {local decoded = cjson.decode('{"keya": "a", "keyb": "b"}')
-                return {decoded.keya, decoded.keyb}
-        } 0
-    } {a b}
-
-    test {EVAL - cmsgpack can pack double?} {
-        r eval {local encoded = cmsgpack.pack(0.1)
-                local h = ""
-                for i = 1, #encoded do
-                    h = h .. string.format("%02x",string.byte(encoded,i))
-                end
-                return h
-        } 0
-    } {cb3fb999999999999a}
-
-    test {EVAL - cmsgpack can pack negative int64?} {
-        r eval {local encoded = cmsgpack.pack(-1099511627776)
-                local h = ""
-                for i = 1, #encoded do
-                    h = h .. string.format("%02x",string.byte(encoded,i))
-                end
-                return h
-        } 0
-    } {d3ffffff0000000000}
-
-    test {EVAL - cmsgpack can pack and unpack circular references?} {
-        r eval {local a = {x=nil,y=5}
-                local b = {x=a}
-                a['x'] = b
-                local encoded = cmsgpack.pack(a)
-                local h = ""
-                -- cmsgpack encodes to a depth of 16, but can't encode
-                -- references, so the encoded object has a deep copy recusive
-                -- depth of 16.
-                for i = 1, #encoded do
-                    h = h .. string.format("%02x",string.byte(encoded,i))
-                end
-                -- when unpacked, re.x.x != re because the unpack creates
-                -- individual tables down to a depth of 16.
-                -- (that's why the encoded output is so large)
-                local re = cmsgpack.unpack(encoded)
-                assert(re)
-                assert(re.x)
-                assert(re.x.x.y == re.y)
-                assert(re.x.x.x.x.y == re.y)
-                assert(re.x.x.x.x.x.x.y == re.y)
-                assert(re.x.x.x.x.x.x.x.x.x.x.y == re.y)
-                -- maximum working depth:
-                assert(re.x.x.x.x.x.x.x.x.x.x.x.x.x.x.y == re.y)
-                -- now the last x would be b above and has no y
-                assert(re.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x)
-                -- so, the final x.x is at the depth limit and was assigned nil
-                assert(re.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x == nil)
-                return {h, re.x.x.x.x.x.x.x.x.y == re.y, re.y == 5}
-        } 0
-    } 
{82a17905a17881a17882a17905a17881a17882a17905a17881a17882a17905a17881a17882a17905a17881a17882a17905a17881a17882a17905a17881a17882a17905a17881a178c0
 1 1}
-
     test {EVAL - Numerical sanity check from bitop} {
         r eval {assert(0x7fffffff == 2147483647, "broken hex literals");
                 assert(0xffffffff == -1 or 0xffffffff == 2^32-1,

Reply via email to