summaryrefslogtreecommitdiffstats
path: root/tests/load-archinfo
blob: 4c38f6b6a8d3abceb3c2b9db608405afa0560bd0 (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
# -*- 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
}