Merged with mainline at revision 128810.
[official-gcc.git] / libgfortran / intrinsics / iso_c_generated_procs.c
blobaee0e57fef13bb8e4f359d806ad3fad827ab7a88
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
79 #ifdef HAVE_GFC_REAL_16
80 void ISO_C_BINDING_PREFIX (c_f_pointer_r16) (void *, gfc_array_void *,
81 const array_t *);
82 #endif
84 #ifdef HAVE_GFC_COMPLEX_4
85 void ISO_C_BINDING_PREFIX (c_f_pointer_c4) (void *, gfc_array_void *,
86 const array_t *);
87 #endif
89 #ifdef HAVE_GFC_COMPLEX_8
90 void ISO_C_BINDING_PREFIX (c_f_pointer_c8) (void *, gfc_array_void *,
91 const array_t *);
92 #endif
94 #ifdef HAVE_GFC_COMPLEX_10
95 void ISO_C_BINDING_PREFIX (c_f_pointer_c10) (void *, gfc_array_void *,
96 const array_t *);
97 #endif
99 #ifdef HAVE_GFC_COMPLEX_16
100 void ISO_C_BINDING_PREFIX (c_f_pointer_c16) (void *, gfc_array_void *,
101 const array_t *);
102 #endif
104 #ifdef GFC_DEFAULT_CHAR
105 void ISO_C_BINDING_PREFIX (c_f_pointer_s0) (void *, gfc_array_void *,
106 const array_t *);
107 #endif
109 #ifdef HAVE_GFC_LOGICAL_1
110 void ISO_C_BINDING_PREFIX (c_f_pointer_l1) (void *, gfc_array_void *,
111 const array_t *);
112 #endif
114 #ifdef HAVE_GFC_LOGICAL_2
115 void ISO_C_BINDING_PREFIX (c_f_pointer_l2) (void *, gfc_array_void *,
116 const array_t *);
117 #endif
119 #ifdef HAVE_GFC_LOGICAL_4
120 void ISO_C_BINDING_PREFIX (c_f_pointer_l4) (void *, gfc_array_void *,
121 const array_t *);
122 #endif
124 #ifdef HAVE_GFC_LOGICAL_8
125 void ISO_C_BINDING_PREFIX (c_f_pointer_l8) (void *, gfc_array_void *,
126 const array_t *);
127 #endif
130 #ifdef HAVE_GFC_INTEGER_1
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=1. The function c_f_pointer is used to set up the pointer
134 descriptor. shape is a one-dimensional array of integers
135 specifying the upper bounds of the array pointed to by the given C
136 address, if applicable. 'shape' is an optional parameter in
137 Fortran, so if the user does not provide it, it will come in here
138 as NULL. */
140 void
141 ISO_C_BINDING_PREFIX (c_f_pointer_i1) (void *c_ptr_in,
142 gfc_array_void *f_ptr_out,
143 const array_t *shape)
145 /* Here we have an integer(kind=1). */
146 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
147 (int) GFC_DTYPE_INTEGER,
148 (int) sizeof (GFC_INTEGER_1));
150 #endif
153 #ifdef HAVE_GFC_INTEGER_2
154 /* Set the given Fortran pointer, 'f_ptr_out', to point to the given C
155 address, 'c_ptr_in'. The Fortran pointer is of type integer and
156 kind=2. The function c_f_pointer is used to set up the pointer
157 descriptor. shape is a one-dimensional array of integers
158 specifying the upper bounds of the array pointed to by the given C
159 address, if applicable. 'shape' is an optional parameter in
160 Fortran, so if the user does not provide it, it will come in here
161 as NULL. */
163 void
164 ISO_C_BINDING_PREFIX (c_f_pointer_i2) (void *c_ptr_in,
165 gfc_array_void *f_ptr_out,
166 const array_t *shape)
168 /* Here we have an integer(kind=2). */
169 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
170 (int) GFC_DTYPE_INTEGER,
171 (int) sizeof (GFC_INTEGER_2));
173 #endif
176 #ifdef HAVE_GFC_INTEGER_4
177 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
178 address, c_ptr_in. The Fortran pointer is of type integer and
179 kind=4. The function c_f_pointer is used to set up the pointer
180 descriptor. */
182 void
183 ISO_C_BINDING_PREFIX (c_f_pointer_i4) (void *c_ptr_in,
184 gfc_array_void *f_ptr_out,
185 const array_t *shape)
187 /* Here we have an integer(kind=4). */
188 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
189 (int) GFC_DTYPE_INTEGER,
190 (int) sizeof (GFC_INTEGER_4));
192 #endif
195 #ifdef HAVE_GFC_INTEGER_8
196 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
197 address, c_ptr_in. The Fortran pointer is of type integer and
198 kind=8. The function c_f_pointer is used to set up the pointer
199 descriptor. */
201 void
202 ISO_C_BINDING_PREFIX (c_f_pointer_i8) (void *c_ptr_in,
203 gfc_array_void *f_ptr_out,
204 const array_t *shape)
206 /* Here we have an integer(kind=8). */
207 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
208 (int) GFC_DTYPE_INTEGER,
209 (int) sizeof (GFC_INTEGER_8));
211 #endif
214 #ifdef HAVE_GFC_INTEGER_16
215 /* Set the given Fortran pointer, 'f_ptr_out', to point to the given C
216 address, 'c_ptr_in'. The Fortran pointer is of type integer and
217 kind=16. The function c_f_pointer is used to set up the pointer
218 descriptor. shape is a one-dimensional array of integers
219 specifying the upper bounds of the array pointed to by the given C
220 address, if applicable. 'shape' is an optional parameter in
221 Fortran, so if the user does not provide it, it will come in here
222 as NULL. */
224 void
225 ISO_C_BINDING_PREFIX (c_f_pointer_i16) (void *c_ptr_in,
226 gfc_array_void *f_ptr_out,
227 const array_t *shape)
229 /* Here we have an integer(kind=16). */
230 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
231 (int) GFC_DTYPE_INTEGER,
232 (int) sizeof (GFC_INTEGER_16));
234 #endif
237 #ifdef HAVE_GFC_REAL_4
238 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
239 address, c_ptr_in. The Fortran pointer is of type real and
240 kind=4. The function c_f_pointer is used to set up the pointer
241 descriptor. */
243 void
244 ISO_C_BINDING_PREFIX (c_f_pointer_r4) (void *c_ptr_in,
245 gfc_array_void *f_ptr_out,
246 const array_t *shape)
248 /* Here we have an real(kind=4). */
249 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
250 (int) GFC_DTYPE_REAL,
251 (int) sizeof (GFC_REAL_4));
253 #endif
256 #ifdef HAVE_GFC_REAL_8
257 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
258 address, c_ptr_in. The Fortran pointer is of type real and
259 kind=8. The function c_f_pointer is used to set up the pointer
260 descriptor. */
262 void
263 ISO_C_BINDING_PREFIX (c_f_pointer_r8) (void *c_ptr_in,
264 gfc_array_void *f_ptr_out,
265 const array_t *shape)
267 /* Here we have an real(kind=8). */
268 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
269 (int) GFC_DTYPE_REAL,
270 (int) sizeof (GFC_REAL_8));
272 #endif
275 #ifdef HAVE_GFC_REAL_10
276 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
277 address, c_ptr_in. The Fortran pointer is of type real and
278 kind=10. The function c_f_pointer is used to set up the pointer
279 descriptor. */
281 void
282 ISO_C_BINDING_PREFIX (c_f_pointer_r10) (void *c_ptr_in,
283 gfc_array_void *f_ptr_out,
284 const array_t *shape)
286 /* Here we have an real(kind=10). */
287 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
288 (int) GFC_DTYPE_REAL,
289 (int) sizeof (GFC_REAL_10));
291 #endif
294 #ifdef HAVE_GFC_REAL_16
295 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
296 address, c_ptr_in. The Fortran pointer is of type real and
297 kind=16. The function c_f_pointer is used to set up the pointer
298 descriptor. */
300 void
301 ISO_C_BINDING_PREFIX (c_f_pointer_r16) (void *c_ptr_in,
302 gfc_array_void *f_ptr_out,
303 const array_t *shape)
305 /* Here we have an real(kind=16). */
306 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
307 (int) GFC_DTYPE_REAL,
308 (int) sizeof (GFC_REAL_16));
310 #endif
313 #ifdef HAVE_GFC_COMPLEX_4
314 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
315 address, c_ptr_in. The Fortran pointer is of type complex and
316 kind=4. The function c_f_pointer is used to set up the pointer
317 descriptor. */
319 void
320 ISO_C_BINDING_PREFIX (c_f_pointer_c4) (void *c_ptr_in,
321 gfc_array_void *f_ptr_out,
322 const array_t *shape)
324 /* Here we have an complex(kind=4). */
325 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
326 (int) GFC_DTYPE_COMPLEX,
327 (int) sizeof (GFC_COMPLEX_4));
329 #endif
332 #ifdef HAVE_GFC_COMPLEX_8
333 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
334 address, c_ptr_in. The Fortran pointer is of type complex and
335 kind=8. The function c_f_pointer is used to set up the pointer
336 descriptor. */
338 void
339 ISO_C_BINDING_PREFIX (c_f_pointer_c8) (void *c_ptr_in,
340 gfc_array_void *f_ptr_out,
341 const array_t *shape)
343 /* Here we have an complex(kind=8). */
344 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
345 (int) GFC_DTYPE_COMPLEX,
346 (int) sizeof (GFC_COMPLEX_8));
348 #endif
351 #ifdef HAVE_GFC_COMPLEX_10
352 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
353 address, c_ptr_in. The Fortran pointer is of type complex and
354 kind=10. The function c_f_pointer is used to set up the pointer
355 descriptor. */
357 void
358 ISO_C_BINDING_PREFIX (c_f_pointer_c10) (void *c_ptr_in,
359 gfc_array_void *f_ptr_out,
360 const array_t *shape)
362 /* Here we have an complex(kind=10). */
363 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
364 (int) GFC_DTYPE_COMPLEX,
365 (int) sizeof (GFC_COMPLEX_10));
367 #endif
370 #ifdef HAVE_GFC_COMPLEX_16
371 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
372 address, c_ptr_in. The Fortran pointer is of type complex and
373 kind=16. The function c_f_pointer is used to set up the pointer
374 descriptor. */
376 void
377 ISO_C_BINDING_PREFIX (c_f_pointer_c16) (void *c_ptr_in,
378 gfc_array_void *f_ptr_out,
379 const array_t *shape)
381 /* Here we have an complex(kind=16). */
382 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
383 (int) GFC_DTYPE_COMPLEX,
384 (int) sizeof (GFC_COMPLEX_16));
386 #endif
389 #ifdef GFC_DEFAULT_CHAR
390 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
391 address, c_ptr_in. The Fortran pointer is of type character. */
393 void
394 ISO_C_BINDING_PREFIX (c_f_pointer_s0) (void *c_ptr_in,
395 gfc_array_void *f_ptr_out,
396 const array_t *shape)
398 /* Here we have a character string of len=1. */
399 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
400 (int) GFC_DTYPE_CHARACTER,
401 (int) sizeof (char));
403 #endif
406 #ifdef HAVE_GFC_LOGICAL_1
407 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
408 address, c_ptr_in. The Fortran pointer is of type logical, kind=1. */
410 void
411 ISO_C_BINDING_PREFIX (c_f_pointer_l1) (void *c_ptr_in,
412 gfc_array_void *f_ptr_out,
413 const array_t *shape)
415 /* Here we have a logical of kind=1. */
416 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
417 (int) GFC_DTYPE_LOGICAL,
418 (int) sizeof (GFC_LOGICAL_1));
420 #endif
423 #ifdef HAVE_GFC_LOGICAL_2
424 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
425 address, c_ptr_in. The Fortran pointer is of type logical, kind=2. */
427 void
428 ISO_C_BINDING_PREFIX (c_f_pointer_l2) (void *c_ptr_in,
429 gfc_array_void *f_ptr_out,
430 const array_t *shape)
432 /* Here we have a logical of kind=2. */
433 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
434 (int) GFC_DTYPE_LOGICAL,
435 (int) sizeof (GFC_LOGICAL_2));
437 #endif
440 #ifdef HAVE_GFC_LOGICAL_4
441 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
442 address, c_ptr_in. The Fortran pointer is of type logical, kind=4. */
444 void
445 ISO_C_BINDING_PREFIX (c_f_pointer_l4) (void *c_ptr_in,
446 gfc_array_void *f_ptr_out,
447 const array_t *shape)
449 /* Here we have a logical of kind=4. */
450 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
451 (int) GFC_DTYPE_LOGICAL,
452 (int) sizeof (GFC_LOGICAL_4));
454 #endif
457 #ifdef HAVE_GFC_LOGICAL_8
458 /* Set the given Fortran pointer, f_ptr_out, to point to the given C
459 address, c_ptr_in. The Fortran pointer is of type logical, kind=8. */
461 void
462 ISO_C_BINDING_PREFIX (c_f_pointer_l8) (void *c_ptr_in,
463 gfc_array_void *f_ptr_out,
464 const array_t *shape)
466 /* Here we have a logical of kind=8. */
467 ISO_C_BINDING_PREFIX (c_f_pointer) (c_ptr_in, f_ptr_out, shape,
468 (int) GFC_DTYPE_LOGICAL,
469 (int) sizeof (GFC_LOGICAL_8));
471 #endif