summaryrefslogblamecommitdiffstats
path: root/tests/fundamental-primitives
blob: 4068934528b69cf44314eb92986566d107337cf9 (plain) (tree)
































































































































































                                                                                                                       
# -*- 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 =\s*"\$ < $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