summaryrefslogtreecommitdiffstats
path: root/tests/fundamental-primitives
blob: 1c8a47ab00618b71965b321894bcf201501a7059 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# -*- sh -*-
# See LICENSE file for copyright and license details.

whole=$(getnum SECTION WHOLE)
noannotation=$(getnum ANNOTATION NONE)
for os in $(getnamelist OS); do
	osn=$(getnum OS $os)
	for arch in $(getnamelist ARCH); do
		archn=$(getnum ARCH $arch)
		if ! issupported $os $arch; then
			continue
		fi

		endian=$(getendian $arch)

		sign_representation=$(getsign $arch)
		if test ${sign_representation} = TWOS_COMPLEMENT; then
			min_is_minus_max=0
		elif test ${sign_representation} = ONES_COMPLEMENT; then
			min_is_minus_max=1
		elif test ${sign_representation} = SIGN_MAGNITUDE; then
			min_is_minus_max=1
		elif test ${sign_representation} = EXCESS_HALF; then
			min_is_minus_max=0
		else
			false # that's all we have for now
		fi
		sign_representation=$(getnum SIGN ${sign_representation})

		for n in $intsizes; do
			type=INT$n
			get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a
			grep "^width_in_bits = ${n}"\$ < $a >/dev/null
			grep "^array_size = 1"\$ < $a >/dev/null
			grep "^relative_position_of_array_size = 0"\$ < $a >/dev/null
			grep "^absolute_position_of_array_size = -1"\$ < $a >/dev/null
			grep "^is_signed = 1"\$ < $a >/dev/null
			grep "^is_unsigned = 0"\$ < $a >/dev/null
			grep "^min_is_minus_max = ${min_is_minus_max}"\$ < $a >/dev/null
			grep "^sign_representation = ${sign_representation}"\$ < $a >/dev/null
			grep "^annotation = ${noannotation}"\$ < $a >/dev/null
			grep "^section = ${whole}"\$ < $a >/dev/null
			grep "^byteorder = $(getbyteorder $n $endian)"\$ < $a >/dev/null

			type=UINT$n
			get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a
			grep "^width_in_bits = ${n}"\$ < $a >/dev/null
			grep "^array_size = 1"\$ < $a >/dev/null
			grep "^relative_position_of_array_size = 0"\$ < $a >/dev/null
			grep "^absolute_position_of_array_size = -1"\$ < $a >/dev/null
			grep "^is_signed = 0"\$ < $a >/dev/null
			grep "^is_unsigned = 1"\$ < $a >/dev/null
			grep "^annotation = ${noannotation}"\$ < $a >/dev/null
			grep "^section = ${whole}"\$ < $a >/dev/null
			grep "^byteorder = $(getbyteorder $n $endian)"\$ < $a >/dev/null
		done

		type=INT$(getaddrsize $arch)
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a
		type=INTPTR
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b
		diff -u $a $b

		type=INT$(getsizesize $arch)
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a
		type=SSIZE
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b
		diff -u $a $b

		type=VOID
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a
		grep "^width_in_bits = 0"\$ < $a >/dev/null
		grep "^array_size = 1"\$ < $a >/dev/null
		grep "^relative_position_of_array_size = 0"\$ < $a >/dev/null
		grep "^absolute_position_of_array_size = -1"\$ < $a >/dev/null
		grep "^is_signed = 0"\$ < $a >/dev/null
		grep "^is_unsigned = 0"\$ < $a >/dev/null
		grep "^annotation = ${noannotation}"\$ < $a >/dev/null
		grep "^section = ${whole}"\$ < $a >/dev/null
		grep "^byteorder =[[:space:]]*"\$ < $a >/dev/null
		type=NO_RETURN
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type | diff -u $a -

		type=INT
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a
		type=INT_SIGNAL
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b
		sed 's/^\(annotation\) .*$/\1 = '"$(getnum ANNOTATION SIGNAL)"'/' < $a | diff -u - $b
		type=INT_FD
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b
		sed 's/^\(annotation\) .*$/\1 = '"$(getnum ANNOTATION FD)"'/' < $a | diff -u - $b
		type=INT_ATFD
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b
		sed 's/^\(annotation\) .*$/\1 = '"$(getnum ANNOTATION ATFD)"'/' < $a | diff -u - $b

		type=LONG
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a
		type=LONG_FD
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b
		sed 's/^\(annotation\) .*$/\1 = '"$(getnum ANNOTATION FD)"'/' < $a | diff -u - $b
		type=LONG_ATFD
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b
		sed 's/^\(annotation\) .*$/\1 = '"$(getnum ANNOTATION ATFD)"'/' < $a | diff -u - $b

		for type in SCHAR SHORT INT LONG LLONG PTRDIFF INTPTR SSIZE; do
			if test $type = SCHAR; then
				utype=UCHAR
			elif test $type = SSIZE; then
				utype=SIZE
			else
				utype=U$type
			fi

			get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a
			grep "^width_in_bits = ." < $a >/dev/null
			grep "^array_size = 1"\$ < $a >/dev/null
			grep "^relative_position_of_array_size = 0"\$ < $a >/dev/null
			grep "^absolute_position_of_array_size = -1"\$ < $a >/dev/null
			grep "^is_signed = 1"\$ < $a >/dev/null
			grep "^is_unsigned = 0"\$ < $a >/dev/null
			grep "^min_is_minus_max = ${min_is_minus_max}"\$ < $a >/dev/null
			grep "^sign_representation = ${sign_representation}"\$ < $a >/dev/null
			grep "^annotation = ${noannotation}"\$ < $a >/dev/null
			grep "^section = ${whole}"\$ < $a >/dev/null
			n="$(grep "^width_in_bits = ." < $a | cut -d ' ' -f 3)"
			grep "^byteorder = $(getbyteorder $n $endian)"\$ < $a >/dev/null

			sed -e 's/^\(is_signed =\) .$/\1 0/' -e 's/^\(is_unsigned =\) .$/\1 1/' < $a > $b
			( ! diff -u $b $a > /dev/null)
			grep -v '^\(min_is_minus_max\|sign_representation\) = ' < $b > $a
			( ! diff -u $a $b > /dev/null)
			get-datatype-description.tu $osn $archn $(lookupnum "$types" $utype) $os $arch $utype > $b
			grep -v '^\(min_is_minus_max\|sign_representation\) = ' < $b | diff -u $a -

			if test $type = SCHAR; then
				xtypes=CHAR
			elif test $type = INTPTR; then
				xtypes="MEMORY_ADDRESS STRING STRINGS_THEN_NULL"
			else
				xtypes=
			fi
			for xtype in $xtypes; do
				get-datatype-description.tu $osn $archn $(lookupnum "$types" $xtype) $os $arch $xtype \
				| grep -v '^\(min_is_minus_max\|sign_representation\) = ' > $b
				sed 's/^\(is_\(un\)signed =\) .$/\1 0/' < $a | diff -u - $b
			done
		done

		type=INTPTR
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a
		type=PTRDIFF
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b
		diff -u $a $b

		type=DYNAMIC
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $a
		type=UNKNOWN
		get-datatype-description.tu $osn $archn $(lookupnum "$types" $type) $os $arch $type > $b
		diff -u $a $b
	done
done