summaryrefslogtreecommitdiffstats
path: root/src/gen-compat.lua
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-13 07:54:12 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-13 07:54:12 +0000
commit4754ed45b607e82450a5e31fea1da3ba61433b04 (patch)
tree3554490bdc003e6004f605abe41929cdf98b0651 /src/gen-compat.lua
parentInitial commit. (diff)
downloaddnsjit-4754ed45b607e82450a5e31fea1da3ba61433b04.tar.xz
dnsjit-4754ed45b607e82450a5e31fea1da3ba61433b04.zip
Adding upstream version 1.1.0+debian.upstream/1.1.0+debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/gen-compat.lua')
-rw-r--r--src/gen-compat.lua34
1 files changed, 34 insertions, 0 deletions
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 <unistd.h>")
+ print("typedef ssize_t luajit_ssize_t;")
+else
+ print("typedef long luajit_ssize_t;")
+end