summaryrefslogtreecommitdiffstats
path: root/tests/load-archinfo
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-12-05 20:10:48 +0100
committerMattias Andrée <maandree@kth.se>2023-12-05 20:10:48 +0100
commit6d77b155bcd4725e09837604e6ea86f5f124ba9c (patch)
tree7cfdf466bb94bbbe3e7929432bc048da5eaa2349 /tests/load-archinfo
parentSecond commit (diff)
downloadlibsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.gz
libsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.bz2
libsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.xz
Third commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--tests/load-archinfo41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/load-archinfo b/tests/load-archinfo
new file mode 100644
index 0000000..4c38f6b
--- /dev/null
+++ b/tests/load-archinfo
@@ -0,0 +1,41 @@
+# -*- sh -*-
+# See LICENSE file for copyright and license details.
+
+#in this test, we are assuming that char is 8 bits
+intsizes="8 16 32 64"
+cat > $b <<.
+8Little 0
+16Little 0 8
+32Little 0 8 16 24
+64Little 0 8 16 24 32 40 48 56
+8Big 0
+16Big 8 0
+32Big 24 16 8 0
+64Big 56 48 40 32 24 16 8 0
+.
+byteorders="$(cat $b)"
+getbyteorder () {
+ printf '%s\n' "$byteorders" | grep "^$1$2 " | cut -d ' ' -f 2-
+}
+
+sed '1,/LIST_ARCH_SPECS/d' < libsyscalls_get_datatype_description.c \
+| sed '/#include/q' \
+| sed 's/\(TO''DO\)\s*([^)]*)/\1/g' \
+| sed -n 's/^\s*[A-Z_]\+(LIBSYSCALLS_ARCH_\([^)]*\)).*$/\1/p' \
+| sed 's/,\s*/ /g' > $b
+archinfo="$(cat $b)"
+getbytesize () {
+ printf '%s\n' "$archinfo" | grep "^$1 " | cut -d ' ' -f 2
+}
+getaddrsize () {
+ printf '%s\n' "$archinfo" | grep "^$1 " | cut -d ' ' -f 3
+}
+getsizesize () {
+ printf '%s\n' "$archinfo" | grep "^$1 " | cut -d ' ' -f 4
+}
+getendian () {
+ printf '%s\n' "$archinfo" | grep "^$1 " | cut -d ' ' -f 5
+}
+getsign () {
+ printf '%s\n' "$archinfo" | grep "^$1 " | cut -d ' ' -f 6
+}