5 if test "$#" -ne 3; then
6 echo "Usage $0 int_kinds real_kinds compile"
10 # Possible kinds must be listed in ascending order
11 possible_integer_kinds
="$1"
12 possible_real_kinds
="$2"
17 for k
in $possible_integer_kinds; do
18 echo " integer (kind=$k) :: i" > tmp$$.f90
19 echo " i = 1_$k" >> tmp$$.f90
20 echo " end" >> tmp$$.f90
21 if $compile -S tmp$$.f90
> /dev
/null
2>&1; then
25 if [ $s -eq 128 ]; then
31 if [ "$smallest" = "" ]; then
35 echo "typedef ${prefix}int${s}_t GFC_INTEGER_${k};"
36 echo "typedef ${prefix}uint${s}_t GFC_UINTEGER_${k};"
37 echo "typedef GFC_INTEGER_${k} GFC_LOGICAL_${k};"
38 echo "#define HAVE_GFC_LOGICAL_${k} 1"
39 echo "#define HAVE_GFC_INTEGER_${k} 1"
45 echo "#define GFC_INTEGER_LARGEST GFC_INTEGER_${largest}"
46 echo "#define GFC_UINTEGER_LARGEST GFC_UINTEGER_${largest}"
47 echo "#define GFC_DEFAULT_CHAR ${smallest}"
51 # Get the kind value for long double, so we may disambiguate it
53 echo "use iso_c_binding; print *, c_long_double ; end" > tmq$$.f90
54 long_double_kind
=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
55 | sed 's/ *TRANSFER *//'`
59 for k
in $possible_real_kinds; do
60 echo " real (kind=$k) :: x" > tmp$$.f90
61 echo " x = 1.0_$k" >> tmp$$.f90
62 echo " end" >> tmp$$.f90
63 if $compile -S tmp$$.f90
> /dev
/null
2>&1; then
65 4) ctype
="float" ; cplxtype
="complex float" ; suffix
="f" ;;
66 8) ctype
="double" ; cplxtype
="complex double" ; suffix
="" ;;
67 10) ctype
="long double" ; cplxtype
="complex long double" ; suffix
="l" ;;
68 16) if [ $long_double_kind -eq 10 ]; then
70 cplxtype
="_Complex float __attribute__((mode(TC)))"
74 cplxtype
="complex long double"
77 *) echo "$0: Unknown type" >&2 ; exit 1 ;;
80 # Check for the value of HUGE
81 echo "print *, huge(0._$k) ; end" > tmq$$.f90
82 huge
=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
83 | sed 's/ *TRANSFER *//' | sed 's/_.*//'`
86 # Check for the value of DIGITS
87 echo "print *, digits(0._$k) ; end" > tmq$$.f90
88 digits
=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
89 | sed 's/ *TRANSFER *//'`
92 # Check for the value of RADIX
93 echo "print *, radix(0._$k) ; end" > tmq$$.f90
94 radix
=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
95 | sed 's/ *TRANSFER *//'`
98 # Output the information we've gathered
99 echo "typedef ${ctype} GFC_REAL_${k};"
100 echo "typedef ${cplxtype} GFC_COMPLEX_${k};"
101 echo "#define HAVE_GFC_REAL_${k} 1"
102 echo "#define HAVE_GFC_COMPLEX_${k} 1"
103 echo "#define GFC_REAL_${k}_HUGE ${huge}${suffix}"
104 echo "#define GFC_REAL_${k}_LITERAL_SUFFIX ${suffix}"
105 if [ "x$suffix" = "x" ]; then
106 echo "#define GFC_REAL_${k}_LITERAL(X) (X)"
108 echo "#define GFC_REAL_${k}_LITERAL(X) (X ## ${suffix})"
110 echo "#define GFC_REAL_${k}_DIGITS ${digits}"
111 echo "#define GFC_REAL_${k}_RADIX ${radix}"
117 # For ISO_Fortran_binding.h
118 for k
in "C_LONG_DOUBLE" "C_FLOAT128" "C_INT128_T"; do
120 echo "use iso_c_binding, only: $k; end" > tmp$$.f90
121 if $compile -S -fdump-parse-tree tmp$$.f90
> "$fname"; then
122 kind
=`grep "value:" "$fname" |grep value: | sed -e 's/.*value: *//'`
123 if [ "x$kind" = "x" ]; then
124 echo "ERROR: Failed to extract kind for $k" 1>&2
127 echo "#define GFC_${k}_KIND ${kind}"
129 echo "ERROR: Failed to extract kind for $k" 1>&2
135 # After this, we include a header that can override some of the
136 # autodetected settings.
137 echo '#include "kinds-override.h"'