10#ifndef CFI_ISO_FORTRAN_BINDING_H_
11#define CFI_ISO_FORTRAN_BINDING_H_
17#ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
19#define FORTRAN_ISO_NAMESPACE_
33#define CFI_VERSION 20240719
35#if !defined CFI_MAX_RANK || !defined __OVERRIDE_CFI_MAX_RANK
36#define CFI_MAX_RANK 15
38typedef unsigned char CFI_rank_t;
43typedef ptrdiff_t CFI_index_t;
45typedef unsigned char CFI_attribute_t;
46#define CFI_attribute_pointer 1
47#define CFI_attribute_allocatable 2
48#define CFI_attribute_other 0
50typedef signed char CFI_type_t;
55#define CFI_type_signed_char 1
56#define CFI_type_short 2
58#define CFI_type_long 4
59#define CFI_type_long_long 5
60#define CFI_type_size_t 6
61#define CFI_type_int8_t 7
62#define CFI_type_int16_t 8
63#define CFI_type_int32_t 9
64#define CFI_type_int64_t 10
65#define CFI_type_int128_t 11
66#define CFI_type_int_least8_t 12
67#define CFI_type_int_least16_t 13
68#define CFI_type_int_least32_t 14
69#define CFI_type_int_least64_t 15
70#define CFI_type_int_least128_t 16
71#define CFI_type_int_fast8_t 17
72#define CFI_type_int_fast16_t 18
73#define CFI_type_int_fast32_t 19
74#define CFI_type_int_fast64_t 20
75#define CFI_type_int_fast128_t 21
76#define CFI_type_intmax_t 22
77#define CFI_type_intptr_t 23
78#define CFI_type_ptrdiff_t 24
79#define CFI_type_half_float 25
80#define CFI_type_bfloat 26
81#define CFI_type_float 27
82#define CFI_type_double 28
83#define CFI_type_extended_double 29
84#define CFI_type_long_double 30
85#define CFI_type_float128 31
86#define CFI_type_half_float_Complex 32
87#define CFI_type_bfloat_Complex 33
88#define CFI_type_float_Complex 34
89#define CFI_type_double_Complex 35
90#define CFI_type_extended_double_Complex 36
91#define CFI_type_long_double_Complex 37
92#define CFI_type_float128_Complex 38
93#define CFI_type_Bool 39
94#define CFI_type_char 40
95#define CFI_type_cptr 41
96#define CFI_type_struct 42
97#define CFI_type_char16_t 43
98#define CFI_type_char32_t 44
99#define CFI_type_uint8_t 45
100#define CFI_type_uint16_t 46
101#define CFI_type_uint32_t 47
102#define CFI_type_uint64_t 48
103#define CFI_type_uint128_t 49
104#define CFI_TYPE_LAST CFI_type_uint128_t
105#define CFI_type_other (-1)
111#define CFI_ERROR_BASE_ADDR_NULL 11
112#define CFI_ERROR_BASE_ADDR_NOT_NULL 12
113#define CFI_INVALID_ELEM_LEN 13
114#define CFI_INVALID_RANK 14
115#define CFI_INVALID_TYPE 15
116#define CFI_INVALID_ATTRIBUTE 16
117#define CFI_INVALID_EXTENT 17
118#define CFI_INVALID_DESCRIPTOR 18
119#define CFI_ERROR_MEM_ALLOCATION 19
120#define CFI_ERROR_OUT_OF_BOUNDS 20
124 CFI_index_t lower_bound;
130namespace cfi_internal {
135extern "C++" template <
typename T>
struct FlexibleArray : T {
136 RT_API_ATTRS T &operator[](
int index) {
return *(
this + index); }
137 RT_API_ATTRS
const T &operator[](
int index)
const {
return *(
this + index); }
138 RT_API_ATTRS
operator T *() {
return this; }
139 RT_API_ATTRS
operator const T *()
const {
return this; }
147#define _CFI_CDESC_T_HEADER_MEMBERS \
155 CFI_attribute_t attribute; \
161 _CFI_CDESC_T_HEADER_MEMBERS
163 cfi_internal::FlexibleArray<CFI_dim_t> dim;
174namespace cfi_internal {
175extern "C++" template <
int r>
struct CdescStorage :
public CFI_cdesc_t {
176 static_assert((r > 1 && r <= CFI_MAX_RANK),
"CFI_INVALID_RANK");
179extern "C++" template <>
struct CdescStorage<1> :
public CFI_cdesc_t {};
180extern "C++" template <>
struct CdescStorage<0> :
public CFI_cdesc_t {};
182#define CFI_CDESC_T(rank) \
183 FORTRAN_ISO_NAMESPACE_::cfi_internal::CdescStorage<rank>
185#define CFI_CDESC_T(_RANK) \
187 _CFI_CDESC_T_HEADER_MEMBERS \
188 CFI_dim_t dim[_RANK]; \
196RT_API_ATTRS
void *CFI_address(
197 const CFI_cdesc_t *,
const CFI_index_t subscripts[]);
198RT_API_ATTRS
int CFI_allocate(
CFI_cdesc_t *,
const CFI_index_t lower_bounds[],
199 const CFI_index_t upper_bounds[],
size_t elem_len);
201RT_API_ATTRS
int CFI_establish(
CFI_cdesc_t *,
void *base_addr, CFI_attribute_t,
202 CFI_type_t,
size_t elem_len, CFI_rank_t,
const CFI_index_t extents[]);
203RT_API_ATTRS
int CFI_is_contiguous(
const CFI_cdesc_t *);
205 const CFI_index_t lower_bounds[],
const CFI_index_t upper_bounds[],
206 const CFI_index_t strides[]);
208 size_t displacement,
size_t elem_len);
209RT_API_ATTRS
int CFI_setpointer(
Definition: ISO_Fortran_binding.h:158
Definition: ISO_Fortran_binding.h:123