1 /* Copyright (C
) 2006, 2007, 2008 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
)
31 # define
NAMED_CMPXCST(a
,b
,c
)
35 # define
NAMED_LOGCST(a
,b
,c
)
38 #ifndef NAMED_CHARKNDCST
39 # define
NAMED_CHARKNDCST(a
,b
,c
)
42 /* The arguments to NAMED_
*CST are
:
44 -- the symbol name in the module
, as seen by Fortran code
45 -- the value it has
, for use in trans
-types.c
46 -- the standard that supports this type
*/
48 NAMED_INTCST (ISOCBINDING_INT
, "c_int", gfc_c_int_kind
, GFC_STD_F2003
)
49 NAMED_INTCST (ISOCBINDING_SHORT
, "c_short", \
50 get_int_kind_from_node (short_integer_type_node
), GFC_STD_F2003
)
51 NAMED_INTCST (ISOCBINDING_LONG
, "c_long", \
52 get_int_kind_from_node (long_integer_type_node
), GFC_STD_F2003
)
53 NAMED_INTCST (ISOCBINDING_LONG_LONG
, "c_long_long", \
54 get_int_kind_from_node (long_long_integer_type_node
), GFC_STD_F2003
)
56 NAMED_INTCST (ISOCBINDING_INTMAX_T
, "c_intmax_t", \
57 get_int_kind_from_node (intmax_type_node
), GFC_STD_F2003
)
58 NAMED_INTCST (ISOCBINDING_INTPTR_T
, "c_intptr_t", \
59 get_int_kind_from_node (ptr_type_node
), GFC_STD_F2003
)
60 NAMED_INTCST (ISOCBINDING_SIZE_T
, "c_size_t", \
61 gfc_index_integer_kind
, GFC_STD_F2003
)
62 NAMED_INTCST (ISOCBINDING_SIGNED_CHAR
, "c_signed_char", \
63 get_int_kind_from_node (signed_char_type_node
), GFC_STD_F2003
)
65 NAMED_INTCST (ISOCBINDING_INT8_T
, "c_int8_t", get_int_kind_from_width (8), \
67 NAMED_INTCST (ISOCBINDING_INT16_T
, "c_int16_t", get_int_kind_from_width (16), \
69 NAMED_INTCST (ISOCBINDING_INT32_T
, "c_int32_t", get_int_kind_from_width (32), \
71 NAMED_INTCST (ISOCBINDING_INT64_T
, "c_int64_t", get_int_kind_from_width (64), \
74 NAMED_INTCST (ISOCBINDING_INT128_T
, "c_int128_t", get_int_kind_from_width (128), \
77 NAMED_INTCST (ISOCBINDING_INT_LEAST8_T
, "c_int_least8_t", \
78 get_int_kind_from_minimal_width (8), GFC_STD_F2003
)
79 NAMED_INTCST (ISOCBINDING_INT_LEAST16_T
, "c_int_least16_t", \
80 get_int_kind_from_minimal_width (16), GFC_STD_F2003
)
81 NAMED_INTCST (ISOCBINDING_INT_LEAST32_T
, "c_int_least32_t", \
82 get_int_kind_from_minimal_width (32), GFC_STD_F2003
)
83 NAMED_INTCST (ISOCBINDING_INT_LEAST64_T
, "c_int_least64_t", \
84 get_int_kind_from_minimal_width (64), GFC_STD_F2003
)
86 NAMED_INTCST (ISOCBINDING_INT_LEAST128_T
, "c_int_least128_t", \
87 get_int_kind_from_minimal_width (128), GFC_STD_GNU
)
89 /* TODO
: Implement c_int_fast
*_t. Depends on PR
448.
*/
90 NAMED_INTCST (ISOCBINDING_INT_FAST8_T
, "c_int_fast8_t", -2, GFC_STD_F2003
)
91 NAMED_INTCST (ISOCBINDING_INT_FAST16_T
, "c_int_fast16_t", -2, GFC_STD_F2003
)
92 NAMED_INTCST (ISOCBINDING_INT_FAST32_T
, "c_int_fast32_t", -2, GFC_STD_F2003
)
93 NAMED_INTCST (ISOCBINDING_INT_FAST64_T
, "c_int_fast64_t", -2, GFC_STD_F2003
)
95 NAMED_INTCST (ISOCBINDING_INT_FAST128_T
, "c_int_fast128_t", -2, GFC_STD_GNU
)
97 NAMED_REALCST (ISOCBINDING_FLOAT
, "c_float", \
98 get_real_kind_from_node (float_type_node
))
99 NAMED_REALCST (ISOCBINDING_DOUBLE
, "c_double", \
100 get_real_kind_from_node (double_type_node
))
101 NAMED_REALCST (ISOCBINDING_LONG_DOUBLE
, "c_long_double", \
102 get_real_kind_from_node (long_double_type_node
))
103 NAMED_CMPXCST (ISOCBINDING_FLOAT_COMPLEX
, "c_float_complex", \
104 get_real_kind_from_node (float_type_node
))
105 NAMED_CMPXCST (ISOCBINDING_DOUBLE_COMPLEX
, "c_double_complex", \
106 get_real_kind_from_node (double_type_node
))
107 NAMED_CMPXCST (ISOCBINDING_LONG_DOUBLE_COMPLEX
, "c_long_double_complex", \
108 get_real_kind_from_node (long_double_type_node
))
110 NAMED_LOGCST (ISOCBINDING_BOOL
, "c_bool", \
111 get_int_kind_from_width (BOOL_TYPE_SIZE
))
113 NAMED_CHARKNDCST (ISOCBINDING_CHAR
, "c_char", gfc_default_character_kind
)
115 #ifndef NAMED_CHARCST
116 # define
NAMED_CHARCST(a
,b
,c
)
119 /* Use langhooks to deal with host to target translations.
*/
120 NAMED_CHARCST (ISOCBINDING_NULL_CHAR
, "c_null_char", \
121 lang_hooks.
to_target_charset ('\0'))
122 NAMED_CHARCST (ISOCBINDING_ALERT
, "c_alert", \
123 lang_hooks.
to_target_charset ('\a'))
124 NAMED_CHARCST (ISOCBINDING_BACKSPACE
, "c_backspace", \
125 lang_hooks.
to_target_charset ('\b'))
126 NAMED_CHARCST (ISOCBINDING_FORM_FEED
, "c_form_feed", \
127 lang_hooks.
to_target_charset ('\f'))
128 NAMED_CHARCST (ISOCBINDING_NEW_LINE
, "c_new_line", \
129 lang_hooks.
to_target_charset ('\n'))
130 NAMED_CHARCST (ISOCBINDING_CARRIAGE_RETURN
, "c_carriage_return", \
131 lang_hooks.
to_target_charset ('\r'))
132 NAMED_CHARCST (ISOCBINDING_HORIZONTAL_TAB
, "c_horizontal_tab", \
133 lang_hooks.
to_target_charset ('\t'))
134 NAMED_CHARCST (ISOCBINDING_VERTICAL_TAB
, "c_vertical_tab", \
135 lang_hooks.
to_target_charset ('\v'))
138 # define
DERIVED_TYPE(a
,b
,c
)
141 DERIVED_TYPE (ISOCBINDING_PTR
, "c_ptr", \
142 get_int_kind_from_node (ptr_type_node
))
143 DERIVED_TYPE (ISOCBINDING_NULL_PTR
, "c_null_ptr", \
144 get_int_kind_from_node (ptr_type_node
))
145 DERIVED_TYPE (ISOCBINDING_FUNPTR
, "c_funptr", \
146 get_int_kind_from_node (ptr_type_node
))
147 DERIVED_TYPE (ISOCBINDING_NULL_FUNPTR
, "c_null_funptr", \
148 get_int_kind_from_node (ptr_type_node
))
152 # define
PROCEDURE(a
,b
)
155 PROCEDURE (ISOCBINDING_F_POINTER
, "c_f_pointer")
156 PROCEDURE (ISOCBINDING_ASSOCIATED
, "c_associated")
157 PROCEDURE (ISOCBINDING_LOC
, "c_loc")
158 PROCEDURE (ISOCBINDING_FUNLOC
, "c_funloc")
160 /* Insert c_f_procpointer
, though unsupported for now.
*/
161 PROCEDURE (ISOCBINDING_F_PROCPOINTER
, "c_f_procpointer")
168 #undef NAMED_CHARKNDCST