OSDN Git Service

PR ada/60703
[pf3gnuchains/gcc-fork.git] / libgomp / fortran.c
1 /* Copyright (C) 2005, 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
2    Contributed by Jakub Jelinek <jakub@redhat.com>.
3
4    This file is part of the GNU OpenMP Library (libgomp).
5
6    Libgomp is free software; you can redistribute it and/or modify it
7    under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3, or (at your option)
9    any later version.
10
11    Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
12    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13    FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14    more details.
15
16    Under Section 7 of GPL version 3, you are granted additional
17    permissions described in the GCC Runtime Library Exception, version
18    3.1, as published by the Free Software Foundation.
19
20    You should have received a copy of the GNU General Public License and
21    a copy of the GCC Runtime Library Exception along with this program;
22    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23    <http://www.gnu.org/licenses/>.  */
24
25 /* This file contains Fortran wrapper routines.  */
26
27 #include "libgomp.h"
28 #include "libgomp_f.h"
29 #include <stdlib.h>
30 #include <limits.h>
31
32 #ifdef HAVE_ATTRIBUTE_ALIAS
33 /* Use internal aliases if possible.  */
34 # define ULP            STR1(__USER_LABEL_PREFIX__)
35 # define STR1(x)        STR2(x)
36 # define STR2(x)        #x
37 # define ialias_redirect(fn) \
38   extern __typeof (fn) fn __asm__ (ULP "gomp_ialias_" #fn) attribute_hidden;
39 # ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
40 ialias_redirect (omp_init_lock)
41 ialias_redirect (omp_init_nest_lock)
42 ialias_redirect (omp_destroy_lock)
43 ialias_redirect (omp_destroy_nest_lock)
44 ialias_redirect (omp_set_lock)
45 ialias_redirect (omp_set_nest_lock)
46 ialias_redirect (omp_unset_lock)
47 ialias_redirect (omp_unset_nest_lock)
48 ialias_redirect (omp_test_lock)
49 ialias_redirect (omp_test_nest_lock)
50 # endif
51 ialias_redirect (omp_set_dynamic)
52 ialias_redirect (omp_set_nested)
53 ialias_redirect (omp_set_num_threads)
54 ialias_redirect (omp_get_dynamic)
55 ialias_redirect (omp_get_nested)
56 ialias_redirect (omp_in_parallel)
57 ialias_redirect (omp_get_max_threads)
58 ialias_redirect (omp_get_num_procs)
59 ialias_redirect (omp_get_num_threads)
60 ialias_redirect (omp_get_thread_num)
61 ialias_redirect (omp_get_wtick)
62 ialias_redirect (omp_get_wtime)
63 ialias_redirect (omp_set_schedule)
64 ialias_redirect (omp_get_schedule)
65 ialias_redirect (omp_get_thread_limit)
66 ialias_redirect (omp_set_max_active_levels)
67 ialias_redirect (omp_get_max_active_levels)
68 ialias_redirect (omp_get_level)
69 ialias_redirect (omp_get_ancestor_thread_num)
70 ialias_redirect (omp_get_team_size)
71 ialias_redirect (omp_get_active_level)
72 ialias_redirect (omp_in_final)
73 #endif
74
75 #ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
76 # define gomp_init_lock__30 omp_init_lock_
77 # define gomp_destroy_lock__30 omp_destroy_lock_
78 # define gomp_set_lock__30 omp_set_lock_
79 # define gomp_unset_lock__30 omp_unset_lock_
80 # define gomp_test_lock__30 omp_test_lock_
81 # define gomp_init_nest_lock__30 omp_init_nest_lock_
82 # define gomp_destroy_nest_lock__30 omp_destroy_nest_lock_
83 # define gomp_set_nest_lock__30 omp_set_nest_lock_
84 # define gomp_unset_nest_lock__30 omp_unset_nest_lock_
85 # define gomp_test_nest_lock__30 omp_test_nest_lock_
86 #endif
87
88 void
89 gomp_init_lock__30 (omp_lock_arg_t lock)
90 {
91 #ifndef OMP_LOCK_DIRECT
92   omp_lock_arg (lock) = malloc (sizeof (omp_lock_t));
93 #endif
94   gomp_init_lock_30 (omp_lock_arg (lock));
95 }
96
97 void
98 gomp_init_nest_lock__30 (omp_nest_lock_arg_t lock)
99 {
100 #ifndef OMP_NEST_LOCK_DIRECT
101   omp_nest_lock_arg (lock) = malloc (sizeof (omp_nest_lock_t));
102 #endif
103   gomp_init_nest_lock_30 (omp_nest_lock_arg (lock));
104 }
105
106 void
107 gomp_destroy_lock__30 (omp_lock_arg_t lock)
108 {
109   gomp_destroy_lock_30 (omp_lock_arg (lock));
110 #ifndef OMP_LOCK_DIRECT
111   free (omp_lock_arg (lock));
112   omp_lock_arg (lock) = NULL;
113 #endif
114 }
115
116 void
117 gomp_destroy_nest_lock__30 (omp_nest_lock_arg_t lock)
118 {
119   gomp_destroy_nest_lock_30 (omp_nest_lock_arg (lock));
120 #ifndef OMP_NEST_LOCK_DIRECT
121   free (omp_nest_lock_arg (lock));
122   omp_nest_lock_arg (lock) = NULL;
123 #endif
124 }
125
126 void
127 gomp_set_lock__30 (omp_lock_arg_t lock)
128 {
129   gomp_set_lock_30 (omp_lock_arg (lock));
130 }
131
132 void
133 gomp_set_nest_lock__30 (omp_nest_lock_arg_t lock)
134 {
135   gomp_set_nest_lock_30 (omp_nest_lock_arg (lock));
136 }
137
138 void
139 gomp_unset_lock__30 (omp_lock_arg_t lock)
140 {
141   gomp_unset_lock_30 (omp_lock_arg (lock));
142 }
143
144 void
145 gomp_unset_nest_lock__30 (omp_nest_lock_arg_t lock)
146 {
147   gomp_unset_nest_lock_30 (omp_nest_lock_arg (lock));
148 }
149
150 int32_t
151 gomp_test_lock__30 (omp_lock_arg_t lock)
152 {
153   return gomp_test_lock_30 (omp_lock_arg (lock));
154 }
155
156 int32_t
157 gomp_test_nest_lock__30 (omp_nest_lock_arg_t lock)
158 {
159   return gomp_test_nest_lock_30 (omp_nest_lock_arg (lock));
160 }
161
162 #ifdef LIBGOMP_GNU_SYMBOL_VERSIONING
163 void
164 gomp_init_lock__25 (omp_lock_25_arg_t lock)
165 {
166 #ifndef OMP_LOCK_25_DIRECT
167   omp_lock_25_arg (lock) = malloc (sizeof (omp_lock_25_t));
168 #endif
169   gomp_init_lock_25 (omp_lock_25_arg (lock));
170 }
171
172 void
173 gomp_init_nest_lock__25 (omp_nest_lock_25_arg_t lock)
174 {
175 #ifndef OMP_NEST_LOCK_25_DIRECT
176   omp_nest_lock_25_arg (lock) = malloc (sizeof (omp_nest_lock_25_t));
177 #endif
178   gomp_init_nest_lock_25 (omp_nest_lock_25_arg (lock));
179 }
180
181 void
182 gomp_destroy_lock__25 (omp_lock_25_arg_t lock)
183 {
184   gomp_destroy_lock_25 (omp_lock_25_arg (lock));
185 #ifndef OMP_LOCK_25_DIRECT
186   free (omp_lock_25_arg (lock));
187   omp_lock_25_arg (lock) = NULL;
188 #endif
189 }
190
191 void
192 gomp_destroy_nest_lock__25 (omp_nest_lock_25_arg_t lock)
193 {
194   gomp_destroy_nest_lock_25 (omp_nest_lock_25_arg (lock));
195 #ifndef OMP_NEST_LOCK_25_DIRECT
196   free (omp_nest_lock_25_arg (lock));
197   omp_nest_lock_25_arg (lock) = NULL;
198 #endif
199 }
200
201 void
202 gomp_set_lock__25 (omp_lock_25_arg_t lock)
203 {
204   gomp_set_lock_25 (omp_lock_25_arg (lock));
205 }
206
207 void
208 gomp_set_nest_lock__25 (omp_nest_lock_25_arg_t lock)
209 {
210   gomp_set_nest_lock_25 (omp_nest_lock_25_arg (lock));
211 }
212
213 void
214 gomp_unset_lock__25 (omp_lock_25_arg_t lock)
215 {
216   gomp_unset_lock_25 (omp_lock_25_arg (lock));
217 }
218
219 void
220 gomp_unset_nest_lock__25 (omp_nest_lock_25_arg_t lock)
221 {
222   gomp_unset_nest_lock_25 (omp_nest_lock_25_arg (lock));
223 }
224
225 int32_t
226 gomp_test_lock__25 (omp_lock_25_arg_t lock)
227 {
228   return gomp_test_lock_25 (omp_lock_25_arg (lock));
229 }
230
231 int32_t
232 gomp_test_nest_lock__25 (omp_nest_lock_25_arg_t lock)
233 {
234   return gomp_test_nest_lock_25 (omp_nest_lock_25_arg (lock));
235 }
236
237 omp_lock_symver (omp_init_lock_)
238 omp_lock_symver (omp_destroy_lock_)
239 omp_lock_symver (omp_set_lock_)
240 omp_lock_symver (omp_unset_lock_)
241 omp_lock_symver (omp_test_lock_)
242 omp_lock_symver (omp_init_nest_lock_)
243 omp_lock_symver (omp_destroy_nest_lock_)
244 omp_lock_symver (omp_set_nest_lock_)
245 omp_lock_symver (omp_unset_nest_lock_)
246 omp_lock_symver (omp_test_nest_lock_)
247 #endif
248
249 #define TO_INT(x) ((x) > INT_MIN ? (x) < INT_MAX ? (x) : INT_MAX : INT_MIN)
250
251 void
252 omp_set_dynamic_ (const int32_t *set)
253 {
254   omp_set_dynamic (*set);
255 }
256
257 void
258 omp_set_dynamic_8_ (const int64_t *set)
259 {
260   omp_set_dynamic (!!*set);
261 }
262
263 void
264 omp_set_nested_ (const int32_t *set)
265 {
266   omp_set_nested (*set);
267 }
268
269 void
270 omp_set_nested_8_ (const int64_t *set)
271 {
272   omp_set_nested (!!*set);
273 }
274
275 void
276 omp_set_num_threads_ (const int32_t *set)
277 {
278   omp_set_num_threads (*set);
279 }
280
281 void
282 omp_set_num_threads_8_ (const int64_t *set)
283 {
284   omp_set_num_threads (TO_INT (*set));
285 }
286
287 int32_t
288 omp_get_dynamic_ (void)
289 {
290   return omp_get_dynamic ();
291 }
292
293 int32_t
294 omp_get_nested_ (void)
295 {
296   return omp_get_nested ();
297 }
298
299 int32_t
300 omp_in_parallel_ (void)
301 {
302   return omp_in_parallel ();
303 }
304
305 int32_t
306 omp_get_max_threads_ (void)
307 {
308   return omp_get_max_threads ();
309 }
310
311 int32_t
312 omp_get_num_procs_ (void)
313 {
314   return omp_get_num_procs ();
315 }
316
317 int32_t
318 omp_get_num_threads_ (void)
319 {
320   return omp_get_num_threads ();
321 }
322
323 int32_t
324 omp_get_thread_num_ (void)
325 {
326   return omp_get_thread_num ();
327 }
328
329 double
330 omp_get_wtick_ (void)
331 {
332   return omp_get_wtick ();
333 }
334
335 double
336 omp_get_wtime_ (void)
337 {
338   return omp_get_wtime ();
339 }
340
341 void
342 omp_set_schedule_ (const int32_t *kind, const int32_t *modifier)
343 {
344   omp_set_schedule (*kind, *modifier);
345 }
346
347 void
348 omp_set_schedule_8_ (const int32_t *kind, const int64_t *modifier)
349 {
350   omp_set_schedule (*kind, TO_INT (*modifier));
351 }
352
353 void
354 omp_get_schedule_ (int32_t *kind, int32_t *modifier)
355 {
356   omp_sched_t k;
357   int m;
358   omp_get_schedule (&k, &m);
359   *kind = k;
360   *modifier = m;
361 }
362
363 void
364 omp_get_schedule_8_ (int32_t *kind, int64_t *modifier)
365 {
366   omp_sched_t k;
367   int m;
368   omp_get_schedule (&k, &m);
369   *kind = k;
370   *modifier = m;
371 }
372
373 int32_t
374 omp_get_thread_limit_ (void)
375 {
376   return omp_get_thread_limit ();
377 }
378
379 void
380 omp_set_max_active_levels_ (const int32_t *levels)
381 {
382   omp_set_max_active_levels (*levels);
383 }
384
385 void
386 omp_set_max_active_levels_8_ (const int64_t *levels)
387 {
388   omp_set_max_active_levels (TO_INT (*levels));
389 }
390
391 int32_t
392 omp_get_max_active_levels_ (void)
393 {
394   return omp_get_max_active_levels ();
395 }
396
397 int32_t
398 omp_get_level_ (void)
399 {
400   return omp_get_level ();
401 }
402
403 int32_t
404 omp_get_ancestor_thread_num_ (const int32_t *level)
405 {
406   return omp_get_ancestor_thread_num (*level);
407 }
408
409 int32_t
410 omp_get_ancestor_thread_num_8_ (const int64_t *level)
411 {
412   return omp_get_ancestor_thread_num (TO_INT (*level));
413 }
414
415 int32_t
416 omp_get_team_size_ (const int32_t *level)
417 {
418   return omp_get_team_size (*level);
419 }
420
421 int32_t
422 omp_get_team_size_8_ (const int64_t *level)
423 {
424   return omp_get_team_size (TO_INT (*level));
425 }
426
427 int32_t
428 omp_get_active_level_ (void)
429 {
430   return omp_get_active_level ();
431 }
432
433 int32_t
434 omp_in_final_ (void)
435 {
436   return omp_in_final ();
437 }