OSDN Git Service

2007-07-01 Christopher D. Rickett <crickett@lanl.gov>
[pf3gnuchains/gcc-fork.git] / libgfortran / intrinsics / iso_c_generated_procs.c
1 /* Implementation of the ISO_C_BINDING library helper generated functions.
2    Copyright (C) 2007 Free Software Foundation, Inc.
3    Contributed by Christopher Rickett.
4
5 This file is part of the GNU Fortran 95 runtime library (libgfortran).
6
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.
11
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.)
20
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.
25
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.  */
30
31
32 #include "libgfortran.h"
33 #include "iso_c_binding.h"
34
35
36 /* TODO: This file needs to be finished so that a function is provided
37    for all possible type/kind combinations!  */
38
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
43
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
48
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
53
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
58
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
63
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
68
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
73
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
82
83
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.  */
93
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)
98 {
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));
103 }
104 #endif
105
106
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.  */
116
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)
121 {
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));
126 }
127 #endif
128
129
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.  */
135
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)
140 {
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));
145 }
146 #endif
147
148
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.  */
154
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)
159 {
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));
164 }
165 #endif
166
167
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.  */
177
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)
182 {
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));
187 }
188 #endif
189
190
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.  */
196
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)
201 {
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));
206 }
207 #endif
208
209
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.  */
215
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)
220 {
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));
225 }
226 #endif
227
228
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.  */
234
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)
239 {
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));
244 }
245 #endif
246
247
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.  */
253
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)
258 {
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));
263 }
264 #endif