PR c++/34196
[official-gcc.git] / libgfortran / mk-kinds-h.sh
blob6e893ff5ee73e7e0b72c6873f8c0638837c89a78
1 #!/bin/sh
2 LC_ALL=C
3 export LC_ALL
5 compile="$1"
7 # Possible types must be listed in ascending order
8 possible_integer_kinds="1 2 4 8 16"
9 possible_real_kinds="4 8 10 16"
12 largest=""
13 smallest=""
14 for k in $possible_integer_kinds; do
15 echo " integer (kind=$k) :: i" > tmp$$.f90
16 echo " end" >> tmp$$.f90
17 if $compile -S tmp$$.f90 > /dev/null 2>&1; then
18 s=`expr 8 \* $k`
19 largest="$k"
21 if [ $s -eq 128 ]; then
22 prefix="__"
23 else
24 prefix=""
27 if [ "$smallest" = "" ]; then
28 smallest="$k"
31 echo "typedef ${prefix}int${s}_t GFC_INTEGER_${k};"
32 echo "typedef ${prefix}uint${s}_t GFC_UINTEGER_${k};"
33 echo "typedef GFC_INTEGER_${k} GFC_LOGICAL_${k};"
34 echo "#define HAVE_GFC_LOGICAL_${k}"
35 echo "#define HAVE_GFC_INTEGER_${k}"
36 echo ""
38 rm -f tmp$$.*
39 done
41 echo "#define GFC_INTEGER_LARGEST GFC_INTEGER_${largest}"
42 echo "#define GFC_UINTEGER_LARGEST GFC_UINTEGER_${largest}"
43 echo "#define GFC_DEFAULT_CHAR ${smallest}"
44 echo ""
47 for k in $possible_real_kinds; do
48 echo " real (kind=$k) :: x" > tmp$$.f90
49 echo " end" >> tmp$$.f90
50 if $compile -S tmp$$.f90 > /dev/null 2>&1; then
51 case $k in
52 4) ctype="float" ; suffix="f" ;;
53 8) ctype="double" ; suffix="" ;;
54 10) ctype="long double" ; suffix="l" ;;
55 16) ctype="long double" ; suffix="l" ;;
56 *) echo "$0: Unknown type" >&2 ; exit 1 ;;
57 esac
59 # Check for the value of HUGE
60 echo "print *, huge(0._$k) ; end" > tmq$$.f90
61 huge=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
62 | sed 's/ *TRANSFER *//' | sed 's/_.*//'`
63 rm -f tmq$$.*
65 # Check for the value of DIGITS
66 echo "print *, digits(0._$k) ; end" > tmq$$.f90
67 digits=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
68 | sed 's/ *TRANSFER *//'`
69 rm -f tmq$$.*
71 # Check for the value of RADIX
72 echo "print *, radix(0._$k) ; end" > tmq$$.f90
73 radix=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
74 | sed 's/ *TRANSFER *//'`
75 rm -f tmq$$.*
77 # Output the information we've gathered
78 echo "typedef ${ctype} GFC_REAL_${k};"
79 echo "typedef complex ${ctype} GFC_COMPLEX_${k};"
80 echo "#define HAVE_GFC_REAL_${k}"
81 echo "#define HAVE_GFC_COMPLEX_${k}"
82 echo "#define GFC_REAL_${k}_HUGE ${huge}${suffix}"
83 echo "#define GFC_REAL_${k}_DIGITS ${digits}"
84 echo "#define GFC_REAL_${k}_RADIX ${radix}"
85 echo ""
87 rm -f tmp$$.*
88 done
90 exit 0