re PR fortran/66979 (gfortran internal compiler error with malformed FLUSH statement)
[official-gcc.git] / libgomp / fortran.c
blob993145f8890132421a3ae509a5d8c249089e6223
1 /* Copyright (C) 2005-2015 Free Software Foundation, Inc.
2 Contributed by Jakub Jelinek <jakub@redhat.com>.
4 This file is part of the GNU Offloading and Multi Processing Library
5 (libgomp).
7 Libgomp is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 more details.
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
26 /* This file contains Fortran wrapper routines. */
28 #include "libgomp.h"
29 #include "libgomp_f.h"
30 #include <stdlib.h>
31 #include <limits.h>
33 #ifdef HAVE_ATTRIBUTE_ALIAS
34 /* Use internal aliases if possible. */
35 # ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
36 ialias_redirect (omp_init_lock)
37 ialias_redirect (omp_init_nest_lock)
38 ialias_redirect (omp_destroy_lock)
39 ialias_redirect (omp_destroy_nest_lock)
40 ialias_redirect (omp_set_lock)
41 ialias_redirect (omp_set_nest_lock)
42 ialias_redirect (omp_unset_lock)
43 ialias_redirect (omp_unset_nest_lock)
44 ialias_redirect (omp_test_lock)
45 ialias_redirect (omp_test_nest_lock)
46 # endif
47 ialias_redirect (omp_set_dynamic)
48 ialias_redirect (omp_set_nested)
49 ialias_redirect (omp_set_num_threads)
50 ialias_redirect (omp_get_dynamic)
51 ialias_redirect (omp_get_nested)
52 ialias_redirect (omp_in_parallel)
53 ialias_redirect (omp_get_max_threads)
54 ialias_redirect (omp_get_num_procs)
55 ialias_redirect (omp_get_num_threads)
56 ialias_redirect (omp_get_thread_num)
57 ialias_redirect (omp_get_wtick)
58 ialias_redirect (omp_get_wtime)
59 ialias_redirect (omp_set_schedule)
60 ialias_redirect (omp_get_schedule)
61 ialias_redirect (omp_get_thread_limit)
62 ialias_redirect (omp_set_max_active_levels)
63 ialias_redirect (omp_get_max_active_levels)
64 ialias_redirect (omp_get_level)
65 ialias_redirect (omp_get_ancestor_thread_num)
66 ialias_redirect (omp_get_team_size)
67 ialias_redirect (omp_get_active_level)
68 ialias_redirect (omp_in_final)
69 ialias_redirect (omp_get_cancellation)
70 ialias_redirect (omp_get_proc_bind)
71 ialias_redirect (omp_set_default_device)
72 ialias_redirect (omp_get_default_device)
73 ialias_redirect (omp_get_num_devices)
74 ialias_redirect (omp_get_num_teams)
75 ialias_redirect (omp_get_team_num)
76 ialias_redirect (omp_is_initial_device)
77 #endif
79 #ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
80 # define gomp_init_lock__30 omp_init_lock_
81 # define gomp_destroy_lock__30 omp_destroy_lock_
82 # define gomp_set_lock__30 omp_set_lock_
83 # define gomp_unset_lock__30 omp_unset_lock_
84 # define gomp_test_lock__30 omp_test_lock_
85 # define gomp_init_nest_lock__30 omp_init_nest_lock_
86 # define gomp_destroy_nest_lock__30 omp_destroy_nest_lock_
87 # define gomp_set_nest_lock__30 omp_set_nest_lock_
88 # define gomp_unset_nest_lock__30 omp_unset_nest_lock_
89 # define gomp_test_nest_lock__30 omp_test_nest_lock_
90 #endif
92 void
93 gomp_init_lock__30 (omp_lock_arg_t lock)
95 #ifndef OMP_LOCK_DIRECT
96 omp_lock_arg (lock) = malloc (sizeof (omp_lock_t));
97 #endif
98 gomp_init_lock_30 (omp_lock_arg (lock));
101 void
102 gomp_init_nest_lock__30 (omp_nest_lock_arg_t lock)
104 #ifndef OMP_NEST_LOCK_DIRECT
105 omp_nest_lock_arg (lock) = malloc (sizeof (omp_nest_lock_t));
106 #endif
107 gomp_init_nest_lock_30 (omp_nest_lock_arg (lock));
110 void
111 gomp_destroy_lock__30 (omp_lock_arg_t lock)
113 gomp_destroy_lock_30 (omp_lock_arg (lock));
114 #ifndef OMP_LOCK_DIRECT
115 free (omp_lock_arg (lock));
116 omp_lock_arg (lock) = NULL;
117 #endif
120 void
121 gomp_destroy_nest_lock__30 (omp_nest_lock_arg_t lock)
123 gomp_destroy_nest_lock_30 (omp_nest_lock_arg (lock));
124 #ifndef OMP_NEST_LOCK_DIRECT
125 free (omp_nest_lock_arg (lock));
126 omp_nest_lock_arg (lock) = NULL;
127 #endif
130 void
131 gomp_set_lock__30 (omp_lock_arg_t lock)
133 gomp_set_lock_30 (omp_lock_arg (lock));
136 void
137 gomp_set_nest_lock__30 (omp_nest_lock_arg_t lock)
139 gomp_set_nest_lock_30 (omp_nest_lock_arg (lock));
142 void
143 gomp_unset_lock__30 (omp_lock_arg_t lock)
145 gomp_unset_lock_30 (omp_lock_arg (lock));
148 void
149 gomp_unset_nest_lock__30 (omp_nest_lock_arg_t lock)
151 gomp_unset_nest_lock_30 (omp_nest_lock_arg (lock));
154 int32_t
155 gomp_test_lock__30 (omp_lock_arg_t lock)
157 return gomp_test_lock_30 (omp_lock_arg (lock));
160 int32_t
161 gomp_test_nest_lock__30 (omp_nest_lock_arg_t lock)
163 return gomp_test_nest_lock_30 (omp_nest_lock_arg (lock));
166 #ifdef LIBGOMP_GNU_SYMBOL_VERSIONING
167 void
168 gomp_init_lock__25 (omp_lock_25_arg_t lock)
170 #ifndef OMP_LOCK_25_DIRECT
171 omp_lock_25_arg (lock) = malloc (sizeof (omp_lock_25_t));
172 #endif
173 gomp_init_lock_25 (omp_lock_25_arg (lock));
176 void
177 gomp_init_nest_lock__25 (omp_nest_lock_25_arg_t lock)
179 #ifndef OMP_NEST_LOCK_25_DIRECT
180 omp_nest_lock_25_arg (lock) = malloc (sizeof (omp_nest_lock_25_t));
181 #endif
182 gomp_init_nest_lock_25 (omp_nest_lock_25_arg (lock));
185 void
186 gomp_destroy_lock__25 (omp_lock_25_arg_t lock)
188 gomp_destroy_lock_25 (omp_lock_25_arg (lock));
189 #ifndef OMP_LOCK_25_DIRECT
190 free (omp_lock_25_arg (lock));
191 omp_lock_25_arg (lock) = NULL;
192 #endif
195 void
196 gomp_destroy_nest_lock__25 (omp_nest_lock_25_arg_t lock)
198 gomp_destroy_nest_lock_25 (omp_nest_lock_25_arg (lock));
199 #ifndef OMP_NEST_LOCK_25_DIRECT
200 free (omp_nest_lock_25_arg (lock));
201 omp_nest_lock_25_arg (lock) = NULL;
202 #endif
205 void
206 gomp_set_lock__25 (omp_lock_25_arg_t lock)
208 gomp_set_lock_25 (omp_lock_25_arg (lock));
211 void
212 gomp_set_nest_lock__25 (omp_nest_lock_25_arg_t lock)
214 gomp_set_nest_lock_25 (omp_nest_lock_25_arg (lock));
217 void
218 gomp_unset_lock__25 (omp_lock_25_arg_t lock)
220 gomp_unset_lock_25 (omp_lock_25_arg (lock));
223 void
224 gomp_unset_nest_lock__25 (omp_nest_lock_25_arg_t lock)
226 gomp_unset_nest_lock_25 (omp_nest_lock_25_arg (lock));
229 int32_t
230 gomp_test_lock__25 (omp_lock_25_arg_t lock)
232 return gomp_test_lock_25 (omp_lock_25_arg (lock));
235 int32_t
236 gomp_test_nest_lock__25 (omp_nest_lock_25_arg_t lock)
238 return gomp_test_nest_lock_25 (omp_nest_lock_25_arg (lock));
241 omp_lock_symver (omp_init_lock_)
242 omp_lock_symver (omp_destroy_lock_)
243 omp_lock_symver (omp_set_lock_)
244 omp_lock_symver (omp_unset_lock_)
245 omp_lock_symver (omp_test_lock_)
246 omp_lock_symver (omp_init_nest_lock_)
247 omp_lock_symver (omp_destroy_nest_lock_)
248 omp_lock_symver (omp_set_nest_lock_)
249 omp_lock_symver (omp_unset_nest_lock_)
250 omp_lock_symver (omp_test_nest_lock_)
251 #endif
253 #define TO_INT(x) ((x) > INT_MIN ? (x) < INT_MAX ? (x) : INT_MAX : INT_MIN)
255 void
256 omp_set_dynamic_ (const int32_t *set)
258 omp_set_dynamic (*set);
261 void
262 omp_set_dynamic_8_ (const int64_t *set)
264 omp_set_dynamic (!!*set);
267 void
268 omp_set_nested_ (const int32_t *set)
270 omp_set_nested (*set);
273 void
274 omp_set_nested_8_ (const int64_t *set)
276 omp_set_nested (!!*set);
279 void
280 omp_set_num_threads_ (const int32_t *set)
282 omp_set_num_threads (*set);
285 void
286 omp_set_num_threads_8_ (const int64_t *set)
288 omp_set_num_threads (TO_INT (*set));
291 int32_t
292 omp_get_dynamic_ (void)
294 return omp_get_dynamic ();
297 int32_t
298 omp_get_nested_ (void)
300 return omp_get_nested ();
303 int32_t
304 omp_in_parallel_ (void)
306 return omp_in_parallel ();
309 int32_t
310 omp_get_max_threads_ (void)
312 return omp_get_max_threads ();
315 int32_t
316 omp_get_num_procs_ (void)
318 return omp_get_num_procs ();
321 int32_t
322 omp_get_num_threads_ (void)
324 return omp_get_num_threads ();
327 int32_t
328 omp_get_thread_num_ (void)
330 return omp_get_thread_num ();
333 double
334 omp_get_wtick_ (void)
336 return omp_get_wtick ();
339 double
340 omp_get_wtime_ (void)
342 return omp_get_wtime ();
345 void
346 omp_set_schedule_ (const int32_t *kind, const int32_t *modifier)
348 omp_set_schedule (*kind, *modifier);
351 void
352 omp_set_schedule_8_ (const int32_t *kind, const int64_t *modifier)
354 omp_set_schedule (*kind, TO_INT (*modifier));
357 void
358 omp_get_schedule_ (int32_t *kind, int32_t *modifier)
360 omp_sched_t k;
361 int m;
362 omp_get_schedule (&k, &m);
363 *kind = k;
364 *modifier = m;
367 void
368 omp_get_schedule_8_ (int32_t *kind, int64_t *modifier)
370 omp_sched_t k;
371 int m;
372 omp_get_schedule (&k, &m);
373 *kind = k;
374 *modifier = m;
377 int32_t
378 omp_get_thread_limit_ (void)
380 return omp_get_thread_limit ();
383 void
384 omp_set_max_active_levels_ (const int32_t *levels)
386 omp_set_max_active_levels (*levels);
389 void
390 omp_set_max_active_levels_8_ (const int64_t *levels)
392 omp_set_max_active_levels (TO_INT (*levels));
395 int32_t
396 omp_get_max_active_levels_ (void)
398 return omp_get_max_active_levels ();
401 int32_t
402 omp_get_level_ (void)
404 return omp_get_level ();
407 int32_t
408 omp_get_ancestor_thread_num_ (const int32_t *level)
410 return omp_get_ancestor_thread_num (*level);
413 int32_t
414 omp_get_ancestor_thread_num_8_ (const int64_t *level)
416 return omp_get_ancestor_thread_num (TO_INT (*level));
419 int32_t
420 omp_get_team_size_ (const int32_t *level)
422 return omp_get_team_size (*level);
425 int32_t
426 omp_get_team_size_8_ (const int64_t *level)
428 return omp_get_team_size (TO_INT (*level));
431 int32_t
432 omp_get_active_level_ (void)
434 return omp_get_active_level ();
437 int32_t
438 omp_in_final_ (void)
440 return omp_in_final ();
443 int32_t
444 omp_get_cancellation_ (void)
446 return omp_get_cancellation ();
449 int32_t
450 omp_get_proc_bind_ (void)
452 return omp_get_proc_bind ();
455 void
456 omp_set_default_device_ (const int32_t *device_num)
458 return omp_set_default_device (*device_num);
461 void
462 omp_set_default_device_8_ (const int64_t *device_num)
464 return omp_set_default_device (TO_INT (*device_num));
467 int32_t
468 omp_get_default_device_ (void)
470 return omp_get_default_device ();
473 int32_t
474 omp_get_num_devices_ (void)
476 return omp_get_num_devices ();
479 int32_t
480 omp_get_num_teams_ (void)
482 return omp_get_num_teams ();
485 int32_t
486 omp_get_team_num_ (void)
488 return omp_get_team_num ();
491 int32_t
492 omp_is_initial_device_ (void)
494 return omp_is_initial_device ();