1 /* Copyright (C
) 2006-2023 Free Software Foundation
, Inc.
3 This file is part of GCC.
5 GCC is free software
; you can redistribute it and
/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation
; either version
3, or (at your option
) any later
10 GCC is distributed in the hope that it will be useful
, but WITHOUT ANY
11 WARRANTY
; without even the implied warranty of MERCHANTABILITY or
12 FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 You should have received a copy of the GNU General Public License
16 along with GCC
; see the file COPYING3. If not see
17 <http
://www.gnu.org
/licenses
/>.
*/
19 /* This file contains the definition of the types provided by the
20 Fortran
2003 ISO_C_BINDING intrinsic module.
*/
23 # define
NAMED_INTCST(a
,b
,c
,d
)
27 # define
NAMED_REALCST(a
,b
,c
,d
)
31 # define
NAMED_CMPXCST(a
,b
,c
,d
)
35 # define
NAMED_LOGCST(a
,b
,c
)
38 #ifndef NAMED_CHARKNDCST
39 # define
NAMED_CHARKNDCST(a
,b
,c
)
42 #ifndef NAMED_FUNCTION
43 # define
NAMED_FUNCTION(a
,b
,c
,d
)
46 #ifndef NAMED_SUBROUTINE
47 # define
NAMED_SUBROUTINE(a
,b
,c
,d
)
50 /* The arguments to NAMED_
*CST are
:
52 -- the symbol name in the module
, as seen by Fortran code
53 -- the value it has
, for use in trans
-types.cc
54 -- the standard that supports this type
*/
56 NAMED_INTCST (ISOCBINDING_INT
, "c_int", gfc_c_int_kind
, GFC_STD_F2003
)
57 NAMED_INTCST (ISOCBINDING_SHORT
, "c_short", \
58 get_int_kind_from_node (short_integer_type_node
), GFC_STD_F2003
)
59 NAMED_INTCST (ISOCBINDING_LONG
, "c_long", \
60 get_int_kind_from_node (long_integer_type_node
), GFC_STD_F2003
)
61 NAMED_INTCST (ISOCBINDING_LONG_LONG
, "c_long_long", \
62 get_int_kind_from_node (long_long_integer_type_node
), GFC_STD_F2003
)
64 NAMED_INTCST (ISOCBINDING_INTMAX_T
, "c_intmax_t", \
65 get_int_kind_from_name (INTMAX_TYPE
), GFC_STD_F2003
)
66 NAMED_INTCST (ISOCBINDING_INTPTR_T
, "c_intptr_t", \
67 get_int_kind_from_name (INTPTR_TYPE
), GFC_STD_F2003
)
68 NAMED_INTCST (ISOCBINDING_PTRDIFF_T
, "c_ptrdiff_t", \
69 get_int_kind_from_name (PTRDIFF_TYPE
), GFC_STD_F2018
)
70 NAMED_INTCST (ISOCBINDING_SIZE_T
, "c_size_t", \
71 gfc_index_integer_kind
, GFC_STD_F2003
)
72 NAMED_INTCST (ISOCBINDING_SIGNED_CHAR
, "c_signed_char", \
73 get_int_kind_from_node (signed_char_type_node
), GFC_STD_F2003
)
75 NAMED_INTCST (ISOCBINDING_INT8_T
, "c_int8_t", \
76 get_int_kind_from_name (INT8_TYPE
), GFC_STD_F2003
)
77 NAMED_INTCST (ISOCBINDING_INT16_T
, "c_int16_t", \
78 get_int_kind_from_name (INT16_TYPE
), GFC_STD_F2003
)
79 NAMED_INTCST (ISOCBINDING_INT32_T
, "c_int32_t", \
80 get_int_kind_from_name (INT32_TYPE
), GFC_STD_F2003
)
81 NAMED_INTCST (ISOCBINDING_INT64_T
, "c_int64_t", \
82 get_int_kind_from_name (INT64_TYPE
), GFC_STD_F2003
)
84 NAMED_INTCST (ISOCBINDING_INT128_T
, "c_int128_t", \
85 get_int_kind_from_width (128), GFC_STD_GNU
)
87 NAMED_INTCST (ISOCBINDING_INT_LEAST8_T
, "c_int_least8_t", \
88 get_int_kind_from_name (INT_LEAST8_TYPE
), GFC_STD_F2003
)
89 NAMED_INTCST (ISOCBINDING_INT_LEAST16_T
, "c_int_least16_t", \
90 get_int_kind_from_name (INT_LEAST16_TYPE
), GFC_STD_F2003
)
91 NAMED_INTCST (ISOCBINDING_INT_LEAST32_T
, "c_int_least32_t", \
92 get_int_kind_from_name (INT_LEAST32_TYPE
), GFC_STD_F2003
)
93 NAMED_INTCST (ISOCBINDING_INT_LEAST64_T
, "c_int_least64_t", \
94 get_int_kind_from_name (INT_LEAST64_TYPE
), GFC_STD_F2003
)
96 NAMED_INTCST (ISOCBINDING_INT_LEAST128_T
, "c_int_least128_t", \
97 get_int_kind_from_minimal_width (128), GFC_STD_GNU
)
99 NAMED_INTCST (ISOCBINDING_INT_FAST8_T
, "c_int_fast8_t", \
100 get_int_kind_from_name (INT_FAST8_TYPE
), GFC_STD_F2003
)
101 NAMED_INTCST (ISOCBINDING_INT_FAST16_T
, "c_int_fast16_t", \
102 get_int_kind_from_name (INT_FAST16_TYPE
), GFC_STD_F2003
)
103 NAMED_INTCST (ISOCBINDING_INT_FAST32_T
, "c_int_fast32_t", \
104 get_int_kind_from_name (INT_FAST32_TYPE
), GFC_STD_F2003
)
105 NAMED_INTCST (ISOCBINDING_INT_FAST64_T
, "c_int_fast64_t", \
106 get_int_kind_from_name (INT_FAST64_TYPE
), GFC_STD_F2003
)
108 NAMED_INTCST (ISOCBINDING_INT_FAST128_T
, "c_int_fast128_t",
109 get_int_kind_from_width (128), GFC_STD_GNU
)
111 NAMED_REALCST (ISOCBINDING_FLOAT
, "c_float", \
112 get_real_kind_from_node (float_type_node
), GFC_STD_F2003
)
113 NAMED_REALCST (ISOCBINDING_DOUBLE
, "c_double", \
114 get_real_kind_from_node (double_type_node
), GFC_STD_F2003
)
115 NAMED_REALCST (ISOCBINDING_LONG_DOUBLE
, "c_long_double", \
116 get_real_kind_from_node (long_double_type_node
), GFC_STD_F2003
)
118 /* GNU Extension. Note that the equivalence here is specifically to
119 the IEEE
128-bit type _Float128
; if that does not map onto a type
120 otherwise supported by the Fortran front end
, get_real_kind_from_node
121 will reject it as unsupported.
*/
122 NAMED_REALCST (ISOCBINDING_FLOAT128
, "c_float128", \
123 (float128_type_node
== NULL_TREE \
124 ?
-4 : get_real_kind_from_node (float128_type_node
)), \
126 NAMED_CMPXCST (ISOCBINDING_FLOAT_COMPLEX
, "c_float_complex", \
127 get_real_kind_from_node (float_type_node
), GFC_STD_F2003
)
128 NAMED_CMPXCST (ISOCBINDING_DOUBLE_COMPLEX
, "c_double_complex", \
129 get_real_kind_from_node (double_type_node
), GFC_STD_F2003
)
130 NAMED_CMPXCST (ISOCBINDING_LONG_DOUBLE_COMPLEX
, "c_long_double_complex", \
131 get_real_kind_from_node (long_double_type_node
), GFC_STD_F2003
)
133 /* GNU Extension. Similar issues to c_float128 above.
*/
134 NAMED_CMPXCST (ISOCBINDING_FLOAT128_COMPLEX
, "c_float128_complex", \
135 (float128_type_node
== NULL_TREE \
136 ?
-4 : get_real_kind_from_node (float128_type_node
)), \
139 NAMED_LOGCST (ISOCBINDING_BOOL
, "c_bool", \
140 get_int_kind_from_width (BOOL_TYPE_SIZE
))
142 NAMED_CHARKNDCST (ISOCBINDING_CHAR
, "c_char", gfc_default_character_kind
)
144 #ifndef NAMED_CHARCST
145 # define
NAMED_CHARCST(a
,b
,c
)
148 /* Use langhooks to deal with host to target translations.
*/
149 NAMED_CHARCST (ISOCBINDING_NULL_CHAR
, "c_null_char", \
150 lang_hooks.
to_target_charset ('\0'))
151 NAMED_CHARCST (ISOCBINDING_ALERT
, "c_alert", \
152 lang_hooks.
to_target_charset ('\a'))
153 NAMED_CHARCST (ISOCBINDING_BACKSPACE
, "c_backspace", \
154 lang_hooks.
to_target_charset ('\b'))
155 NAMED_CHARCST (ISOCBINDING_FORM_FEED
, "c_form_feed", \
156 lang_hooks.
to_target_charset ('\f'))
157 NAMED_CHARCST (ISOCBINDING_NEW_LINE
, "c_new_line", \
158 lang_hooks.
to_target_charset ('\n'))
159 NAMED_CHARCST (ISOCBINDING_CARRIAGE_RETURN
, "c_carriage_return", \
160 lang_hooks.
to_target_charset ('\r'))
161 NAMED_CHARCST (ISOCBINDING_HORIZONTAL_TAB
, "c_horizontal_tab", \
162 lang_hooks.
to_target_charset ('\t'))
163 NAMED_CHARCST (ISOCBINDING_VERTICAL_TAB
, "c_vertical_tab", \
164 lang_hooks.
to_target_charset ('\v'))
167 # define
DERIVED_TYPE(a
,b
,c
)
170 DERIVED_TYPE (ISOCBINDING_PTR
, "c_ptr", \
171 get_int_kind_from_node (ptr_type_node
))
172 DERIVED_TYPE (ISOCBINDING_NULL_PTR
, "c_null_ptr", \
173 get_int_kind_from_node (ptr_type_node
))
174 DERIVED_TYPE (ISOCBINDING_FUNPTR
, "c_funptr", \
175 get_int_kind_from_node (ptr_type_node
))
176 DERIVED_TYPE (ISOCBINDING_NULL_FUNPTR
, "c_null_funptr", \
177 get_int_kind_from_node (ptr_type_node
))
179 /* The arguments to NAMED_FUNCTIONS and NAMED_SUBROUTINES are
:
181 -- the symbol name in the module
, as seen by Fortran code
182 -- the Fortran standard
*/
184 NAMED_SUBROUTINE (ISOCBINDING_F_POINTER
, "c_f_pointer",
185 GFC_ISYM_C_F_POINTER
, GFC_STD_F2003
)
186 NAMED_SUBROUTINE (ISOCBINDING_F_PROCPOINTER
, "c_f_procpointer",
187 GFC_ISYM_C_F_PROCPOINTER
, GFC_STD_F2003
)
189 NAMED_FUNCTION (ISOCBINDING_ASSOCIATED
, "c_associated",
190 GFC_ISYM_C_ASSOCIATED
, GFC_STD_F2003
)
191 NAMED_FUNCTION (ISOCBINDING_FUNLOC
, "c_funloc",
192 GFC_ISYM_C_FUNLOC
, GFC_STD_F2003
)
193 NAMED_FUNCTION (ISOCBINDING_LOC
, "c_loc",
194 GFC_ISYM_C_LOC
, GFC_STD_F2003
)
196 NAMED_FUNCTION (ISOCBINDING_C_SIZEOF
, "c_sizeof", \
197 GFC_ISYM_C_SIZEOF
, GFC_STD_F2008
)
204 #undef NAMED_CHARKNDCST
206 #undef NAMED_FUNCTION
207 #undef NAMED_SUBROUTINE