#define CFI_attribute_other 2
/* Error codes.
- CFI_INVALID_STRIDE should be defined in the standard because they are useful to the implementation of the functions.
- */
+ Note that CFI_FAILURE and CFI_INVALID_STRIDE are specific to GCC
+ and not part of the Fortran standard */
#define CFI_SUCCESS 0
#define CFI_FAILURE 1
#define CFI_ERROR_BASE_ADDR_NULL 2
#define CFI_type_other -1
/* Types with kind parameter.
- The kind parameter represents the type's byte size. The exception is kind = 10, which has byte size of 64 but 80 bit precision. Complex variables are double the byte size of their real counterparts. The ucs4_char matches wchar_t if sizeof (wchar_t) == 4.
+ The kind parameter represents the type's byte size. The exception is
+ real kind = 10, which has byte size of 128 bits but 80 bit precision.
+ Complex variables are double the byte size of their real counterparts.
+ The ucs4_char matches wchar_t if sizeof (wchar_t) == 4.
*/
#define CFI_type_char (CFI_type_Character + (1 << CFI_type_kind_shift))
#define CFI_type_ucs4_char (CFI_type_Character + (4 << CFI_type_kind_shift))
/* C-Fortran Interoperability types. */
-#define CFI_type_signed_char (CFI_type_Integer + (1 << CFI_type_kind_shift))
-#define CFI_type_short (CFI_type_Integer + (2 << CFI_type_kind_shift))
-#define CFI_type_int (CFI_type_Integer + (4 << CFI_type_kind_shift))
-#define CFI_type_long (CFI_type_Integer + (8 << CFI_type_kind_shift))
-#define CFI_type_long_long (CFI_type_Integer + (8 << CFI_type_kind_shift))
-#define CFI_type_size_t (CFI_type_Integer + (8 << CFI_type_kind_shift))
-#define CFI_type_int8_t (CFI_type_Integer + (1 << CFI_type_kind_shift))
-#define CFI_type_int16_t (CFI_type_Integer + (2 << CFI_type_kind_shift))
-#define CFI_type_int32_t (CFI_type_Integer + (4 << CFI_type_kind_shift))
-#define CFI_type_int64_t (CFI_type_Integer + (8 << CFI_type_kind_shift))
-#define CFI_type_int_least8_t (CFI_type_Integer + (1 << CFI_type_kind_shift))
-#define CFI_type_int_least16_t (CFI_type_Integer + (2 << CFI_type_kind_shift))
-#define CFI_type_int_least32_t (CFI_type_Integer + (4 << CFI_type_kind_shift))
-#define CFI_type_int_least64_t (CFI_type_Integer + (8 << CFI_type_kind_shift))
-#define CFI_type_int_fast8_t (CFI_type_Integer + (1 << CFI_type_kind_shift))
-#define CFI_type_int_fast16_t (CFI_type_Integer + (2 << CFI_type_kind_shift))
-#define CFI_type_int_fast32_t (CFI_type_Integer + (4 << CFI_type_kind_shift))
-#define CFI_type_int_fast64_t (CFI_type_Integer + (8 << CFI_type_kind_shift))
-#define CFI_type_intmax_t (CFI_type_Integer + (8 << CFI_type_kind_shift))
-#define CFI_type_intptr_t (CFI_type_Integer + (8 << CFI_type_kind_shift))
-#define CFI_type_ptrdiff_t (CFI_type_Integer + (8 << CFI_type_kind_shift))
-#define CFI_type_int128_t (CFI_type_Integer + (16 << CFI_type_kind_shift))
-#define CFI_type_int_least128_t (CFI_type_Integer + (16 << CFI_type_kind_shift))
-#define CFI_type_int_fast128_t (CFI_type_Integer + (16 << CFI_type_kind_shift))
-#define CFI_type_Bool (CFI_type_Logical + (1 << CFI_type_kind_shift))
-#define CFI_type_float (CFI_type_Real + (4 << CFI_type_kind_shift))
-#define CFI_type_double (CFI_type_Real + (8 << CFI_type_kind_shift))
-#define CFI_type_long_double (CFI_type_Real + (10 << CFI_type_kind_shift))
-#define CFI_type_float128 (CFI_type_Real + (16 << CFI_type_kind_shift))
-#define CFI_type_float_Complex (CFI_type_Complex + (4 << CFI_type_kind_shift))
-#define CFI_type_double_Complex (CFI_type_Complex + (8 << CFI_type_kind_shift))
-#define CFI_type_long_double_Complex (CFI_type_Complex + (10 << CFI_type_kind_shift))
-#define CFI_type_float128_Complex (CFI_type_Complex + (16 << CFI_type_kind_shift))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ISO_FORTRAN_BINDING_H */
+#define CFI_type_signed_char (CFI_type_Integer + (sizeof (char) << CFI_type_kind_shift))
+#define CFI_type_short (CFI_type_Integer + (sizeof (short) << CFI_type_kind_shift))
+#define CFI_type_int (CFI_type_Integer + (sizeof (int) << CFI_type_kind_shift))
+#define CFI_type_long (CFI_type_Integer + (sizeof (long) << CFI_type_kind_shift))
+#define CFI_type_long_long (CFI_type_Integer + (sizeof (long long) << CFI_type_kind_shift))
+#define CFI_type_size_t (CFI_type_Integer + (sizeof (size_t) << CFI_type_kind_shift))
+#define CFI_type_int8_t (CFI_type_Integer + (sizeof (int8_t) << CFI_type_kind_shift))
+#define CFI_type_int16_t (CFI_type_Integer + (sizeof (int16_t) << CFI_type_kind_shift))
+#define CFI_type_int32_t (CFI_type_Integer + (sizeof (int32_t) << CFI_type_kind_shift))
+#define CFI_type_int64_t (CFI_type_Integer + (sizeof (int64_t) << CFI_type_kind_shift))
+#define CFI_type_int_least8_t (CFI_type_Integer + (sizeof (int_least8_t) << CFI_type_kind_shift))
+#define CFI_type_int_least16_t (CFI_type_Integer + (sizeof (int_least16_t) << CFI_type_kind_shift))
+#define CFI_type_int_least32_t (CFI_type_Integer + (sizeof (int_least32_t) << CFI_type_kind_shift))
+#define CFI_type_int_least64_t (CFI_type_Integer + (sizeof (int_least64_t) << CFI_type_kind_shift))
+#define CFI_type_int_fast8_t (CFI_type_Integer + (sizeof (int_fast8_t) << CFI_type_kind_shift))
+#define CFI_type_int_fast16_t (CFI_type_Integer + (sizeof (int_fast16_t) << CFI_type_kind_shift))
+#define CFI_type_int_fast32_t (CFI_type_Integer + (sizeof (int_fast32_t) << CFI_type_kind_shift))
+#define CFI_type_int_fast64_t (CFI_type_Integer + (sizeof (int_fast64_t) << CFI_type_kind_shift))
+#define CFI_type_intmax_t (CFI_type_Integer + (sizeof (intmax_t) << CFI_type_kind_shift))
+#define CFI_type_intptr_t (CFI_type_Integer + (sizeof (intptr_t) << CFI_type_kind_shift))
+#define CFI_type_ptrdiff_t (CFI_type_Integer + (sizeof (ptrdiff_t) << CFI_type_kind_shift))
+#define CFI_type_Bool (CFI_type_Logical + (sizeof (_Bool) << CFI_type_kind_shift))
+#define CFI_type_float (CFI_type_Real + (sizeof (float) << CFI_type_kind_shift))
+#define CFI_type_double (CFI_type_Real + (sizeof (double) << CFI_type_kind_shift))
+#define CFI_type_float_Complex (CFI_type_Complex + (sizeof (float) << CFI_type_kind_shift))
+#define CFI_type_double_Complex (CFI_type_Complex + (sizeof (double) << CFI_type_kind_shift))
--- /dev/null
+#include "config.h"
+#include "kinds.inc"
+
+/* Note that -1 is used by CFI_type_other, hence, -2 is used for unavailable kinds. */
+
+#if GFC_C_INT128_T_KIND == 16
+#define CFI_type_int128_t (CFI_type_Integer + (16 << CFI_type_kind_shift))
+#define CFI_type_int_least128_t (CFI_type_Integer + (16 << CFI_type_kind_shift))
+#define CFI_type_int_fast128_t (CFI_type_Integer + (16 << CFI_type_kind_shift))
+#elif GFC_C_INT128_T_KIND < 0
+#define CFI_type_int128_t -2
+#define CFI_type_int_least128_t -2
+#define CFI_type_int_fast128_t -2
+#else
+#error "Unexpected value for GFC_C_INT128_T_KIND"
+#endif
+
+#if GFC_C_LONG_DOUBLE_KIND == 16
+#define CFI_type_long_double (CFI_type_Real + (16 << CFI_type_kind_shift))
+#define CFI_type_long_double_Complex (CFI_type_Complex + (16 << CFI_type_kind_shift))
+#elif GFC_C_LONG_DOUBLE_KIND == 10
+#define CFI_type_long_double (CFI_type_Real + (10 << CFI_type_kind_shift))
+#define CFI_type_long_double_Complex (CFI_type_Complex + (10 << CFI_type_kind_shift))
+#elif GFC_C_LONG_DOUBLE_KIND == 8
+#define CFI_type_long_double (CFI_type_Real + (8 << CFI_type_kind_shift))
+#define CFI_type_long_double_Complex (CFI_type_Complex + (8 << CFI_type_kind_shift))
+#elif GFC_C_LONG_DOUBLE_KIND < 0
+#define CFI_type_long_double -2
+#define CFI_type_long_double_Complex -2
+#else
+#error "Unexpected value for GFC_C_LONG_DOUBLE_KIND"
+#endif
+
+#if GFC_C_FLOAT128_KIND == 16
+#define CFI_type_float128 (CFI_type_Real + (16 << CFI_type_kind_shift))
+#define CFI_type_float128_Complex (CFI_type_Complex + (16 << CFI_type_kind_shift))
+#elif GFC_C_FLOAT128_KIND < 0
+#define CFI_type_float128 -2
+#define CFI_type_float128_Complex -2
+#else
+#error "Unexpected value for GFC_C_FLOAT128_KIND"
+#endif
--- /dev/null
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ISO_FORTRAN_BINDING_H */
version_dep =
endif
-gfor_c_HEADERS = $(srcdir)/ISO_Fortran_binding.h
-gfor_cdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
+gfor_c_HEADERS = ISO_Fortran_binding.h
+gfor_cdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/include
LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) \
$(lt_host_flags)
$(i_pow_c) $(i_pack_c) $(i_unpack_c) $(i_matmulavx128_c) \
$(i_spread_c) selected_int_kind.inc selected_real_kind.inc kinds.h \
$(i_cshift0_c) kinds.inc c99_protos.inc fpu-target.h fpu-target.inc \
+ ISO_Fortran_binding.h \
$(i_cshift1a_c) $(i_maxloc0s_c) $(i_minloc0s_c) $(i_maxloc1s_c) \
$(i_minloc1s_c) $(i_maxloc2s_c) $(i_minloc2s_c) $(i_maxvals_c) \
$(i_maxval0s_c) $(i_minval0s_c) $(i_maxval1s_c) $(i_minval1s_c) \
grep '^#define GFC_FPE_' < $(top_srcdir)/../gcc/fortran/libgfortran.h > $@ || true
grep '^#define GFC_FPE_' < $(srcdir)/libgfortran.h >> $@ || true
+ISO_Fortran_binding.h: $(srcdir)/ISO_Fortran_binding-1-tmpl.h \
+ $(srcdir)/ISO_Fortran_binding-2-tmpl.h \
+ $(srcdir)/ISO_Fortran_binding-3-tmpl.h \
+ kinds.inc
+ -rm -f $@
+ cp $(srcdir)/ISO_Fortran_binding-1-tmpl.h $@
+ $(COMPILE) -E -dD $(srcdir)/ISO_Fortran_binding-2-tmpl.h \
+ | grep '^#define CFI_type' >> $@
+ cat $(srcdir)/ISO_Fortran_binding-3-tmpl.h >> $@
+
## A 'normal' build shouldn't need to regenerate these
## so we only include them in maintainer mode
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@LIBGFOR_USE_SYMVER_FALSE@version_dep =
@LIBGFOR_USE_SYMVER_GNU_TRUE@@LIBGFOR_USE_SYMVER_TRUE@version_dep = $(srcdir)/gfortran.map
@LIBGFOR_USE_SYMVER_SUN_TRUE@@LIBGFOR_USE_SYMVER_TRUE@version_dep = gfortran.map-sun
-gfor_c_HEADERS = $(srcdir)/ISO_Fortran_binding.h
-gfor_cdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
+gfor_c_HEADERS = ISO_Fortran_binding.h
+gfor_cdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/include
LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) \
$(lt_host_flags)
$(i_pow_c) $(i_pack_c) $(i_unpack_c) $(i_matmulavx128_c) \
$(i_spread_c) selected_int_kind.inc selected_real_kind.inc kinds.h \
$(i_cshift0_c) kinds.inc c99_protos.inc fpu-target.h fpu-target.inc \
+ ISO_Fortran_binding.h \
$(i_cshift1a_c) $(i_maxloc0s_c) $(i_minloc0s_c) $(i_maxloc1s_c) \
$(i_minloc1s_c) $(i_maxloc2s_c) $(i_minloc2s_c) $(i_maxvals_c) \
$(i_maxval0s_c) $(i_minval0s_c) $(i_maxval1s_c) $(i_minval1s_c) \
grep '^#define GFC_FPE_' < $(top_srcdir)/../gcc/fortran/libgfortran.h > $@ || true
grep '^#define GFC_FPE_' < $(srcdir)/libgfortran.h >> $@ || true
+ISO_Fortran_binding.h: $(srcdir)/ISO_Fortran_binding-1-tmpl.h \
+ $(srcdir)/ISO_Fortran_binding-2-tmpl.h \
+ $(srcdir)/ISO_Fortran_binding-3-tmpl.h \
+ kinds.inc
+ -rm -f $@
+ cp $(srcdir)/ISO_Fortran_binding-1-tmpl.h $@
+ $(COMPILE) -E -dD $(srcdir)/ISO_Fortran_binding-2-tmpl.h \
+ | grep '^#define CFI_type' >> $@
+ cat $(srcdir)/ISO_Fortran_binding-3-tmpl.h >> $@
+
@MAINTAINER_MODE_TRUE@$(i_all_c): m4/all.m4 $(I_M4_DEPS2)
@MAINTAINER_MODE_TRUE@ $(M4) -Dfile=$@ -I$(srcdir)/m4 all.m4 > $@
echo "typedef ${prefix}int${s}_t GFC_INTEGER_${k};"
echo "typedef ${prefix}uint${s}_t GFC_UINTEGER_${k};"
echo "typedef GFC_INTEGER_${k} GFC_LOGICAL_${k};"
- echo "#define HAVE_GFC_LOGICAL_${k}"
- echo "#define HAVE_GFC_INTEGER_${k}"
+ echo "#define HAVE_GFC_LOGICAL_${k} 1"
+ echo "#define HAVE_GFC_INTEGER_${k} 1"
echo ""
fi
rm -f tmp$$.*
# Output the information we've gathered
echo "typedef ${ctype} GFC_REAL_${k};"
echo "typedef ${cplxtype} GFC_COMPLEX_${k};"
- echo "#define HAVE_GFC_REAL_${k}"
- echo "#define HAVE_GFC_COMPLEX_${k}"
+ echo "#define HAVE_GFC_REAL_${k} 1"
+ echo "#define HAVE_GFC_COMPLEX_${k} 1"
echo "#define GFC_REAL_${k}_HUGE ${huge}${suffix}"
echo "#define GFC_REAL_${k}_LITERAL_SUFFIX ${suffix}"
if [ "x$suffix" = "x" ]; then
rm -f tmp$$.*
done
+# For ISO_Fortran_binding.h
+for k in "C_LONG_DOUBLE" "C_FLOAT128" "C_INT128_T"; do
+ fname="tmp$$.val"
+ echo "use iso_c_binding, only: $k; end" > tmp$$.f90
+ if $compile -S -fdump-parse-tree tmp$$.f90 > "$fname"; then
+ kind=`grep "value:" "$fname" |grep value: | sed -e 's/.*value: *//'`
+ if [ "x$kind" = "x" ]; then
+ echo "ERROR: Failed to extract kind for $k" 1>&2
+ exit 1
+ fi
+ echo "#define GFC_${k}_KIND ${kind}"
+ else
+ echo "ERROR: Failed to extract kind for $k" 1>&2
+ exit 1
+ fi
+ rm -f tmp$$.*
+done
# After this, we include a header that can override some of the
# autodetected settings.
<http://www.gnu.org/licenses/>. */
#include "libgfortran.h"
-#include <ISO_Fortran_binding.h>
+#include "ISO_Fortran_binding.h"
#include <string.h>
extern void cfi_desc_to_gfc_desc (gfc_array_void *, CFI_cdesc_t **);