summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2019-09-20 18:22:27 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2019-09-20 18:22:27 +0000
commit6011d413604df8224b91ca9f9b3d50663b60e117 (patch)
treeca36404ebcc87922d26664dd93e2c0ebd23bef67 /tools
parent98d3a523be4fff36f65e71c37df8b9e127b12b83 (diff)
downloadskalibs-6011d413604df8224b91ca9f9b3d50663b60e117.tar.xz
sysdeps redesign: first part: minimize clr tests
Remaining clr: emptyregex: can be safely guessed to no nullispointer: can't be safely guessed, but do we need the test? devurandom: can't be safely guessed malloc0: can more or less be safely guessed to no
Diffstat (limited to 'tools')
-rwxr-xr-xtools/gen-bits-internal.sh9
-rwxr-xr-xtools/gen-bits.sh6
-rwxr-xr-xtools/gen-sysdepsh.sh39
3 files changed, 44 insertions, 10 deletions
diff --git a/tools/gen-bits-internal.sh b/tools/gen-bits-internal.sh
deleted file mode 100755
index 93e64ab..0000000
--- a/tools/gen-bits-internal.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh -e
-
-bits="$1"
-dfmt="$2"
-ofmt="$3"
-xfmt="$4"
-bfmt="$5"
-
-exec sed -e "s/@BITS@/$bits/g; s/@DFMT@/$dfmt/g; s/@OFMT@/$ofmt/g; s/@XFMT@/$xfmt/g; s/@BFMT@/$bfmt/g;" < src/headers/bits-template
diff --git a/tools/gen-bits.sh b/tools/gen-bits.sh
index 951a7d9..01aa9b8 100755
--- a/tools/gen-bits.sh
+++ b/tools/gen-bits.sh
@@ -7,6 +7,10 @@ ofmt="$4"
xfmt="$5"
bfmt="$6"
+gen_bits() {
+ sed -e "s/@BITS@/$1/g; s/@DFMT@/$2/g; s/@OFMT@/$3/g; s/@XFMT@/$4/g; s/@BFMT@/$5/g;" < src/headers/bits-template
+}
+
tools/gen-types-internal.sh "" "" "$bits" < src/headers/bits-header
if test "$bits" = 64 ; then
@@ -33,5 +37,5 @@ else
fi
tools/gen-types-internal.sh "" "" "$bits" < src/headers/bits-${endian}endian
-tools/gen-bits-internal.sh "$bits" "$dfmt" "$ofmt" "$xfmt" "$bfmt"
+gen_bits "$bits" "$dfmt" "$ofmt" "$xfmt" "$bfmt"
exec tools/gen-types-internal.sh "" "" "$bits" < src/headers/bits-footer
diff --git a/tools/gen-sysdepsh.sh b/tools/gen-sysdepsh.sh
new file mode 100755
index 0000000..f6194f2
--- /dev/null
+++ b/tools/gen-sysdepsh.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+cat <<EOF
+/* ISC license. */
+
+#ifndef SYSDEPS_H
+#define SYSDEPS_H
+
+#undef SKALIBS_TARGET
+#define SKALIBS_TARGET "$1"
+
+EOF
+
+while read k v ; do
+ k=$(echo "${k%%:}" | tr a-z A-Z)
+ if test ${k} != ${k##SIGNED} ; then
+ echo "#undef SKALIBS_HASUN$k"
+ echo "#undef SKALIBS_HAS$k"
+ if test $v = yes ; then
+ echo "#define SKALIBS_HAS$k"
+ else
+ echo "#define SKALIBS_HASUN$k"
+ fi
+ elif test ${k} != ${k##SIZEOF} ; then
+ echo "#undef SKALIBS_HAS$k"
+ echo "#define SKALIBS_HAS$k $v"
+ elif test ${k} = ENDIANNESS ; then
+ echo '#undef SKALIBS_ENDIANNESS'
+ echo "#define SKALIBS_ENDIANNESS $v"
+ else
+ echo "#undef SKALIBS_HAS$k"
+ if test $v = yes ; then
+ echo "#define SKALIBS_HAS$k"
+ fi
+ fi
+ echo
+done
+
+echo '#endif'