Line data Source code
1 : /* Copyright (C) 2006-2026 Free Software Foundation, Inc.
2 :
3 : This file is part of GCC.
4 :
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
8 : version.
9 :
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
13 : for more details.
14 :
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/>. */
18 :
19 : /* This file contains the definition of the types provided by the
20 : Fortran 2003 ISO_C_BINDING intrinsic module. The ordering of
21 : the entries matters for the *.mod backwards compatibility. */
22 :
23 : #ifndef NAMED_INTCST
24 : # define NAMED_INTCST(a,b,c,d)
25 : #endif
26 :
27 : #ifndef NAMED_REALCST
28 : # define NAMED_REALCST(a,b,c,d)
29 : #endif
30 :
31 : #ifndef NAMED_CMPXCST
32 : # define NAMED_CMPXCST(a,b,c,d)
33 : #endif
34 :
35 : #ifndef NAMED_LOGCST
36 : # define NAMED_LOGCST(a,b,c)
37 : #endif
38 :
39 : #ifndef NAMED_CHARKNDCST
40 : # define NAMED_CHARKNDCST(a,b,c)
41 : #endif
42 :
43 : #ifndef NAMED_FUNCTION
44 : # define NAMED_FUNCTION(a,b,c,d)
45 : #endif
46 :
47 : #ifndef NAMED_SUBROUTINE
48 : # define NAMED_SUBROUTINE(a,b,c,d)
49 : #endif
50 :
51 : #ifndef NAMED_UINTCST
52 : # define NAMED_UINTCST(a,b,c,d)
53 : #endif
54 :
55 : /* The arguments to NAMED_*CST are:
56 : -- an internal name
57 : -- the symbol name in the module, as seen by Fortran code
58 : -- the value it has, for use in trans-types.cc
59 : -- the standard that supports this type */
60 :
61 151346 : NAMED_INTCST (ISOCBINDING_INT, "c_int", gfc_c_int_kind, GFC_STD_F2003)
62 149880 : NAMED_INTCST (ISOCBINDING_SHORT, "c_short", \
63 : get_int_kind_from_node (short_integer_type_node), GFC_STD_F2003)
64 149879 : NAMED_INTCST (ISOCBINDING_LONG, "c_long", \
65 : get_int_kind_from_node (long_integer_type_node), GFC_STD_F2003)
66 149879 : NAMED_INTCST (ISOCBINDING_LONG_LONG, "c_long_long", \
67 : get_int_kind_from_node (long_long_integer_type_node), GFC_STD_F2003)
68 :
69 150286 : NAMED_INTCST (ISOCBINDING_INTMAX_T, "c_intmax_t", \
70 : get_int_kind_from_name (INTMAX_TYPE), GFC_STD_F2003)
71 150431 : NAMED_INTCST (ISOCBINDING_INTPTR_T, "c_intptr_t", \
72 : get_int_kind_from_name (INTPTR_TYPE), GFC_STD_F2003)
73 150293 : NAMED_INTCST (ISOCBINDING_PTRDIFF_T, "c_ptrdiff_t", \
74 : get_int_kind_from_name (PTRDIFF_TYPE), GFC_STD_F2018)
75 151642 : NAMED_INTCST (ISOCBINDING_SIZE_T, "c_size_t", \
76 : gfc_index_integer_kind, GFC_STD_F2003)
77 149999 : NAMED_INTCST (ISOCBINDING_SIGNED_CHAR, "c_signed_char", \
78 : get_int_kind_from_node (signed_char_type_node), GFC_STD_F2003)
79 :
80 149879 : NAMED_INTCST (ISOCBINDING_INT8_T, "c_int8_t", \
81 : get_int_kind_from_name (INT8_TYPE), GFC_STD_F2003)
82 149975 : NAMED_INTCST (ISOCBINDING_INT16_T, "c_int16_t", \
83 : get_int_kind_from_name (INT16_TYPE), GFC_STD_F2003)
84 151297 : NAMED_INTCST (ISOCBINDING_INT32_T, "c_int32_t", \
85 : get_int_kind_from_name (INT32_TYPE), GFC_STD_F2003)
86 151702 : NAMED_INTCST (ISOCBINDING_INT64_T, "c_int64_t", \
87 : get_int_kind_from_name (INT64_TYPE), GFC_STD_F2003)
88 : /* GNU Extension. */
89 149881 : NAMED_INTCST (ISOCBINDING_INT128_T, "c_int128_t", \
90 : get_int_kind_from_width (128), GFC_STD_GNU)
91 :
92 149879 : NAMED_INTCST (ISOCBINDING_INT_LEAST8_T, "c_int_least8_t", \
93 : get_int_kind_from_name (INT_LEAST8_TYPE), GFC_STD_F2003)
94 149879 : NAMED_INTCST (ISOCBINDING_INT_LEAST16_T, "c_int_least16_t", \
95 : get_int_kind_from_name (INT_LEAST16_TYPE), GFC_STD_F2003)
96 149879 : NAMED_INTCST (ISOCBINDING_INT_LEAST32_T, "c_int_least32_t", \
97 : get_int_kind_from_name (INT_LEAST32_TYPE), GFC_STD_F2003)
98 150286 : NAMED_INTCST (ISOCBINDING_INT_LEAST64_T, "c_int_least64_t", \
99 : get_int_kind_from_name (INT_LEAST64_TYPE), GFC_STD_F2003)
100 : /* GNU Extension. */
101 149881 : NAMED_INTCST (ISOCBINDING_INT_LEAST128_T, "c_int_least128_t", \
102 : get_int_kind_from_minimal_width (128), GFC_STD_GNU)
103 :
104 149879 : NAMED_INTCST (ISOCBINDING_INT_FAST8_T, "c_int_fast8_t", \
105 : get_int_kind_from_name (INT_FAST8_TYPE), GFC_STD_F2003)
106 150286 : NAMED_INTCST (ISOCBINDING_INT_FAST16_T, "c_int_fast16_t", \
107 : get_int_kind_from_name (INT_FAST16_TYPE), GFC_STD_F2003)
108 150286 : NAMED_INTCST (ISOCBINDING_INT_FAST32_T, "c_int_fast32_t", \
109 : get_int_kind_from_name (INT_FAST32_TYPE), GFC_STD_F2003)
110 150286 : NAMED_INTCST (ISOCBINDING_INT_FAST64_T, "c_int_fast64_t", \
111 : get_int_kind_from_name (INT_FAST64_TYPE), GFC_STD_F2003)
112 : /* GNU Extension. */
113 149881 : NAMED_INTCST (ISOCBINDING_INT_FAST128_T, "c_int_fast128_t",
114 : get_int_kind_from_width (128), GFC_STD_GNU)
115 :
116 149897 : NAMED_REALCST (ISOCBINDING_FLOAT, "c_float", \
117 : get_real_kind_from_node (float_type_node), GFC_STD_F2003)
118 149894 : NAMED_REALCST (ISOCBINDING_DOUBLE, "c_double", \
119 : get_real_kind_from_node (double_type_node), GFC_STD_F2003)
120 149885 : NAMED_REALCST (ISOCBINDING_LONG_DOUBLE, "c_long_double", \
121 : get_real_kind_from_node (long_double_type_node), GFC_STD_F2003)
122 :
123 : /* GNU Extension. Note that the equivalence here is specifically to
124 : the IEEE 128-bit type _Float128; if that does not map onto a type
125 : otherwise supported by the Fortran front end, get_real_kind_from_node
126 : will reject it as unsupported. */
127 149881 : NAMED_REALCST (ISOCBINDING_FLOAT128, "c_float128", \
128 : (float128_type_node == NULL_TREE \
129 : ? -4 : get_real_kind_from_node (float128_type_node)), \
130 : GFC_STD_GNU)
131 149891 : NAMED_CMPXCST (ISOCBINDING_FLOAT_COMPLEX, "c_float_complex", \
132 : get_real_kind_from_node (float_type_node), GFC_STD_F2003)
133 149891 : NAMED_CMPXCST (ISOCBINDING_DOUBLE_COMPLEX, "c_double_complex", \
134 : get_real_kind_from_node (double_type_node), GFC_STD_F2003)
135 149891 : NAMED_CMPXCST (ISOCBINDING_LONG_DOUBLE_COMPLEX, "c_long_double_complex", \
136 : get_real_kind_from_node (long_double_type_node), GFC_STD_F2003)
137 :
138 : /* GNU Extension. Similar issues to c_float128 above. */
139 149887 : NAMED_CMPXCST (ISOCBINDING_FLOAT128_COMPLEX, "c_float128_complex", \
140 : (float128_type_node == NULL_TREE \
141 : ? -4 : get_real_kind_from_node (float128_type_node)), \
142 : GFC_STD_GNU)
143 :
144 146681 : NAMED_LOGCST (ISOCBINDING_BOOL, "c_bool", \
145 : get_int_kind_from_width (BOOL_TYPE_SIZE))
146 :
147 146681 : NAMED_CHARKNDCST (ISOCBINDING_CHAR, "c_char", gfc_default_character_kind)
148 :
149 : #ifndef NAMED_CHARCST
150 : # define NAMED_CHARCST(a,b,c)
151 : #endif
152 :
153 : /* Use langhooks to deal with host to target translations. */
154 57126 : NAMED_CHARCST (ISOCBINDING_NULL_CHAR, "c_null_char", \
155 : lang_hooks.to_target_charset ('\0'))
156 57126 : NAMED_CHARCST (ISOCBINDING_ALERT, "c_alert", \
157 : lang_hooks.to_target_charset ('\a'))
158 57126 : NAMED_CHARCST (ISOCBINDING_BACKSPACE, "c_backspace", \
159 : lang_hooks.to_target_charset ('\b'))
160 57126 : NAMED_CHARCST (ISOCBINDING_FORM_FEED, "c_form_feed", \
161 : lang_hooks.to_target_charset ('\f'))
162 57126 : NAMED_CHARCST (ISOCBINDING_NEW_LINE, "c_new_line", \
163 : lang_hooks.to_target_charset ('\n'))
164 57126 : NAMED_CHARCST (ISOCBINDING_CARRIAGE_RETURN, "c_carriage_return", \
165 : lang_hooks.to_target_charset ('\r'))
166 57126 : NAMED_CHARCST (ISOCBINDING_HORIZONTAL_TAB, "c_horizontal_tab", \
167 : lang_hooks.to_target_charset ('\t'))
168 57126 : NAMED_CHARCST (ISOCBINDING_VERTICAL_TAB, "c_vertical_tab", \
169 : lang_hooks.to_target_charset ('\v'))
170 :
171 : #ifndef DERIVED_TYPE
172 : # define DERIVED_TYPE(a,b,c)
173 : #endif
174 :
175 31578 : DERIVED_TYPE (ISOCBINDING_PTR, "c_ptr", \
176 : get_int_kind_from_node (ptr_type_node))
177 31578 : DERIVED_TYPE (ISOCBINDING_NULL_PTR, "c_null_ptr", \
178 : get_int_kind_from_node (ptr_type_node))
179 31578 : DERIVED_TYPE (ISOCBINDING_FUNPTR, "c_funptr", \
180 : get_int_kind_from_node (ptr_type_node))
181 31578 : DERIVED_TYPE (ISOCBINDING_NULL_FUNPTR, "c_null_funptr", \
182 : get_int_kind_from_node (ptr_type_node))
183 :
184 : /* The arguments to NAMED_FUNCTIONS and NAMED_SUBROUTINES are:
185 : -- the ISYM
186 : -- the symbol name in the module, as seen by Fortran code
187 : -- the Fortran standard */
188 :
189 38094 : NAMED_SUBROUTINE (ISOCBINDING_F_POINTER, "c_f_pointer",
190 : GFC_ISYM_C_F_POINTER, GFC_STD_F2003)
191 37976 : NAMED_SUBROUTINE (ISOCBINDING_F_PROCPOINTER, "c_f_procpointer",
192 : GFC_ISYM_C_F_PROCPOINTER, GFC_STD_F2003)
193 37928 : NAMED_SUBROUTINE (ISOCBINDING_F_STRPOINTER, "c_f_strpointer",
194 : GFC_ISYM_C_F_STRPOINTER, GFC_STD_F2023)
195 :
196 38146 : NAMED_FUNCTION (ISOCBINDING_ASSOCIATED, "c_associated",
197 : GFC_ISYM_C_ASSOCIATED, GFC_STD_F2003)
198 38046 : NAMED_FUNCTION (ISOCBINDING_FUNLOC, "c_funloc",
199 : GFC_ISYM_C_FUNLOC, GFC_STD_F2003)
200 38234 : NAMED_FUNCTION (ISOCBINDING_LOC, "c_loc",
201 : GFC_ISYM_C_LOC, GFC_STD_F2003)
202 :
203 38011 : NAMED_FUNCTION (ISOCBINDING_C_SIZEOF, "c_sizeof", \
204 : GFC_ISYM_C_SIZEOF, GFC_STD_F2008)
205 :
206 37968 : NAMED_FUNCTION (ISOCBINDING_F_C_STRING, "f_c_string", \
207 : GFC_ISYM_F_C_STRING, GFC_STD_F2023)
208 :
209 : /* UNSIGNED. */
210 149879 : NAMED_UINTCST (ISOCBINDING_UINT, "c_unsigned", gfc_c_uint_kind, \
211 : GFC_STD_UNSIGNED)
212 149879 : NAMED_UINTCST (ISOCBINDING_USHORT, "c_unsigned_short", \
213 : get_unsigned_kind_from_node (short_unsigned_type_node), \
214 : GFC_STD_UNSIGNED)
215 149879 : NAMED_UINTCST (ISOCBINDING_UCHAR, "c_unsigned_char", \
216 : get_unsigned_kind_from_node (unsigned_char_type_node), \
217 : GFC_STD_UNSIGNED)
218 149879 : NAMED_UINTCST (ISOCBINDING_ULONG, "c_unsigned_long", \
219 : get_unsigned_kind_from_node (long_unsigned_type_node), \
220 : GFC_STD_UNSIGNED)
221 149879 : NAMED_UINTCST (ISOCBINDING_ULONGLONG, "c_unsigned_long_long", \
222 : get_unsigned_kind_from_node (long_long_unsigned_type_node), \
223 : GFC_STD_UNSIGNED)
224 150286 : NAMED_UINTCST (ISOCBINDING_UINTMAX_T, "c_uintmax_t", \
225 : get_uint_kind_from_name (UINTMAX_TYPE), GFC_STD_UNSIGNED)
226 149879 : NAMED_UINTCST (ISOCBINDING_UINT8_T, "c_uint8_t", \
227 : get_uint_kind_from_name (UINT8_TYPE), GFC_STD_UNSIGNED)
228 149879 : NAMED_UINTCST (ISOCBINDING_UINT16_T, "c_uint16_t", \
229 : get_uint_kind_from_name (UINT16_TYPE), GFC_STD_UNSIGNED)
230 149879 : NAMED_UINTCST (ISOCBINDING_UINT32_T, "c_uint32_t", \
231 : get_uint_kind_from_name (UINT32_TYPE), GFC_STD_UNSIGNED)
232 150286 : NAMED_UINTCST (ISOCBINDING_UINT64_T, "c_uint64_t", \
233 : get_uint_kind_from_name (UINT64_TYPE), GFC_STD_UNSIGNED)
234 149879 : NAMED_UINTCST (ISOCBINDING_UINT128_T, "c_uint128_t", \
235 : get_uint_kind_from_width (128), GFC_STD_UNSIGNED)
236 149879 : NAMED_UINTCST (ISOCBINDING_UINT_LEAST8_T, "c_uint_least8_t", \
237 : get_uint_kind_from_name (UINT_LEAST8_TYPE), \
238 : GFC_STD_UNSIGNED)
239 149879 : NAMED_UINTCST (ISOCBINDING_UINT_LEAST16_T, "c_uint_least16_t", \
240 : get_uint_kind_from_name (UINT_LEAST16_TYPE), \
241 : GFC_STD_UNSIGNED)
242 149879 : NAMED_UINTCST (ISOCBINDING_UINT_LEAST32_T, "c_uint_least32_t", \
243 : get_uint_kind_from_name (UINT_LEAST32_TYPE),\
244 : GFC_STD_UNSIGNED)
245 150286 : NAMED_UINTCST (ISOCBINDING_UINT_LEAST64_T, "c_uint_least64_t", \
246 : get_uint_kind_from_name (UINT_LEAST64_TYPE),\
247 : GFC_STD_UNSIGNED)
248 149879 : NAMED_UINTCST (ISOCBINDING_UINT_LEAST128_T, "c_uint_least128_t", \
249 : get_uint_kind_from_width (128), GFC_STD_UNSIGNED)
250 149879 : NAMED_UINTCST (ISOCBINDING_UINT_FAST8_T, "c_uint_fast8_t", \
251 : get_uint_kind_from_name (UINT_FAST8_TYPE), \
252 : GFC_STD_UNSIGNED)
253 150286 : NAMED_UINTCST (ISOCBINDING_UINT_FAST16_T, "c_uint_fast16_t", \
254 : get_uint_kind_from_name (UINT_FAST16_TYPE), \
255 : GFC_STD_UNSIGNED)
256 150286 : NAMED_UINTCST (ISOCBINDING_UINT_FAST32_T, "c_uint_fast32_t", \
257 : get_uint_kind_from_name (UINT_FAST32_TYPE),\
258 : GFC_STD_UNSIGNED)
259 150286 : NAMED_UINTCST (ISOCBINDING_UINT_FAST64_T, "c_uint_fast64_t", \
260 : get_uint_kind_from_name (UINT_FAST64_TYPE),\
261 : GFC_STD_UNSIGNED)
262 149879 : NAMED_UINTCST (ISOCBINDING_UINT_FAST128_T, "c_uint_fast128_t", \
263 : get_uint_kind_from_width (128), GFC_STD_UNSIGNED)
264 :
265 : #undef NAMED_INTCST
266 : #undef NAMED_UINTCST
267 : #undef NAMED_REALCST
268 : #undef NAMED_CMPXCST
269 : #undef NAMED_LOGCST
270 : #undef NAMED_CHARCST
271 : #undef NAMED_CHARKNDCST
272 : #undef DERIVED_TYPE
273 : #undef NAMED_FUNCTION
274 : #undef NAMED_SUBROUTINE
|