]>
Commit | Line | Data |
---|---|---|
14c3c235 | 1 | #!/bin/sh |
59a4f90e | 2 | LC_ALL=C |
3 | export LC_ALL | |
14c3c235 | 4 | |
5 | compile="$1" | |
6 | ||
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" | |
10 | ||
11 | ||
12 | largest="" | |
65a5a63e | 13 | smallest="" |
14c3c235 | 14 | for k in $possible_integer_kinds; do |
15 | echo " integer (kind=$k) :: i" > tmp$$.f90 | |
eae83ec6 | 16 | echo " i = 1_$k" >> tmp$$.f90 |
14c3c235 | 17 | echo " end" >> tmp$$.f90 |
bd978a47 | 18 | if $compile -S tmp$$.f90 > /dev/null 2>&1; then |
14c3c235 | 19 | s=`expr 8 \* $k` |
20 | largest="$k" | |
21 | ||
22 | if [ $s -eq 128 ]; then | |
23 | prefix="__" | |
24 | else | |
25 | prefix="" | |
26 | fi | |
27 | ||
65a5a63e | 28 | if [ "$smallest" = "" ]; then |
29 | smallest="$k" | |
30 | fi | |
31 | ||
14c3c235 | 32 | echo "typedef ${prefix}int${s}_t GFC_INTEGER_${k};" |
33 | echo "typedef ${prefix}uint${s}_t GFC_UINTEGER_${k};" | |
34 | echo "typedef GFC_INTEGER_${k} GFC_LOGICAL_${k};" | |
920e54ef | 35 | echo "#define HAVE_GFC_LOGICAL_${k}" |
14c3c235 | 36 | echo "#define HAVE_GFC_INTEGER_${k}" |
4a8a06d3 | 37 | echo "" |
14c3c235 | 38 | fi |
39 | rm -f tmp$$.* | |
40 | done | |
41 | ||
42 | echo "#define GFC_INTEGER_LARGEST GFC_INTEGER_${largest}" | |
43 | echo "#define GFC_UINTEGER_LARGEST GFC_UINTEGER_${largest}" | |
65a5a63e | 44 | echo "#define GFC_DEFAULT_CHAR ${smallest}" |
14c3c235 | 45 | echo "" |
46 | ||
87969c8c | 47 | |
48 | # Get the kind value for long double, so we may disambiguate it | |
49 | # from __float128. | |
50 | echo "use iso_c_binding; print *, c_long_double ; end" > tmq$$.f90 | |
51 | long_double_kind=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \ | |
52 | | sed 's/ *TRANSFER *//'` | |
53 | rm -f tmq$$.* | |
54 | ||
14c3c235 | 55 | |
14c3c235 | 56 | for k in $possible_real_kinds; do |
57 | echo " real (kind=$k) :: x" > tmp$$.f90 | |
eae83ec6 | 58 | echo " x = 1.0_$k" >> tmp$$.f90 |
14c3c235 | 59 | echo " end" >> tmp$$.f90 |
bd978a47 | 60 | if $compile -S tmp$$.f90 > /dev/null 2>&1; then |
14c3c235 | 61 | case $k in |
87969c8c | 62 | 4) ctype="float" ; cplxtype="complex float" ; suffix="f" ;; |
63 | 8) ctype="double" ; cplxtype="complex double" ; suffix="" ;; | |
64 | 10) ctype="long double" ; cplxtype="complex long double" ; suffix="l" ;; | |
65 | 16) if [ $long_double_kind -eq 10 ]; then | |
66 | ctype="__float128" | |
67 | cplxtype="_Complex float __attribute__((mode(TC)))" | |
68 | suffix="q" | |
69 | else | |
70 | ctype="long double" | |
71 | cplxtype="complex long double" | |
72 | suffix="l" | |
73 | fi ;; | |
14c3c235 | 74 | *) echo "$0: Unknown type" >&2 ; exit 1 ;; |
75 | esac | |
4a8a06d3 | 76 | |
77 | # Check for the value of HUGE | |
78 | echo "print *, huge(0._$k) ; end" > tmq$$.f90 | |
bd978a47 | 79 | huge=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \ |
27843232 | 80 | | sed 's/ *TRANSFER *//' | sed 's/_.*//'` |
4a8a06d3 | 81 | rm -f tmq$$.* |
82 | ||
83 | # Check for the value of DIGITS | |
84 | echo "print *, digits(0._$k) ; end" > tmq$$.f90 | |
bd978a47 | 85 | digits=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \ |
4a8a06d3 | 86 | | sed 's/ *TRANSFER *//'` |
87 | rm -f tmq$$.* | |
88 | ||
89 | # Check for the value of RADIX | |
90 | echo "print *, radix(0._$k) ; end" > tmq$$.f90 | |
bd978a47 | 91 | radix=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \ |
4a8a06d3 | 92 | | sed 's/ *TRANSFER *//'` |
93 | rm -f tmq$$.* | |
94 | ||
95 | # Output the information we've gathered | |
14c3c235 | 96 | echo "typedef ${ctype} GFC_REAL_${k};" |
87969c8c | 97 | echo "typedef ${cplxtype} GFC_COMPLEX_${k};" |
14c3c235 | 98 | echo "#define HAVE_GFC_REAL_${k}" |
920e54ef | 99 | echo "#define HAVE_GFC_COMPLEX_${k}" |
4a8a06d3 | 100 | echo "#define GFC_REAL_${k}_HUGE ${huge}${suffix}" |
e099d7cd | 101 | echo "#define GFC_REAL_${k}_LITERAL_SUFFIX ${suffix}" |
102 | if [ "x$suffix" = "x" ]; then | |
103 | echo "#define GFC_REAL_${k}_LITERAL(X) (X)" | |
104 | else | |
105 | echo "#define GFC_REAL_${k}_LITERAL(X) (X ## ${suffix})" | |
106 | fi | |
4a8a06d3 | 107 | echo "#define GFC_REAL_${k}_DIGITS ${digits}" |
108 | echo "#define GFC_REAL_${k}_RADIX ${radix}" | |
109 | echo "" | |
14c3c235 | 110 | fi |
111 | rm -f tmp$$.* | |
112 | done | |
113 | ||
87969c8c | 114 | |
115 | # After this, we include a header that can override some of the | |
116 | # autodetected settings. | |
117 | echo '#include "kinds-override.h"' | |
118 | ||
14c3c235 | 119 | exit 0 |