summaryrefslogtreecommitdiffstats
path: root/tests/load-archinfo
blob: 8e6b2a6cac9e90a7c2078482bc541e879d0bf4f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- 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' < common.h \
| sed '/#include/q' \
| sed 's/\(TO''DO\)[[:space:]]*([^)]*)/\1/g' \
| sed -n 's/^[[:space:]]*[A-Z_]\{1,\}(LIBSYSCALLS_ARCH_\([^)]*\)).*$/\1/p' \
| sed 's/,[[:space:]]*/ /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
}
getintalign () {
    printf '%s\n' "$archinfo" | grep "^$1 " | cut -d ' ' -f 5
}
getendian () {
    printf '%s\n' "$archinfo" | grep "^$1 " | cut -d ' ' -f 6
}
getsign () {
    printf '%s\n' "$archinfo" | grep "^$1 " | cut -d ' ' -f 7
}