Merged with mainline at revision 126229.
[official-gcc.git] / libgfortran / intrinsics / iso_c_generated_procs.c
blobf60b264dba6e0d610b1603f4a75e4b3ab30b7915
1 /* Implementation of the ISO_C_BINDING library helper generated functions.
2 Copyright (C) 2007 Free Software Foundation, Inc.
3 Contributed by Christopher Rickett.
5 This file is part of the GNU Fortran 95 runtime library (libgfortran).
7 Libgfortran is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 In addition to the permissions in the GNU General Public License, the
13 Free Software Foundation gives you unlimited permission to link the
14 compiled version of this file into combinations with other programs,
15 and to distribute those combinations without any restriction coming
16 from the use of this file. (The General Public License restrictions
17 do apply in other respects; for example, they cover modification of
18 the file, and distribution when not linked into a combine
19 executable.)
21 Libgfortran is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public
27 License along with libgfortran; see the file COPYING. If not,
28 write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
29 Boston, MA 02110-1301, USA. */
32 #include "libgfortran.h"
33 #include "iso_c_binding.h"
36 /* TODO: This file needs to be finished so that a function is provided
37 for all possible type/kind combinations! */
39 #ifdef HAVE_GFC_INTEGER_1
40 void ISO_C_BINDING_PREFIX (c_f_pointer_i1) (void *, gfc_array_void *,
41 const array_t *);
42 #endif
44 #ifdef HAVE_GFC_INTEGER_2
45 void ISO_C_BINDING_PREFIX (c_f_pointer_i2) (void *, gfc_array_void *,
46 const array_t *);
47 #endif
49 #ifdef HAVE_GFC_INTEGER_4
50 void ISO_C_BINDING_PREFIX (c_f_pointer_i4) (void *, gfc_array_void *,
51 const array_t *);
52 #endif
54 #ifdef HAVE_GFC_INTEGER_8
55 void ISO_C_BINDING_PREFIX (c_f_pointer_i8) (void *, gfc_array_void *,
56 const array_t *);
57 #endif
59 #ifdef HAVE_GFC_INTEGER_16
60 void ISO_C_BINDING_PREFIX (c_f_pointer_i16) (void *, gfc_array_void *,
61 const array_t *);
62 #endif
64 #ifdef HAVE_GFC_REAL_4
65 void ISO_C_BINDING_PREFIX (c_f_pointer_r4) (void *, gfc_array_void *,
66 const array_t *);
67 #endif
69 #ifdef HAVE_GFC_REAL_8
70 void ISO_C_BINDING_PREFIX (c_f_pointer_r8) (void *, gfc_array_void *,
71 const array_t *);
72 #endif
74 #ifdef HAVE_GFC_REAL_10
75 void ISO_C_BINDING_PREFIX (c_f_pointer_r10) (void *, gfc_array_void *,
76 const array_t *);
77 #endif
78 #ifdef HAVE_GFC_REAL_16
79 void ISO_C_BINDING_PREFIX (c_f_pointer_r16) (void *, gfc_array_void *,
80 const array_t *);
81 #endif
84 #ifdef HAVE_GFC_INTEGER_1
85 /* Set the given Fortran pointer, 'f_ptr_out', to point to the given C
86 address, 'c_ptr_in'. The Fortran pointer is of type integer and
87 kind=1. The function c_f_pointer is used to set up the pointer
88 descriptor. shape is a one-dimensional array of integers
89 specifying the upper bounds of the array pointed to by the given C
90 address, if applicable. 'shape' is an optional parameter in
91 Fortran, so if the user does not provide it, it will come in here
92 as NULL. */
94 void
95 ISO_C_BINDING_PREFIX (c_f_pointer_i1) (void *c_ptr_in,
96 gfc_array_void *f_ptr_out,
97 const array_t *shape)
99 /* Here we have an integer(kind=1). */
100 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
101 (int) GFC_DTYPE_INTEGER,
102 (int) sizeof (GFC_INTEGER_1));
104 #endif
107 #ifdef HAVE_GFC_INTEGER_2
108 /* Set the given Fortran pointer, 'f_ptr_out', to point to the given C
109 address, 'c_ptr_in'. The Fortran pointer is of type integer and
110 kind=2. The function c_f_pointer is used to set up the pointer
111 descriptor. shape is a one-dimensional array of integers
112 specifying the upper bounds of the array pointed to by the given C
113 address, if applicable. 'shape' is an optional parameter in
114 Fortran, so if the user does not provide it, it will come in here
115 as NULL. */
117 void
118 ISO_C_BINDING_PREFIX (c_f_pointer_i2) (void *c_ptr_in,
119 gfc_array_void *f_ptr_out,
120 const array_t *shape)
122 /* Here we have an integer(kind=2). */
123 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
124 (int) GFC_DTYPE_INTEGER,
125 (int) sizeof (GFC_INTEGER_2));
127 #endif
130 #ifdef HAVE_GFC_INTEGER_4
131 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
132 address, c_ptr_in. The Fortran pointer is of type integer and
133 kind=4. The function c_f_pointer is used to set up the pointer
134 descriptor. */
136 void
137 ISO_C_BINDING_PREFIX (c_f_pointer_i4) (void *c_ptr_in,
138 gfc_array_void *f_ptr_out,
139 const array_t *shape)
141 /* Here we have an integer(kind=4). */
142 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
143 (int) GFC_DTYPE_INTEGER,
144 (int) sizeof (GFC_INTEGER_4));
146 #endif
149 #ifdef HAVE_GFC_INTEGER_8
150 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
151 address, c_ptr_in. The Fortran pointer is of type integer and
152 kind=8. The function c_f_pointer is used to set up the pointer
153 descriptor. */
155 void
156 ISO_C_BINDING_PREFIX (c_f_pointer_i8) (void *c_ptr_in,
157 gfc_array_void *f_ptr_out,
158 const array_t *shape)
160 /* Here we have an integer(kind=8). */
161 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
162 (int) GFC_DTYPE_INTEGER,
163 (int) sizeof (GFC_INTEGER_8));
165 #endif
168 #ifdef HAVE_GFC_INTEGER_16
169 /* Set the given Fortran pointer, 'f_ptr_out', to point to the given C
170 address, 'c_ptr_in'. The Fortran pointer is of type integer and
171 kind=16. The function c_f_pointer is used to set up the pointer
172 descriptor. shape is a one-dimensional array of integers
173 specifying the upper bounds of the array pointed to by the given C
174 address, if applicable. 'shape' is an optional parameter in
175 Fortran, so if the user does not provide it, it will come in here
176 as NULL. */
178 void
179 ISO_C_BINDING_PREFIX (c_f_pointer_i16) (void *c_ptr_in,
180 gfc_array_void *f_ptr_out,
181 const array_t *shape)
183 /* Here we have an integer(kind=16). */
184 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
185 (int) GFC_DTYPE_INTEGER,
186 (int) sizeof (GFC_INTEGER_16));
188 #endif
191 #ifdef HAVE_GFC_REAL_4
192 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
193 address, c_ptr_in. The Fortran pointer is of type real and
194 kind=4. The function c_f_pointer is used to set up the pointer
195 descriptor. */
197 void
198 ISO_C_BINDING_PREFIX (c_f_pointer_r4) (void *c_ptr_in,
199 gfc_array_void *f_ptr_out,
200 const array_t *shape)
202 /* Here we have an real(kind=4). */
203 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
204 (int) GFC_DTYPE_REAL,
205 (int) sizeof (GFC_REAL_4));
207 #endif
210 #ifdef HAVE_GFC_REAL_8
211 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
212 address, c_ptr_in. The Fortran pointer is of type real and
213 kind=8. The function c_f_pointer is used to set up the pointer
214 descriptor. */
216 void
217 ISO_C_BINDING_PREFIX (c_f_pointer_r8) (void *c_ptr_in,
218 gfc_array_void *f_ptr_out,
219 const array_t *shape)
221 /* Here we have an real(kind=8). */
222 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
223 (int) GFC_DTYPE_REAL,
224 (int) sizeof (GFC_REAL_8));
226 #endif
229 #ifdef HAVE_GFC_REAL_10
230 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
231 address, c_ptr_in. The Fortran pointer is of type real and
232 kind=10. The function c_f_pointer is used to set up the pointer
233 descriptor. */
235 void
236 ISO_C_BINDING_PREFIX (c_f_pointer_r10) (void *c_ptr_in,
237 gfc_array_void *f_ptr_out,
238 const array_t *shape)
240 /* Here we have an real(kind=10). */
241 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
242 (int) GFC_DTYPE_REAL,
243 (int) sizeof (GFC_REAL_10));
245 #endif
248 #ifdef HAVE_GFC_REAL_16
249 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
250 address, c_ptr_in. The Fortran pointer is of type real and
251 kind=16. The function c_f_pointer is used to set up the pointer
252 descriptor. */
254 void
255 ISO_C_BINDING_PREFIX (c_f_pointer_r16) (void *c_ptr_in,
256 gfc_array_void *f_ptr_out,
257 const array_t *shape)
259 /* Here we have an real(kind=16). */
260 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
261 (int) GFC_DTYPE_REAL,
262 (int) sizeof (GFC_REAL_16));
264 #endif