From 4754ed45b607e82450a5e31fea1da3ba61433b04 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Mar 2021 08:54:12 +0100 Subject: Adding upstream version 1.1.0+debian. Signed-off-by: Daniel Baumann --- src/gen-compat.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/gen-compat.lua (limited to 'src/gen-compat.lua') diff --git a/src/gen-compat.lua b/src/gen-compat.lua new file mode 100644 index 0000000..65c40ec --- /dev/null +++ b/src/gen-compat.lua @@ -0,0 +1,34 @@ +for line in io.lines("config.h") do + local n, s = line:match("define SIZEOF_(%S*) (%d+)") + if n and s then + if n:match("^PTHREAD") or n:match("^CK_") or n:match("^GNUTLS_") then + s = math.ceil(s / 8) + print("#if !defined(SIZEOF_"..n..") || SIZEOF_"..n.." == 0") + print("#error \""..n.." is undefined or zero\"") + print("#endif") + n = n:lower() + print("typedef struct "..n:sub(1,-3).." { uint64_t a["..s.."]; } "..n..";") + elseif n:match("^STRUCT") then + n = n:match("^STRUCT_(%S*)") + if n == "SOCKADDR_STORAGE" or n == "POLLFD" then + print("#if !defined(SIZEOF_STRUCT_"..n..") || SIZEOF_STRUCT_"..n.." == 0") + print("#error \""..n.." is undefined or zero\"") + print("#endif") + n = n:lower() + print("struct "..n.." { uint8_t a["..s.."]; };") + end + end + end +end +code, err = pcall(function() + local ffi = require("ffi") + ffi.cdef[[ + ssize_t dummy; + ]] +end) +if code then + print("#include ") + print("typedef ssize_t luajit_ssize_t;") +else + print("typedef long luajit_ssize_t;") +end -- cgit v1.2.3