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