aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2019-01-12 15:25:52 +0000
committerPaul Thomas <pault@gcc.gnu.org>2019-01-12 15:25:52 +0000
commitbbf18dc5d248a79a20ebf4b3a751669cd75485fd (patch)
treedfff4a53d274e517577746cfd677e88335f966dd /libgfortran
parentaf79605ec27c0db7dee9ee001cd7d768eb6fcf02 (diff)
downloadgcc-bbf18dc5d248a79a20ebf4b3a751669cd75485fd.zip
gcc-bbf18dc5d248a79a20ebf4b3a751669cd75485fd.tar.gz
gcc-bbf18dc5d248a79a20ebf4b3a751669cd75485fd.tar.bz2
gfortran.texi: Add description in sections on TS 29113 and further interoperability with C.
2019-01-12 Paul Thomas <pault@gcc.gnu.org> * gfortran.texi : Add description in sections on TS 29113 and further interoperability with C. * trans-array.c (gfc_conv_descriptor_attribute): New function. (gfc_get_dataptr_offset): Remove static function attribute. * trans-array.h : Add prototypes for above functions. * trans-decl.c : Add declarations for the library functions cfi_desc_to_gfc_desc and gfc_desc_to_cfi_desc. * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): New function. (gfc_conv_procedure_call): Call it for scalar and array actual arguments, when the formal arguments are bind_c with assumed shape or assumed rank. * trans.h : External declarations for gfor_fndecl_cfi_to_gfc and gfor_fndecl_gfc_to_cfi. 2019-01-12 Paul Thomas <pault@gcc.gnu.org> * gfortran.dg/ISO_Fortran_binding_1.f90 : New test. * gfortran.dg/ISO_Fortran_binding_1.c : Auxilliary file for test. * gfortran.dg/ISO_Fortran_binding_2.f90 : New test. * gfortran.dg/ISO_Fortran_binding_2.c : Auxilliary file for test. * gfortran.dg/bind_c_array_params_2.f90 : Change search string for dump tree scan. 2019-01-12 Paul Thomas <pault@gcc.gnu.org> * ISO_Fortran_binding.h : New file. * Makefile.am : Include ISO_Fortran_binding.c in the list of files to compile. * Makefile.in : Regenerated. * gfortran.map : Add _gfortran_cfi_desc_to_gfc_desc, _gfortran_gfc_desc_to_cfi_desc and the CFI API functions. * runtime/ISO_Fortran_binding.c : New file containing the new functions added to the map. From-SVN: r267881
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog11
-rw-r--r--libgfortran/ISO_Fortran_binding.h206
-rw-r--r--libgfortran/Makefile.am8
-rw-r--r--libgfortran/Makefile.in127
-rwxr-xr-xlibgfortran/configure28
-rw-r--r--libgfortran/gfortran.map10
-rw-r--r--libgfortran/runtime/ISO_Fortran_binding.c864
7 files changed, 1187 insertions, 67 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index d5fdb48..e4a1c11 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,14 @@
+2019-01-12 Paul Thomas <pault@gcc.gnu.org>
+
+ * ISO_Fortran_binding.h : New file.
+ * Makefile.am : Include ISO_Fortran_binding.c in the list of
+ files to compile.
+ * Makefile.in : Regenerated.
+ * gfortran.map : Add _gfortran_cfi_desc_to_gfc_desc,
+ _gfortran_gfc_desc_to_cfi_desc and the CFI API functions.
+ * runtime/ISO_Fortran_binding.c : New file containing the new
+ functions added to the map.
+
2019-01-12 Jakub Jelinek <jakub@redhat.com>
PR libfortran/88807
diff --git a/libgfortran/ISO_Fortran_binding.h b/libgfortran/ISO_Fortran_binding.h
new file mode 100644
index 0000000..4282cf5
--- /dev/null
+++ b/libgfortran/ISO_Fortran_binding.h
@@ -0,0 +1,206 @@
+/* Declarations for ISO Fortran binding.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ Contributed by Daniel Celis Garza <celisdanieljr@gmail.com>
+
+This file is part of the GNU Fortran runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef ISO_FORTRAN_BINDING_H
+#define ISO_FORTRAN_BINDING_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stddef.h> /* Standard ptrdiff_t tand size_t. */
+#include <stdint.h> /* Integer types. */
+
+/* Constants, defined as macros. */
+#define CFI_VERSION 1
+#define CFI_MAX_RANK 15
+
+/* Attributes. */
+#define CFI_attribute_pointer 0
+#define CFI_attribute_allocatable 1
+#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.
+ */
+#define CFI_SUCCESS 0
+#define CFI_FAILURE 1
+#define CFI_ERROR_BASE_ADDR_NULL 2
+#define CFI_ERROR_BASE_ADDR_NOT_NULL 3
+#define CFI_INVALID_ELEM_LEN 4
+#define CFI_INVALID_RANK 5
+#define CFI_INVALID_TYPE 6
+#define CFI_INVALID_ATTRIBUTE 7
+#define CFI_INVALID_EXTENT 8
+#define CFI_INVALID_STRIDE 9
+#define CFI_INVALID_DESCRIPTOR 10
+#define CFI_ERROR_MEM_ALLOCATION 11
+#define CFI_ERROR_OUT_OF_BOUNDS 12
+
+/* CFI type definitions. */
+typedef ptrdiff_t CFI_index_t;
+typedef int8_t CFI_rank_t;
+typedef int8_t CFI_attribute_t;
+typedef int16_t CFI_type_t;
+
+/* CFI_dim_t. */
+typedef struct CFI_dim_t
+ {
+ CFI_index_t lower_bound;
+ CFI_index_t extent;
+ CFI_index_t sm;
+ }
+CFI_dim_t;
+
+/* CFI_cdesc_t, C descriptors are cast to this structure as follows:
+ CFI_CDESC_T(CFI_MAX_RANK) foo;
+ CFI_cdesc_t * bar = (CFI_cdesc_t *) &foo;
+ */
+typedef struct CFI_cdesc_t
+ {
+ void *base_addr;
+ size_t elem_len;
+ int version;
+ CFI_rank_t rank;
+ CFI_attribute_t attribute;
+ CFI_type_t type;
+ CFI_dim_t dim[];
+ }
+CFI_cdesc_t;
+
+/* CFI_CDESC_T with an explicit type. */
+#define CFI_CDESC_TYPE_T(r, base_type) \
+ struct { \
+ base_type *base_addr; \
+ size_t elem_len; \
+ int version; \
+ CFI_rank_t rank; \
+ CFI_attribute_t attribute; \
+ CFI_type_t type; \
+ CFI_dim_t dim[r]; \
+ }
+#define CFI_CDESC_T(r) CFI_CDESC_TYPE_T (r, void)
+
+/* CFI function declarations. */
+extern void *CFI_address (const CFI_cdesc_t *, const CFI_index_t []);
+extern int CFI_allocate (CFI_cdesc_t *, const CFI_index_t [], const CFI_index_t [],
+ size_t);
+extern int CFI_deallocate (CFI_cdesc_t *);
+extern int CFI_establish (CFI_cdesc_t *, void *, CFI_attribute_t, CFI_type_t, size_t,
+ CFI_rank_t, const CFI_index_t []);
+extern int CFI_is_contiguous (const CFI_cdesc_t *);
+extern int CFI_section (CFI_cdesc_t *, const CFI_cdesc_t *, const CFI_index_t [],
+ const CFI_index_t [], const CFI_index_t []);
+extern int CFI_select_part (CFI_cdesc_t *, const CFI_cdesc_t *, size_t, size_t);
+extern int CFI_setpointer (CFI_cdesc_t *, CFI_cdesc_t *, const CFI_index_t []);
+
+/* Types and kind numbers. Allows bitwise and to reveal the intrinsic type of a kind type. It also allows us to find the kind parameter by inverting the bit-shift equation.
+ CFI_type_kind_shift = 8
+ CFI_intrinsic_type = 0 0 0 0 0 0 0 0 0 0 1 0
+ CFI_type_kind = 0 0 0 0 0 0 0 0 1 0 0 0
+ CFI_type_example = CFI_intrinsic_type + (CFI_type_kind << CFI_type_kind_shift)
+ Defining the CFI_type_example.
+ CFI_type_kind = 0 0 0 0 0 0 0 0 1 0 0 0 << CFI_type_kind_shift
+ -------------------------
+ 1 0 0 0 0 0 0 0 0 0 0 0 +
+ CFI_intrinsic_type = 0 0 0 0 0 0 0 0 0 0 1 0
+ -------------------------
+ CFI_type_example = 1 0 0 0 0 0 0 0 0 0 1 0
+ Finding the intrinsic type with the logical mask.
+ CFI_type_example = 1 0 0 0 0 0 0 0 0 0 1 0 &
+ CFI_type_mask = 0 0 0 0 1 1 1 1 1 1 1 1
+ -------------------------
+ CFI_intrinsic_type = 0 0 0 0 0 0 0 0 0 0 1 0
+ Using the intrinsic type and kind shift to find the kind value of the type.
+ CFI_type_kind = (CFI_type_example - CFI_intrinsic_type) >> CFI_type_kind_shift
+ CFI_type_example = 1 0 0 0 0 0 0 0 0 0 1 0 -
+ CFI_intrinsic_type = 0 0 0 0 0 0 0 0 0 0 1 0
+ -------------------------
+ 1 0 0 0 0 0 0 0 0 0 0 0 >> CFI_type_kind_shift
+ -------------------------
+ CFI_type_kind = 0 0 0 0 0 0 0 0 1 0 0 0
+ */
+#define CFI_type_mask 0xFF
+#define CFI_type_kind_shift 8
+
+/* Intrinsic types. Their kind number defines their storage size. */
+#define CFI_type_Integer 1
+#define CFI_type_Logical 2
+#define CFI_type_Real 3
+#define CFI_type_Complex 4
+#define CFI_type_Character 5
+
+/* Types with no kind. */
+#define CFI_type_struct 6
+#define CFI_type_cptr 7
+#define CFI_type_cfunptr 8
+#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.
+ */
+#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 */
diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am
index e1d757d9..90fdef4 100644
--- a/libgfortran/Makefile.am
+++ b/libgfortran/Makefile.am
@@ -30,6 +30,9 @@ version_arg =
version_dep =
endif
+gfor_c_HEADERS = $(srcdir)/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)
@@ -783,6 +786,9 @@ $(srcdir)/generated/spread_c8.c \
$(srcdir)/generated/spread_c10.c \
$(srcdir)/generated/spread_c16.c
+i_isobinding_c = \
+$(srcdir)/runtime/ISO_Fortran_binding.c
+
m4_files= m4/iparm.m4 m4/ifunction.m4 m4/iforeach.m4 m4/all.m4 \
m4/any.m4 m4/count.m4 m4/maxloc0.m4 m4/maxloc1.m4 m4/maxval.m4 \
m4/minloc0.m4 m4/minloc1.m4 m4/minval.m4 m4/product.m4 m4/sum.m4 \
@@ -810,7 +816,7 @@ gfor_built_src= $(i_all_c) $(i_any_c) $(i_count_c) $(i_maxloc0_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) \
$(i_findloc0_c) $(i_findloc0s_c) $(i_findloc1_c) $(i_findloc1s_c) \
- $(i_findloc2s_c)
+ $(i_findloc2s_c) $(i_isobinding_c)
# Machine generated specifics
gfor_built_specific_src= \
diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in
index ed8cf4c..ef0f132 100644
--- a/libgfortran/Makefile.in
+++ b/libgfortran/Makefile.in
@@ -179,7 +179,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
- $(am__configure_deps)
+ $(am__configure_deps) $(gfor_c_HEADERS)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
@@ -215,7 +215,7 @@ am__uninstall_files_from_dir = { \
}
am__installdirs = "$(DESTDIR)$(cafexeclibdir)" \
"$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibdir)" \
- "$(DESTDIR)$(fincludedir)"
+ "$(DESTDIR)$(gfor_cdir)" "$(DESTDIR)$(fincludedir)"
LTLIBRARIES = $(cafexeclib_LTLIBRARIES) $(toolexeclib_LTLIBRARIES)
libcaf_single_la_LIBADD =
am_libcaf_single_la_OBJECTS = single.lo
@@ -378,7 +378,8 @@ am__objects_49 = findloc1_i1.lo findloc1_i2.lo findloc1_i4.lo \
findloc1_r16.lo findloc1_c4.lo findloc1_c8.lo findloc1_c16.lo
am__objects_50 = findloc1_s1.lo findloc1_s4.lo
am__objects_51 = findloc2_s1.lo findloc2_s4.lo
-am__objects_52 = $(am__objects_4) $(am__objects_5) $(am__objects_6) \
+am__objects_52 = ISO_Fortran_binding.lo
+am__objects_53 = $(am__objects_4) $(am__objects_5) $(am__objects_6) \
$(am__objects_7) $(am__objects_8) $(am__objects_9) \
$(am__objects_10) $(am__objects_11) $(am__objects_12) \
$(am__objects_13) $(am__objects_14) $(am__objects_15) \
@@ -393,14 +394,15 @@ am__objects_52 = $(am__objects_4) $(am__objects_5) $(am__objects_6) \
$(am__objects_40) $(am__objects_41) $(am__objects_42) \
$(am__objects_43) $(am__objects_44) $(am__objects_45) \
$(am__objects_46) $(am__objects_47) $(am__objects_48) \
- $(am__objects_49) $(am__objects_50) $(am__objects_51)
-@LIBGFOR_MINIMAL_FALSE@am__objects_53 = close.lo file_pos.lo format.lo \
+ $(am__objects_49) $(am__objects_50) $(am__objects_51) \
+ $(am__objects_52)
+@LIBGFOR_MINIMAL_FALSE@am__objects_54 = close.lo file_pos.lo format.lo \
@LIBGFOR_MINIMAL_FALSE@ inquire.lo intrinsics.lo list_read.lo \
@LIBGFOR_MINIMAL_FALSE@ lock.lo open.lo read.lo transfer.lo \
@LIBGFOR_MINIMAL_FALSE@ transfer128.lo unit.lo unix.lo write.lo \
@LIBGFOR_MINIMAL_FALSE@ fbuf.lo async.lo
-am__objects_54 = size_from_kind.lo $(am__objects_53)
-@LIBGFOR_MINIMAL_FALSE@am__objects_55 = access.lo c99_functions.lo \
+am__objects_55 = size_from_kind.lo $(am__objects_54)
+@LIBGFOR_MINIMAL_FALSE@am__objects_56 = access.lo c99_functions.lo \
@LIBGFOR_MINIMAL_FALSE@ chdir.lo chmod.lo clock.lo cpu_time.lo \
@LIBGFOR_MINIMAL_FALSE@ ctime.lo date_and_time.lo dtime.lo \
@LIBGFOR_MINIMAL_FALSE@ env.lo etime.lo execute_command_line.lo \
@@ -410,19 +412,19 @@ am__objects_54 = size_from_kind.lo $(am__objects_53)
@LIBGFOR_MINIMAL_FALSE@ rename.lo stat.lo symlnk.lo \
@LIBGFOR_MINIMAL_FALSE@ system_clock.lo time.lo umask.lo \
@LIBGFOR_MINIMAL_FALSE@ unlink.lo
-@IEEE_SUPPORT_TRUE@am__objects_56 = ieee_helper.lo
-am__objects_57 = associated.lo abort.lo args.lo cshift0.lo eoshift0.lo \
+@IEEE_SUPPORT_TRUE@am__objects_57 = ieee_helper.lo
+am__objects_58 = associated.lo abort.lo args.lo cshift0.lo eoshift0.lo \
eoshift2.lo erfc_scaled.lo extends_type_of.lo fnum.lo \
- ierrno.lo ishftc.lo mvbits.lo move_alloc.lo pack_generic.lo \
- selected_char_kind.lo size.lo is_contiguous.lo spread_generic.lo \
- string_intrinsics.lo rand.lo random.lo reshape_generic.lo \
- reshape_packed.lo selected_int_kind.lo selected_real_kind.lo \
- unpack_generic.lo in_pack_generic.lo in_unpack_generic.lo \
- $(am__objects_55) $(am__objects_56)
-@IEEE_SUPPORT_TRUE@am__objects_58 = ieee_arithmetic.lo \
+ ierrno.lo ishftc.lo is_contiguous.lo mvbits.lo move_alloc.lo \
+ pack_generic.lo selected_char_kind.lo size.lo \
+ spread_generic.lo string_intrinsics.lo rand.lo random.lo \
+ reshape_generic.lo reshape_packed.lo selected_int_kind.lo \
+ selected_real_kind.lo unpack_generic.lo in_pack_generic.lo \
+ in_unpack_generic.lo $(am__objects_56) $(am__objects_57)
+@IEEE_SUPPORT_TRUE@am__objects_59 = ieee_arithmetic.lo \
@IEEE_SUPPORT_TRUE@ ieee_exceptions.lo ieee_features.lo
-am__objects_59 =
-am__objects_60 = _abs_c4.lo _abs_c8.lo _abs_c10.lo _abs_c16.lo \
+am__objects_60 =
+am__objects_61 = _abs_c4.lo _abs_c8.lo _abs_c10.lo _abs_c16.lo \
_abs_i4.lo _abs_i8.lo _abs_i16.lo _abs_r4.lo _abs_r8.lo \
_abs_r10.lo _abs_r16.lo _aimag_c4.lo _aimag_c8.lo \
_aimag_c10.lo _aimag_c16.lo _exp_r4.lo _exp_r8.lo _exp_r10.lo \
@@ -446,19 +448,19 @@ am__objects_60 = _abs_c4.lo _abs_c8.lo _abs_c10.lo _abs_c16.lo \
_conjg_c4.lo _conjg_c8.lo _conjg_c10.lo _conjg_c16.lo \
_aint_r4.lo _aint_r8.lo _aint_r10.lo _aint_r16.lo _anint_r4.lo \
_anint_r8.lo _anint_r10.lo _anint_r16.lo
-am__objects_61 = _sign_i4.lo _sign_i8.lo _sign_i16.lo _sign_r4.lo \
+am__objects_62 = _sign_i4.lo _sign_i8.lo _sign_i16.lo _sign_r4.lo \
_sign_r8.lo _sign_r10.lo _sign_r16.lo _dim_i4.lo _dim_i8.lo \
_dim_i16.lo _dim_r4.lo _dim_r8.lo _dim_r10.lo _dim_r16.lo \
_atan2_r4.lo _atan2_r8.lo _atan2_r10.lo _atan2_r16.lo \
_mod_i4.lo _mod_i8.lo _mod_i16.lo _mod_r4.lo _mod_r8.lo \
_mod_r10.lo _mod_r16.lo
-am__objects_62 = misc_specifics.lo
-am__objects_63 = $(am__objects_60) $(am__objects_61) $(am__objects_62) \
+am__objects_63 = misc_specifics.lo
+am__objects_64 = $(am__objects_61) $(am__objects_62) $(am__objects_63) \
dprod_r8.lo f2c_specifics.lo random_init.lo
-am__objects_64 = $(am__objects_3) $(am__objects_52) $(am__objects_54) \
- $(am__objects_57) $(am__objects_58) $(am__objects_59) \
- $(am__objects_63)
-@onestep_FALSE@am_libgfortran_la_OBJECTS = $(am__objects_64)
+am__objects_65 = $(am__objects_3) $(am__objects_53) $(am__objects_55) \
+ $(am__objects_58) $(am__objects_59) $(am__objects_60) \
+ $(am__objects_64)
+@onestep_FALSE@am_libgfortran_la_OBJECTS = $(am__objects_65)
@onestep_TRUE@am_libgfortran_la_OBJECTS = libgfortran_c.lo
libgfortran_la_OBJECTS = $(am_libgfortran_la_OBJECTS)
AM_V_P = $(am__v_P_@AM_V@)
@@ -531,7 +533,7 @@ am__can_run_installinfo = \
*) (install-info --version) >/dev/null 2>&1;; \
esac
DATA = $(toolexeclib_DATA)
-HEADERS = $(nodist_finclude_HEADERS)
+HEADERS = $(gfor_c_HEADERS) $(nodist_finclude_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
$(LISP)config.h.in
# Read a list of newline-separated strings from the standard input,
@@ -690,7 +692,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
-runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -715,6 +716,8 @@ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
@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)$(MULTISUBDIR)/include
LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) \
$(lt_host_flags)
@@ -757,10 +760,10 @@ gfor_helper_src = intrinsics/associated.c intrinsics/abort.c \
intrinsics/args.c intrinsics/cshift0.c intrinsics/eoshift0.c \
intrinsics/eoshift2.c intrinsics/erfc_scaled.c \
intrinsics/extends_type_of.c intrinsics/fnum.c \
- intrinsics/ierrno.c intrinsics/ishftc.c intrinsics/mvbits.c \
+ intrinsics/ierrno.c intrinsics/ishftc.c \
+ intrinsics/is_contiguous.c intrinsics/mvbits.c \
intrinsics/move_alloc.c intrinsics/pack_generic.c \
intrinsics/selected_char_kind.c intrinsics/size.c \
- intrinsics/is_contiguous.c \
intrinsics/spread_generic.c intrinsics/string_intrinsics.c \
intrinsics/rand.c intrinsics/random.c \
intrinsics/reshape_generic.c intrinsics/reshape_packed.c \
@@ -1341,6 +1344,9 @@ $(srcdir)/generated/spread_c8.c \
$(srcdir)/generated/spread_c10.c \
$(srcdir)/generated/spread_c16.c
+i_isobinding_c = \
+$(srcdir)/runtime/ISO_Fortran_binding.c
+
m4_files = m4/iparm.m4 m4/ifunction.m4 m4/iforeach.m4 m4/all.m4 \
m4/any.m4 m4/count.m4 m4/maxloc0.m4 m4/maxloc1.m4 m4/maxval.m4 \
m4/minloc0.m4 m4/minloc1.m4 m4/minval.m4 m4/product.m4 m4/sum.m4 \
@@ -1368,7 +1374,7 @@ gfor_built_src = $(i_all_c) $(i_any_c) $(i_count_c) $(i_maxloc0_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) \
$(i_findloc0_c) $(i_findloc0s_c) $(i_findloc1_c) $(i_findloc1s_c) \
- $(i_findloc2s_c)
+ $(i_findloc2s_c) $(i_isobinding_c)
# Machine generated specifics
@@ -1698,6 +1704,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ISO_Fortran_binding.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abort.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/access.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/all_l1.Plo@am__quote@
@@ -1892,6 +1899,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iparity_i2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iparity_i4.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iparity_i8.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is_contiguous.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ishftc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kill.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgfortran_c.Plo@am__quote@
@@ -2199,7 +2207,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/single.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/size.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/size_from_kind.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is_contiguous.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sleep.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spread_c10.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spread_c16.Plo@am__quote@
@@ -6089,6 +6096,13 @@ findloc2_s4.lo: $(srcdir)/generated/findloc2_s4.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o findloc2_s4.lo `test -f '$(srcdir)/generated/findloc2_s4.c' || echo '$(srcdir)/'`$(srcdir)/generated/findloc2_s4.c
+ISO_Fortran_binding.lo: $(srcdir)/runtime/ISO_Fortran_binding.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ISO_Fortran_binding.lo -MD -MP -MF $(DEPDIR)/ISO_Fortran_binding.Tpo -c -o ISO_Fortran_binding.lo `test -f '$(srcdir)/runtime/ISO_Fortran_binding.c' || echo '$(srcdir)/'`$(srcdir)/runtime/ISO_Fortran_binding.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ISO_Fortran_binding.Tpo $(DEPDIR)/ISO_Fortran_binding.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(srcdir)/runtime/ISO_Fortran_binding.c' object='ISO_Fortran_binding.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ISO_Fortran_binding.lo `test -f '$(srcdir)/runtime/ISO_Fortran_binding.c' || echo '$(srcdir)/'`$(srcdir)/runtime/ISO_Fortran_binding.c
+
size_from_kind.lo: io/size_from_kind.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT size_from_kind.lo -MD -MP -MF $(DEPDIR)/size_from_kind.Tpo -c -o size_from_kind.lo `test -f 'io/size_from_kind.c' || echo '$(srcdir)/'`io/size_from_kind.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/size_from_kind.Tpo $(DEPDIR)/size_from_kind.Plo
@@ -6285,6 +6299,13 @@ ishftc.lo: intrinsics/ishftc.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ishftc.lo `test -f 'intrinsics/ishftc.c' || echo '$(srcdir)/'`intrinsics/ishftc.c
+is_contiguous.lo: intrinsics/is_contiguous.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT is_contiguous.lo -MD -MP -MF $(DEPDIR)/is_contiguous.Tpo -c -o is_contiguous.lo `test -f 'intrinsics/is_contiguous.c' || echo '$(srcdir)/'`intrinsics/is_contiguous.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/is_contiguous.Tpo $(DEPDIR)/is_contiguous.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='intrinsics/is_contiguous.c' object='is_contiguous.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o is_contiguous.lo `test -f 'intrinsics/is_contiguous.c' || echo '$(srcdir)/'`intrinsics/is_contiguous.c
+
mvbits.lo: intrinsics/mvbits.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mvbits.lo -MD -MP -MF $(DEPDIR)/mvbits.Tpo -c -o mvbits.lo `test -f 'intrinsics/mvbits.c' || echo '$(srcdir)/'`intrinsics/mvbits.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mvbits.Tpo $(DEPDIR)/mvbits.Plo
@@ -6320,13 +6341,6 @@ size.lo: intrinsics/size.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o size.lo `test -f 'intrinsics/size.c' || echo '$(srcdir)/'`intrinsics/size.c
-is_contiguous.lo: intrinsics/is_contiguous.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT is_contiguous.lo -MD -MP -MF $(DEPDIR)/is_contiguous.Tpo -c -o is_contiguous.lo `test -f 'intrinsics/is_contiguous.c' || echo '$(srcdir)/'`intrinsics/is_contiguous.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/is_contiguous.Tpo $(DEPDIR)/is_contiguous.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='intrinsics/is_contiguous.c' object='is_contiguous.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o is_contiguous.lo `test -f 'intrinsics/is_contiguous.c' || echo '$(srcdir)/'`intrinsics/is_contiguous.c
-
spread_generic.lo: intrinsics/spread_generic.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT spread_generic.lo -MD -MP -MF $(DEPDIR)/spread_generic.Tpo -c -o spread_generic.lo `test -f 'intrinsics/spread_generic.c' || echo '$(srcdir)/'`intrinsics/spread_generic.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/spread_generic.Tpo $(DEPDIR)/spread_generic.Plo
@@ -6664,6 +6678,27 @@ uninstall-toolexeclibDATA:
@list='$(toolexeclib_DATA)'; test -n "$(toolexeclibdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(toolexeclibdir)'; $(am__uninstall_files_from_dir)
+install-gfor_cHEADERS: $(gfor_c_HEADERS)
+ @$(NORMAL_INSTALL)
+ @list='$(gfor_c_HEADERS)'; test -n "$(gfor_cdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(gfor_cdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(gfor_cdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(gfor_cdir)'"; \
+ $(INSTALL_HEADER) $$files "$(DESTDIR)$(gfor_cdir)" || exit $$?; \
+ done
+
+uninstall-gfor_cHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(gfor_c_HEADERS)'; test -n "$(gfor_cdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(gfor_cdir)'; $(am__uninstall_files_from_dir)
install-nodist_fincludeHEADERS: $(nodist_finclude_HEADERS)
@$(NORMAL_INSTALL)
@list='$(nodist_finclude_HEADERS)'; test -n "$(fincludedir)" || list=; \
@@ -6749,7 +6784,7 @@ check: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) check-am
all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS) config.h all-local
installdirs:
- for dir in "$(DESTDIR)$(cafexeclibdir)" "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(fincludedir)"; do \
+ for dir in "$(DESTDIR)$(cafexeclibdir)" "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(gfor_cdir)" "$(DESTDIR)$(fincludedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: $(BUILT_SOURCES)
@@ -6808,7 +6843,7 @@ info: info-am
info-am:
-install-data-am: install-nodist_fincludeHEADERS
+install-data-am: install-gfor_cHEADERS install-nodist_fincludeHEADERS
install-dvi: install-dvi-am
@@ -6858,7 +6893,7 @@ ps: ps-am
ps-am:
-uninstall-am: uninstall-cafexeclibLTLIBRARIES \
+uninstall-am: uninstall-cafexeclibLTLIBRARIES uninstall-gfor_cHEADERS \
uninstall-nodist_fincludeHEADERS uninstall-toolexeclibDATA \
uninstall-toolexeclibLTLIBRARIES
@@ -6873,16 +6908,16 @@ uninstall-am: uninstall-cafexeclibLTLIBRARIES \
dvi dvi-am html html-am info info-am install install-am \
install-cafexeclibLTLIBRARIES install-data install-data-am \
install-dvi install-dvi-am install-exec install-exec-am \
- install-exec-local install-html install-html-am install-info \
- install-info-am install-man install-nodist_fincludeHEADERS \
- install-pdf install-pdf-am install-ps install-ps-am \
- install-strip install-toolexeclibDATA \
+ install-exec-local install-gfor_cHEADERS install-html \
+ install-html-am install-info install-info-am install-man \
+ install-nodist_fincludeHEADERS install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip install-toolexeclibDATA \
install-toolexeclibLTLIBRARIES installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
maintainer-clean-local mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \
pdf-am ps ps-am tags tags-am uninstall uninstall-am \
- uninstall-cafexeclibLTLIBRARIES \
+ uninstall-cafexeclibLTLIBRARIES uninstall-gfor_cHEADERS \
uninstall-nodist_fincludeHEADERS uninstall-toolexeclibDATA \
uninstall-toolexeclibLTLIBRARIES
diff --git a/libgfortran/configure b/libgfortran/configure
index 62e80a0..531e2ca 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -780,7 +780,6 @@ infodir
docdir
oldincludedir
includedir
-runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -871,7 +870,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1124,15 +1122,6 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
- -runstatedir | --runstatedir | --runstatedi | --runstated \
- | --runstate | --runstat | --runsta | --runst | --runs \
- | --run | --ru | --r)
- ac_prev=runstatedir ;;
- -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
- | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
- | --run=* | --ru=* | --r=*)
- runstatedir=$ac_optarg ;;
-
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1270,7 +1259,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir runstatedir
+ libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1423,7 +1412,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -12696,7 +12684,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12699 "configure"
+#line 12687 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12802,7 +12790,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12805 "configure"
+#line 12793 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -16051,7 +16039,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -16097,7 +16085,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -16121,7 +16109,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -16166,7 +16154,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -16190,7 +16178,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
diff --git a/libgfortran/gfortran.map b/libgfortran/gfortran.map
index 43b32de..f7f270b 100644
--- a/libgfortran/gfortran.map
+++ b/libgfortran/gfortran.map
@@ -1486,6 +1486,16 @@ GFORTRAN_C99_8 {
GFORTRAN_9 {
global:
+ CFI_address;
+ CFI_allocate;
+ CFI_deallocate;
+ CFI_establish;
+ CFI_is_contiguous;
+ CFI_section;
+ CFI_select_part;
+ CFI_setpointer;
+ _gfortran_gfc_desc_to_cfi_desc;
+ _gfortran_cfi_desc_to_gfc_desc;
_gfortran_findloc0_c16;
_gfortran_findloc0_c4;
_gfortran_findloc0_c8;
diff --git a/libgfortran/runtime/ISO_Fortran_binding.c b/libgfortran/runtime/ISO_Fortran_binding.c
new file mode 100644
index 0000000..4161a74
--- /dev/null
+++ b/libgfortran/runtime/ISO_Fortran_binding.c
@@ -0,0 +1,864 @@
+/* Functions to convert descriptors between CFI and gfortran
+ and the CFI function declarations whose prototypes appear
+ in ISO_Fortran_binding.h.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ Contributed by Daniel Celis Garza <celisdanieljr@gmail.com>
+ and Paul Thomas <pault@gcc.gnu.org>
+
+This file is part of the GNU Fortran runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "libgfortran.h"
+#include <ISO_Fortran_binding.h>
+#include <string.h>
+
+extern void cfi_desc_to_gfc_desc (gfc_array_void *, CFI_cdesc_t **);
+export_proto(cfi_desc_to_gfc_desc);
+
+void
+cfi_desc_to_gfc_desc (gfc_array_void *d, CFI_cdesc_t **s_ptr)
+{
+ int n;
+ CFI_cdesc_t *s = *s_ptr;
+
+ /* If not a full pointer or allocatable array free the descriptor
+ and return. */
+ if (!s || s->attribute == CFI_attribute_other)
+ goto finish;
+
+ GFC_DESCRIPTOR_DATA (d) = s->base_addr;
+
+ if (!s->rank || s->dim[0].sm == (CFI_index_t)s->elem_len)
+ GFC_DESCRIPTOR_SIZE (d) = s->elem_len;
+ else
+ GFC_DESCRIPTOR_SIZE (d) = (index_type)s->dim[0].sm;
+
+ d->dtype.version = s->version;
+ GFC_DESCRIPTOR_RANK (d) = (signed char)s->rank;
+ GFC_DESCRIPTOR_TYPE (d) = (signed char)(s->type & CFI_type_mask);
+
+ /* Correct the unfortunate difference in order with types. */
+ if (GFC_DESCRIPTOR_TYPE (d) == BT_CHARACTER)
+ GFC_DESCRIPTOR_TYPE (d) = BT_DERIVED;
+ else if (GFC_DESCRIPTOR_TYPE (d) == BT_DERIVED)
+ GFC_DESCRIPTOR_TYPE (d) = BT_DERIVED;
+
+ d->dtype.attribute = (signed short)s->attribute;
+
+ if (s->rank)
+ d->span = (index_type)s->dim[0].sm;
+
+ /* On the other hand, CFI_establish can change the bounds. */
+ d->offset = 0;
+ for (n = 0; n < GFC_DESCRIPTOR_RANK (d); n++)
+ {
+ GFC_DESCRIPTOR_LBOUND(d, n) = (index_type)s->dim[n].lower_bound;
+ GFC_DESCRIPTOR_UBOUND(d, n) = (index_type)(s->dim[n].extent
+ + s->dim[n].lower_bound - 1);
+ GFC_DESCRIPTOR_STRIDE(d, n) = (index_type)(s->dim[n].sm / s->elem_len);
+ d->offset -= GFC_DESCRIPTOR_STRIDE(d, n) * GFC_DESCRIPTOR_LBOUND(d, n);
+ }
+
+finish:
+ if (s)
+ free (s);
+ s = NULL;
+}
+
+extern void gfc_desc_to_cfi_desc (CFI_cdesc_t **, const gfc_array_void *);
+export_proto(gfc_desc_to_cfi_desc);
+
+void
+gfc_desc_to_cfi_desc (CFI_cdesc_t **d_ptr, const gfc_array_void *s)
+{
+ int n;
+ CFI_cdesc_t *d;
+
+ /* Play it safe with allocation of the flexible array member 'dim'
+ by setting the length to CFI_MAX_RANK. This should not be necessary
+ but valgrind complains accesses after the allocated block. */
+ d = malloc (sizeof (CFI_cdesc_t)
+ + (CFI_type_t)(CFI_MAX_RANK * sizeof (CFI_dim_t)));
+
+ d->base_addr = GFC_DESCRIPTOR_DATA (s);
+ d->elem_len = GFC_DESCRIPTOR_SIZE (s);
+ d->version = s->dtype.version;
+ d->rank = (CFI_rank_t)GFC_DESCRIPTOR_RANK (s);
+ d->attribute = (CFI_attribute_t)s->dtype.attribute;
+
+ if (GFC_DESCRIPTOR_TYPE (s) == BT_CHARACTER)
+ d->type = CFI_type_struct;
+ else if (GFC_DESCRIPTOR_TYPE (s) == BT_DERIVED)
+ d->type = CFI_type_Character;
+ else
+ d->type = (CFI_type_t)GFC_DESCRIPTOR_TYPE (s);
+
+ d->type = (CFI_type_t)(d->type
+ + ((CFI_type_t)d->elem_len << CFI_type_kind_shift));
+
+ /* Full pointer or allocatable arrays have zero lower_bound. */
+ for (n = 0; n < GFC_DESCRIPTOR_RANK (s); n++)
+ {
+ if (d->attribute == CFI_attribute_other)
+ d->dim[n].lower_bound = (CFI_index_t)GFC_DESCRIPTOR_LBOUND(s, n);
+ else
+ d->dim[n].lower_bound = 0;
+
+ /* Assumed size arrays have gfc ubound == 0 and CFI extent = -1. */
+ if ((n == GFC_DESCRIPTOR_RANK (s) - 1)
+ && GFC_DESCRIPTOR_LBOUND(s, n) == 1
+ && GFC_DESCRIPTOR_UBOUND(s, n) == 0)
+ d->dim[n].extent = -1;
+ else
+ d->dim[n].extent = (CFI_index_t)GFC_DESCRIPTOR_UBOUND(s, n)
+ - (CFI_index_t)GFC_DESCRIPTOR_LBOUND(s, n) + 1;
+ d->dim[n].sm = (CFI_index_t)(GFC_DESCRIPTOR_STRIDE(s, n) * s->span);
+ }
+
+ *d_ptr = d;
+}
+
+void *CFI_address (const CFI_cdesc_t *dv, const CFI_index_t subscripts[])
+{
+ int i;
+ char *base_addr = (char *)dv->base_addr;
+
+ if (unlikely (compile_options.bounds_check))
+ {
+ /* C Descriptor must not be NULL. */
+ if (dv == NULL)
+ {
+ fprintf (stderr, "CFI_address: C Descriptor is NULL.\n");
+ return NULL;
+ }
+
+ /* Base address of C Descriptor must not be NULL. */
+ if (dv->base_addr == NULL)
+ {
+ fprintf (stderr, "CFI_address: base address of C Descriptor "
+ "must not be NULL.\n");
+ return NULL;
+ }
+ }
+
+ /* Return base address if C descriptor is a scalar. */
+ if (dv->rank == 0)
+ return dv->base_addr;
+
+ /* Calculate the appropriate base address if dv is not a scalar. */
+ else
+ {
+ /* Base address is the C address of the element of the object
+ specified by subscripts. */
+ for (i = 0; i < dv->rank; i++)
+ {
+ if (unlikely (compile_options.bounds_check)
+ && ((dv->dim[i].extent != -1
+ && subscripts[i] >= dv->dim[i].extent)
+ || subscripts[i] < 0))
+ {
+ fprintf (stderr, "CFI_address: subscripts[%d], is out of "
+ "bounds. dv->dim[%d].extent = %d subscripts[%d] "
+ "= %d.\n", i, i, (int)dv->dim[i].extent, i,
+ (int)subscripts[i]);
+ return NULL;
+ }
+
+ base_addr = base_addr + (CFI_index_t)(subscripts[i] * dv->dim[i].sm);
+ }
+ }
+
+ return (void *)base_addr;
+}
+
+
+int
+CFI_allocate (CFI_cdesc_t *dv, const CFI_index_t lower_bounds[],
+ const CFI_index_t upper_bounds[], size_t elem_len)
+{
+ if (unlikely (compile_options.bounds_check))
+ {
+ /* C Descriptor must not be NULL. */
+ if (dv == NULL)
+ {
+ fprintf (stderr, "CFI_allocate: C Descriptor is NULL.\n");
+ return CFI_INVALID_DESCRIPTOR;
+ }
+
+ /* The C Descriptor must be for an allocatable or pointer object. */
+ if (dv->attribute == CFI_attribute_other)
+ {
+ fprintf (stderr, "CFI_allocate: The object of the C descriptor "
+ "must be a pointer or allocatable variable.\n");
+ return CFI_INVALID_ATTRIBUTE;
+ }
+
+ /* Base address of C Descriptor must be NULL. */
+ if (dv->base_addr != NULL)
+ {
+ fprintf (stderr, "CFI_allocate: Base address of C descriptor "
+ "must be NULL.\n");
+ return CFI_ERROR_BASE_ADDR_NOT_NULL;
+ }
+ }
+
+ /* If the type is a character, the descriptor's element length is replaced
+ * by the elem_len argument. */
+ if (dv->type == CFI_type_char || dv->type == CFI_type_ucs4_char ||
+ dv->type == CFI_type_signed_char)
+ dv->elem_len = elem_len;
+
+ /* Dimension information and calculating the array length. */
+ size_t arr_len = 1;
+
+ /* If rank is greater than 0, lower_bounds and upper_bounds are used. They're
+ * ignored otherwhise. */
+ if (dv->rank > 0)
+ {
+ if (unlikely (compile_options.bounds_check)
+ && (lower_bounds == NULL || upper_bounds == NULL))
+ {
+ fprintf (stderr, "CFI_allocate: If 0 < rank (= %d) upper_bounds[] "
+ "and lower_bounds[], must not be NULL.\n", dv->rank);
+ return CFI_INVALID_EXTENT;
+ }
+
+ for (int i = 0; i < dv->rank; i++)
+ {
+ dv->dim[i].lower_bound = lower_bounds[i];
+ dv->dim[i].extent = upper_bounds[i] - dv->dim[i].lower_bound + 1;
+ if (i == 0)
+ dv->dim[i].sm = dv->elem_len;
+ else
+ dv->dim[i].sm = dv->elem_len * dv->dim[i - 1].extent;
+ arr_len *= dv->dim[i].extent;
+ }
+ }
+
+ dv->base_addr = calloc (arr_len, dv->elem_len);
+ if (dv->base_addr == NULL)
+ {
+ fprintf (stderr, "CFI_allocate: Failure in memory allocation.\n");
+ return CFI_ERROR_MEM_ALLOCATION;
+ }
+
+ return CFI_SUCCESS;
+}
+
+
+int
+CFI_deallocate (CFI_cdesc_t *dv)
+{
+ if (unlikely (compile_options.bounds_check))
+ {
+ /* C Descriptor must not be NULL */
+ if (dv == NULL)
+ {
+ fprintf (stderr, "CFI_deallocate: C Descriptor is NULL.\n");
+ return CFI_INVALID_DESCRIPTOR;
+ }
+
+ /* Base address must not be NULL. */
+ if (dv->base_addr == NULL)
+ {
+ fprintf (stderr, "CFI_deallocate: Base address is already NULL.\n");
+ return CFI_ERROR_BASE_ADDR_NULL;
+ }
+
+ /* C Descriptor must be for an allocatable or pointer variable. */
+ if (dv->attribute == CFI_attribute_other)
+ {
+ fprintf (stderr, "CFI_deallocate: C Descriptor must describe a "
+ "pointer or allocatable object.\n");
+ return CFI_INVALID_ATTRIBUTE;
+ }
+ }
+
+ /* Free and nullify memory. */
+ free (dv->base_addr);
+ dv->base_addr = NULL;
+
+ return CFI_SUCCESS;
+}
+
+
+int CFI_establish (CFI_cdesc_t *dv, void *base_addr, CFI_attribute_t attribute,
+ CFI_type_t type, size_t elem_len, CFI_rank_t rank,
+ const CFI_index_t extents[])
+{
+ if (unlikely (compile_options.bounds_check))
+ {
+ /* C descriptor must not be NULL. */
+ if (dv == NULL)
+ {
+ fprintf (stderr, "CFI_establish: C descriptor is NULL.\n");
+ return CFI_INVALID_DESCRIPTOR;
+ }
+
+ /* Rank must be between 0 and CFI_MAX_RANK. */
+ if (rank < 0 || rank > CFI_MAX_RANK)
+ {
+ fprintf (stderr, "CFI_establish: Rank must be between 0 and %d, "
+ "0 < rank (0 !< %d).\n", CFI_MAX_RANK, (int)rank);
+ return CFI_INVALID_RANK;
+ }
+
+ /* C Descriptor must not be an allocated allocatable. */
+ if (dv->attribute == CFI_attribute_allocatable && dv->base_addr != NULL)
+ {
+ fprintf (stderr, "CFI_establish: If the C Descriptor represents an "
+ "allocatable variable (dv->attribute = %d), its base "
+ "address must be NULL (dv->base_addr = NULL).\n",
+ CFI_attribute_allocatable);
+ return CFI_INVALID_DESCRIPTOR;
+ }
+
+ /* If base address is not NULL, the established C Descriptor is for a
+ nonallocatable entity. */
+ if (attribute == CFI_attribute_allocatable && base_addr != NULL)
+ {
+ fprintf (stderr, "CFI_establish: If base address is not NULL "
+ "(base_addr != NULL), the established C descriptor is "
+ "for a nonallocatable entity (attribute != %d).\n",
+ CFI_attribute_allocatable);
+ return CFI_INVALID_ATTRIBUTE;
+ }
+ }
+
+ dv->base_addr = base_addr;
+
+ if (type == CFI_type_char || type == CFI_type_ucs4_char ||
+ type == CFI_type_signed_char || type == CFI_type_struct ||
+ type == CFI_type_other)
+ dv->elem_len = elem_len;
+ else
+ {
+ /* base_type describes the intrinsic type with kind parameter. */
+ size_t base_type = type & CFI_type_mask;
+ /* base_type_size is the size in bytes of the variable as given by its
+ * kind parameter. */
+ size_t base_type_size = (type - base_type) >> CFI_type_kind_shift;
+ /* Kind types 10 have a size of 64 bytes. */
+ if (base_type_size == 10)
+ {
+ base_type_size = 64;
+ }
+ /* Complex numbers are twice the size of their real counterparts. */
+ if (base_type == CFI_type_Complex)
+ {
+ base_type_size *= 2;
+ }
+ dv->elem_len = base_type_size;
+ }
+
+ dv->version = CFI_VERSION;
+ dv->rank = rank;
+ dv->attribute = attribute;
+ dv->type = type;
+
+ /* Extents must not be NULL if rank is greater than zero and base_addr is not
+ * NULL */
+ if (rank > 0 && base_addr != NULL)
+ {
+ if (unlikely (compile_options.bounds_check) && extents == NULL)
+ {
+ fprintf (stderr, "CFI_establish: Extents must not be NULL "
+ "(extents != NULL) if rank (= %d) > 0 nd base address"
+ "is not NULL (base_addr != NULL).\n", (int)rank);
+ return CFI_INVALID_EXTENT;
+ }
+
+ for (int i = 0; i < rank; i++)
+ {
+ /* If the C Descriptor is for a pointer then the lower bounds of every
+ * dimension are set to zero. */
+ if (attribute == CFI_attribute_pointer)
+ dv->dim[i].lower_bound = 0;
+ else
+ dv->dim[i].lower_bound = 1;
+
+ dv->dim[i].extent = extents[i];
+ if (i == 0)
+ dv->dim[i].sm = dv->elem_len;
+ else
+ dv->dim[i].sm = (CFI_index_t)(dv->elem_len * extents[i - 1]);
+ }
+ }
+
+ return CFI_SUCCESS;
+}
+
+
+int CFI_is_contiguous (const CFI_cdesc_t *dv)
+{
+ if (unlikely (compile_options.bounds_check))
+ {
+ /* C descriptor must not be NULL. */
+ if (dv == NULL)
+ {
+ fprintf (stderr, "CFI_is_contiguous: C descriptor is NULL.\n");
+ return CFI_INVALID_DESCRIPTOR;
+ }
+
+ /* Base address must not be NULL. */
+ if (dv->base_addr == NULL)
+ {
+ fprintf (stderr, "CFI_is_contiguous: Base address of C Descriptor "
+ "is already NULL.\n");
+ return CFI_ERROR_BASE_ADDR_NULL;
+ }
+
+ /* Must be an array. */
+ if (dv->rank == 0)
+ {
+ fprintf (stderr, "CFI_is_contiguous: C Descriptor must describe an "
+ "array (0 < dv->rank = %d).\n", dv->rank);
+ return CFI_INVALID_RANK;
+ }
+ }
+
+ /* Assumed size arrays are always contiguous. */
+ if (dv->rank > 0 && dv->dim[dv->rank - 1].extent == -1)
+ return CFI_SUCCESS;
+
+ /* If an array is not contiguous the memory stride is different to the element
+ * length. */
+ for (int i = 0; i < dv->rank; i++)
+ {
+ if (i == 0 && dv->dim[i].sm == (CFI_index_t)dv->elem_len)
+ continue;
+ else if (i > 0
+ && dv->dim[i].sm == (CFI_index_t)(dv->elem_len
+ * dv->dim[i - 1].extent))
+ continue;
+
+ return CFI_FAILURE;
+ }
+
+ /* Array sections are guaranteed to be contiguous by the previous test. */
+ return CFI_SUCCESS;
+}
+
+
+int CFI_section (CFI_cdesc_t *result, const CFI_cdesc_t *source,
+ const CFI_index_t lower_bounds[],
+ const CFI_index_t upper_bounds[], const CFI_index_t strides[])
+{
+ /* Dimension information. */
+ CFI_index_t lower[CFI_MAX_RANK];
+ CFI_index_t upper[CFI_MAX_RANK];
+ CFI_index_t stride[CFI_MAX_RANK];
+ int zero_count = 0;
+ bool assumed_size;
+
+ if (unlikely (compile_options.bounds_check))
+ {
+ /* C Descriptors must not be NULL. */
+ if (source == NULL)
+ {
+ fprintf (stderr, "CFI_section: Source must not be NULL.\n");
+ return CFI_INVALID_DESCRIPTOR;
+ }
+
+ if (result == NULL)
+ {
+ fprintf (stderr, "CFI_section: Result must not be NULL.\n");
+ return CFI_INVALID_DESCRIPTOR;
+ }
+
+ /* Base address of source must not be NULL. */
+ if (source->base_addr == NULL)
+ {
+ fprintf (stderr, "CFI_section: Base address of source must "
+ "not be NULL.\n");
+ return CFI_ERROR_BASE_ADDR_NULL;
+ }
+
+ /* Result must not be an allocatable array. */
+ if (result->attribute == CFI_attribute_allocatable)
+ {
+ fprintf (stderr, "CFI_section: Result must not describe an "
+ "allocatable array.\n");
+ return CFI_INVALID_ATTRIBUTE;
+ }
+
+ /* Source must be some form of array (nonallocatable nonpointer array,
+ allocated allocatable array or an associated pointer array). */
+ if (source->rank <= 0)
+ {
+ fprintf (stderr, "CFI_section: Source must describe an array "
+ "(0 < source->rank, 0 !< %d).\n", source->rank);
+ return CFI_INVALID_RANK;
+ }
+
+ /* Element lengths of source and result must be equal. */
+ if (result->elem_len != source->elem_len)
+ {
+ fprintf (stderr, "CFI_section: The element lengths of "
+ "source (source->elem_len = %d) and result "
+ "(result->elem_len = %d) must be equal.\n",
+ (int)source->elem_len, (int)result->elem_len);
+ return CFI_INVALID_ELEM_LEN;
+ }
+
+ /* Types must be equal. */
+ if (result->type != source->type)
+ {
+ fprintf (stderr, "CFI_section: Types of source "
+ "(source->type = %d) and result (result->type = %d) "
+ "must be equal.\n", source->type, result->type);
+ return CFI_INVALID_TYPE;
+ }
+ }
+
+ /* Stride of zero in the i'th dimension means rank reduction in that
+ dimension. */
+ for (int i = 0; i < source->rank; i++)
+ {
+ if (strides[i] == 0)
+ zero_count++;
+ }
+
+ /* Rank of result must be equal the the rank of source minus the number of
+ * zeros in strides. */
+ if (unlikely (compile_options.bounds_check)
+ && result->rank != source->rank - zero_count)
+ {
+ fprintf (stderr, "CFI_section: Rank of result must be equal to the "
+ "rank of source minus the number of zeros in strides "
+ "(result->rank = source->rank - zero_count, %d != %d "
+ "- %d).\n", result->rank, source->rank, zero_count);
+ return CFI_INVALID_RANK;
+ }
+
+ /* Lower bounds. */
+ if (lower_bounds == NULL)
+ {
+ for (int i = 0; i < source->rank; i++)
+ lower[i] = source->dim[i].lower_bound;
+ }
+ else
+ {
+ for (int i = 0; i < source->rank; i++)
+ lower[i] = lower_bounds[i];
+ }
+
+ /* Upper bounds. */
+ if (upper_bounds == NULL)
+ {
+ if (unlikely (compile_options.bounds_check)
+ && source->dim[source->rank - 1].extent == -1)
+ {
+ fprintf (stderr, "CFI_section: Source must not be an assumed size "
+ "array if upper_bounds is NULL.\n");
+ return CFI_INVALID_EXTENT;
+ }
+
+ for (int i = 0; i < source->rank; i++)
+ upper[i] = source->dim[i].lower_bound + source->dim[i].extent - 1;
+ }
+ else
+ {
+ for (int i = 0; i < source->rank; i++)
+ upper[i] = upper_bounds[i];
+ }
+
+ /* Stride */
+ if (strides == NULL)
+ {
+ for (int i = 0; i < source->rank; i++)
+ stride[i] = 1;
+ }
+ else
+ {
+ for (int i = 0; i < source->rank; i++)
+ {
+ stride[i] = strides[i];
+ /* If stride[i] == 0 then lower[i] and upper[i] must be equal. */
+ if (unlikely (compile_options.bounds_check)
+ && stride[i] == 0 && lower[i] != upper[i])
+ {
+ fprintf (stderr, "CFI_section: If strides[%d] = 0, then the "
+ "lower bounds, lower_bounds[%d] = %d, and "
+ "upper_bounds[%d] = %d, must be equal.\n",
+ i, i, (int)lower_bounds[i], i, (int)upper_bounds[i]);
+ return CFI_ERROR_OUT_OF_BOUNDS;
+ }
+ }
+ }
+
+ /* Check that section upper and lower bounds are within the array bounds. */
+ for (int i = 0; i < source->rank; i++)
+ {
+ assumed_size = (i == source->rank - 1)
+ && (source->dim[i].extent == -1);
+ if (unlikely (compile_options.bounds_check)
+ && lower_bounds != NULL
+ && (lower[i] < source->dim[i].lower_bound ||
+ (!assumed_size && lower[i] > source->dim[i].lower_bound
+ + source->dim[i].extent - 1)))
+ {
+ fprintf (stderr, "CFI_section: Lower bounds must be within the "
+ "bounds of the fortran array (source->dim[%d].lower_bound "
+ "<= lower_bounds[%d] <= source->dim[%d].lower_bound "
+ "+ source->dim[%d].extent - 1, %d <= %d <= %d).\n",
+ i, i, i, i, (int)source->dim[i].lower_bound, (int)lower[i],
+ (int)(source->dim[i].lower_bound
+ + source->dim[i].extent - 1));
+ return CFI_ERROR_OUT_OF_BOUNDS;
+ }
+
+ if (unlikely (compile_options.bounds_check)
+ && upper_bounds != NULL
+ && (upper[i] < source->dim[i].lower_bound
+ || (!assumed_size
+ && upper[i] > source->dim[i].lower_bound
+ + source->dim[i].extent - 1)))
+ {
+ fprintf (stderr, "CFI_section: Upper bounds must be within the "
+ "bounds of the fortran array (source->dim[%d].lower_bound "
+ "<= upper_bounds[%d] <= source->dim[%d].lower_bound + "
+ "source->dim[%d].extent - 1, %d !<= %d !<= %d).\n",
+ i, i, i, i, (int)source->dim[i].lower_bound, (int)upper[i],
+ (int)(source->dim[i].lower_bound
+ + source->dim[i].extent - 1));
+ return CFI_ERROR_OUT_OF_BOUNDS;
+ }
+
+ if (unlikely (compile_options.bounds_check)
+ && upper[i] < lower[i] && stride[i] >= 0)
+ {
+ fprintf (stderr, "CFI_section: If the upper bound is smaller than "
+ "the lower bound for a given dimension (upper[%d] < "
+ "lower[%d], %d < %d), then he stride for said dimension"
+ "t must be negative (stride[%d] < 0, %d < 0).\n",
+ i, i, (int)upper[i], (int)lower[i], i, (int)stride[i]);
+ return CFI_INVALID_STRIDE;
+ }
+ }
+
+ /* Set the appropriate dimension information that gives us access to the
+ * data. */
+ int aux = 0;
+ for (int i = 0; i < source->rank; i++)
+ {
+ if (stride[i] == 0)
+ {
+ aux++;
+ /* Adjust 'lower' for the base address offset. */
+ lower[i] = lower[i] - source->dim[i].lower_bound;
+ continue;
+ }
+ int idx = i - aux;
+ result->dim[idx].lower_bound = lower[i];
+ result->dim[idx].extent = upper[i] - lower[i] + 1;
+ result->dim[idx].sm = stride[i] * source->dim[i].sm;
+ /* Adjust 'lower' for the base address offset. */
+ lower[idx] = lower[idx] - source->dim[i].lower_bound;
+ }
+
+ /* Set the base address. */
+ result->base_addr = CFI_address (source, lower);
+
+ return CFI_SUCCESS;
+}
+
+
+int CFI_select_part (CFI_cdesc_t *result, const CFI_cdesc_t *source,
+ size_t displacement, size_t elem_len)
+{
+ if (unlikely (compile_options.bounds_check))
+ {
+ /* C Descriptors must not be NULL. */
+ if (source == NULL)
+ {
+ fprintf (stderr, "CFI_select_part: Source must not be NULL.\n");
+ return CFI_INVALID_DESCRIPTOR;
+ }
+
+ if (result == NULL)
+ {
+ fprintf (stderr, "CFI_select_part: Result must not be NULL.\n");
+ return CFI_INVALID_DESCRIPTOR;
+ }
+
+ /* Attribute of result will be CFI_attribute_other or
+ CFI_attribute_pointer. */
+ if (result->attribute == CFI_attribute_allocatable)
+ {
+ fprintf (stderr, "CFI_select_part: Result must not describe an "
+ "allocatable object (result->attribute != %d).\n",
+ CFI_attribute_allocatable);
+ return CFI_INVALID_ATTRIBUTE;
+ }
+
+ /* Base address of source must not be NULL. */
+ if (source->base_addr == NULL)
+ {
+ fprintf (stderr, "CFI_select_part: Base address of source must "
+ "not be NULL.\n");
+ return CFI_ERROR_BASE_ADDR_NULL;
+ }
+
+ /* Source and result must have the same rank. */
+ if (source->rank != result->rank)
+ {
+ fprintf (stderr, "CFI_select_part: Source and result must have "
+ "the same rank (source->rank = %d, result->rank = %d).\n",
+ (int)source->rank, (int)result->rank);
+ return CFI_INVALID_RANK;
+ }
+
+ /* Nonallocatable nonpointer must not be an assumed size array. */
+ if (source->rank > 0 && source->dim[source->rank - 1].extent == -1)
+ {
+ fprintf (stderr, "CFI_select_part: Source must not describe an "
+ "assumed size array (source->dim[%d].extent != -1).\n",
+ source->rank - 1);
+ return CFI_INVALID_DESCRIPTOR;
+ }
+ }
+
+ /* Element length. */
+ if (result->type == CFI_type_char || result->type == CFI_type_ucs4_char ||
+ result->type == CFI_type_signed_char)
+ result->elem_len = elem_len;
+
+ if (unlikely (compile_options.bounds_check))
+ {
+ /* Ensure displacement is within the bounds of the element length
+ of source.*/
+ if (displacement > source->elem_len - 1)
+ {
+ fprintf (stderr, "CFI_select_part: Displacement must be within the "
+ "bounds of source (0 <= displacement <= source->elem_len "
+ "- 1, 0 <= %d <= %d).\n", (int)displacement,
+ (int)(source->elem_len - 1));
+ return CFI_ERROR_OUT_OF_BOUNDS;
+ }
+
+ /* Ensure displacement and element length of result are less than or
+ equal to the element length of source. */
+ if (displacement + result->elem_len > source->elem_len)
+ {
+ fprintf (stderr, "CFI_select_part: Displacement plus the element "
+ "length of result must be less than or equal to the "
+ "element length of source (displacement + result->elem_len "
+ "<= source->elem_len, %d + %d = %d <= %d).\n",
+ (int)displacement, (int)result->elem_len,
+ (int)(displacement + result->elem_len),
+ (int)source->elem_len);
+ return CFI_ERROR_OUT_OF_BOUNDS;
+ }
+ }
+
+ if (result->rank > 0)
+ {
+ for (int i = 0; i < result->rank; i++)
+ {
+ result->dim[i].lower_bound = source->dim[i].lower_bound;
+ result->dim[i].extent = source->dim[i].extent;
+ result->dim[i].sm = source->dim[i].sm;
+ }
+ }
+
+ result->base_addr = (char *) source->base_addr + displacement;
+ return CFI_SUCCESS;
+}
+
+
+int CFI_setpointer (CFI_cdesc_t *result, CFI_cdesc_t *source,
+ const CFI_index_t lower_bounds[])
+{
+ /* Result must not be NULL. */
+ if (unlikely (compile_options.bounds_check) && result == NULL)
+ {
+ fprintf (stderr, "CFI_setpointer: Result is NULL.\n");
+ return CFI_INVALID_DESCRIPTOR;
+ }
+
+ /* If source is NULL, the result is a C Descriptor that describes a
+ * disassociated pointer. */
+ if (source == NULL)
+ {
+ result->base_addr = NULL;
+ result->version = CFI_VERSION;
+ result->attribute = CFI_attribute_pointer;
+ }
+ else
+ {
+ /* Check that element lengths, ranks and types of source and result are
+ * the same. */
+ if (unlikely (compile_options.bounds_check))
+ {
+ if (result->elem_len != source->elem_len)
+ {
+ fprintf (stderr, "CFI_setpointer: Element lengths of result "
+ "(result->elem_len = %d) and source (source->elem_len "
+ "= %d) must be the same.\n", (int)result->elem_len,
+ (int)source->elem_len);
+ return CFI_INVALID_ELEM_LEN;
+ }
+
+ if (result->rank != source->rank)
+ {
+ fprintf (stderr, "CFI_setpointer: Ranks of result (result->rank "
+ "= %d) and source (source->rank = %d) must be the same."
+ "\n", result->rank, source->rank);
+ return CFI_INVALID_RANK;
+ }
+
+ if (result->type != source->type)
+ {
+ fprintf (stderr, "CFI_setpointer: Types of result (result->type"
+ "= %d) and source (source->type = %d) must be the same."
+ "\n", result->type, source->type);
+ return CFI_INVALID_TYPE;
+ }
+ }
+
+ /* If the source is a disassociated pointer, the result must also describe
+ * a disassociated pointer. */
+ if (source->base_addr == NULL &&
+ source->attribute == CFI_attribute_pointer)
+ result->base_addr = NULL;
+ else
+ result->base_addr = source->base_addr;
+
+ /* Assign components to result. */
+ result->version = source->version;
+ result->attribute = source->attribute;
+
+ /* Dimension information. */
+ for (int i = 0; i < source->rank; i++)
+ {
+ if (lower_bounds != NULL)
+ result->dim[i].lower_bound = lower_bounds[i];
+ else
+ result->dim[i].lower_bound = source->dim[i].lower_bound;
+
+ result->dim[i].extent = source->dim[i].extent;
+ result->dim[i].sm = source->dim[i].sm;
+ }
+ }
+
+ return CFI_SUCCESS;
+}