]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgomp/fortran.c
Fix tests for gomp
[thirdparty/gcc.git] / libgomp / fortran.c
CommitLineData
83ffe9cd 1/* Copyright (C) 2005-2023 Free Software Foundation, Inc.
953ff289
DN
2 Contributed by Jakub Jelinek <jakub@redhat.com>.
3
f1f3453e
TS
4 This file is part of the GNU Offloading and Multi Processing Library
5 (libgomp).
953ff289
DN
6
7 Libgomp is free software; you can redistribute it and/or modify it
748086b7
JJ
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.
953ff289
DN
11
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
748086b7 14 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
953ff289
DN
15 more details.
16
748086b7
JJ
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.
20
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/>. */
953ff289
DN
25
26/* This file contains Fortran wrapper routines. */
27
28#include "libgomp.h"
29#include "libgomp_f.h"
30#include <stdlib.h>
28567c40
JJ
31#include <stdio.h>
32#include <string.h>
e7385332 33#include <limits.h>
953ff289
DN
34
35#ifdef HAVE_ATTRIBUTE_ALIAS
36/* Use internal aliases if possible. */
a68ab351 37# ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
953ff289
DN
38ialias_redirect (omp_init_lock)
39ialias_redirect (omp_init_nest_lock)
40ialias_redirect (omp_destroy_lock)
41ialias_redirect (omp_destroy_nest_lock)
42ialias_redirect (omp_set_lock)
43ialias_redirect (omp_set_nest_lock)
44ialias_redirect (omp_unset_lock)
45ialias_redirect (omp_unset_nest_lock)
46ialias_redirect (omp_test_lock)
47ialias_redirect (omp_test_nest_lock)
a68ab351 48# endif
953ff289 49ialias_redirect (omp_set_dynamic)
953ff289 50ialias_redirect (omp_get_dynamic)
10508db8
KCY
51#pragma GCC diagnostic push
52#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
53ialias_redirect (omp_set_nested)
953ff289 54ialias_redirect (omp_get_nested)
10508db8
KCY
55#pragma GCC diagnostic pop
56ialias_redirect (omp_set_num_threads)
953ff289
DN
57ialias_redirect (omp_in_parallel)
58ialias_redirect (omp_get_max_threads)
59ialias_redirect (omp_get_num_procs)
60ialias_redirect (omp_get_num_threads)
61ialias_redirect (omp_get_thread_num)
62ialias_redirect (omp_get_wtick)
63ialias_redirect (omp_get_wtime)
a68ab351
JJ
64ialias_redirect (omp_set_schedule)
65ialias_redirect (omp_get_schedule)
66ialias_redirect (omp_get_thread_limit)
67ialias_redirect (omp_set_max_active_levels)
68ialias_redirect (omp_get_max_active_levels)
8949b985 69ialias_redirect (omp_get_supported_active_levels)
07dd3bcd
JJ
70ialias_redirect (omp_set_num_teams)
71ialias_redirect (omp_get_max_teams)
72ialias_redirect (omp_set_teams_thread_limit)
73ialias_redirect (omp_get_teams_thread_limit)
a68ab351
JJ
74ialias_redirect (omp_get_level)
75ialias_redirect (omp_get_ancestor_thread_num)
76ialias_redirect (omp_get_team_size)
77ialias_redirect (omp_get_active_level)
20906c66 78ialias_redirect (omp_in_final)
0ec4e93f 79ialias_redirect (omp_in_explicit_task)
acf0174b
JJ
80ialias_redirect (omp_get_cancellation)
81ialias_redirect (omp_get_proc_bind)
d9a6bd32
JJ
82ialias_redirect (omp_get_num_places)
83ialias_redirect (omp_get_place_num_procs)
84ialias_redirect (omp_get_place_proc_ids)
85ialias_redirect (omp_get_place_num)
86ialias_redirect (omp_get_partition_num_places)
87ialias_redirect (omp_get_partition_place_nums)
acf0174b
JJ
88ialias_redirect (omp_set_default_device)
89ialias_redirect (omp_get_default_device)
90ialias_redirect (omp_get_num_devices)
0bac793e 91ialias_redirect (omp_get_device_num)
acf0174b
JJ
92ialias_redirect (omp_get_num_teams)
93ialias_redirect (omp_get_team_num)
94ialias_redirect (omp_is_initial_device)
d9a6bd32
JJ
95ialias_redirect (omp_get_initial_device)
96ialias_redirect (omp_get_max_task_priority)
28567c40
JJ
97ialias_redirect (omp_pause_resource)
98ialias_redirect (omp_pause_resource_all)
fff15bad
TB
99ialias_redirect (omp_init_allocator)
100ialias_redirect (omp_destroy_allocator)
101ialias_redirect (omp_set_default_allocator)
102ialias_redirect (omp_get_default_allocator)
7123ae24 103ialias_redirect (omp_display_env)
3749c3af 104ialias_redirect (omp_fulfill_event)
a68ab351
JJ
105#endif
106
107#ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
108# define gomp_init_lock__30 omp_init_lock_
109# define gomp_destroy_lock__30 omp_destroy_lock_
110# define gomp_set_lock__30 omp_set_lock_
111# define gomp_unset_lock__30 omp_unset_lock_
112# define gomp_test_lock__30 omp_test_lock_
113# define gomp_init_nest_lock__30 omp_init_nest_lock_
114# define gomp_destroy_nest_lock__30 omp_destroy_nest_lock_
115# define gomp_set_nest_lock__30 omp_set_nest_lock_
116# define gomp_unset_nest_lock__30 omp_unset_nest_lock_
117# define gomp_test_nest_lock__30 omp_test_nest_lock_
118#endif
953ff289
DN
119
120void
a68ab351 121gomp_init_lock__30 (omp_lock_arg_t lock)
953ff289
DN
122{
123#ifndef OMP_LOCK_DIRECT
124 omp_lock_arg (lock) = malloc (sizeof (omp_lock_t));
125#endif
a68ab351 126 gomp_init_lock_30 (omp_lock_arg (lock));
953ff289
DN
127}
128
129void
a68ab351 130gomp_init_nest_lock__30 (omp_nest_lock_arg_t lock)
953ff289
DN
131{
132#ifndef OMP_NEST_LOCK_DIRECT
133 omp_nest_lock_arg (lock) = malloc (sizeof (omp_nest_lock_t));
134#endif
a68ab351 135 gomp_init_nest_lock_30 (omp_nest_lock_arg (lock));
953ff289
DN
136}
137
138void
a68ab351 139gomp_destroy_lock__30 (omp_lock_arg_t lock)
953ff289 140{
a68ab351 141 gomp_destroy_lock_30 (omp_lock_arg (lock));
953ff289
DN
142#ifndef OMP_LOCK_DIRECT
143 free (omp_lock_arg (lock));
144 omp_lock_arg (lock) = NULL;
145#endif
146}
147
148void
a68ab351 149gomp_destroy_nest_lock__30 (omp_nest_lock_arg_t lock)
953ff289 150{
a68ab351 151 gomp_destroy_nest_lock_30 (omp_nest_lock_arg (lock));
953ff289
DN
152#ifndef OMP_NEST_LOCK_DIRECT
153 free (omp_nest_lock_arg (lock));
154 omp_nest_lock_arg (lock) = NULL;
155#endif
156}
157
158void
a68ab351
JJ
159gomp_set_lock__30 (omp_lock_arg_t lock)
160{
161 gomp_set_lock_30 (omp_lock_arg (lock));
162}
163
164void
165gomp_set_nest_lock__30 (omp_nest_lock_arg_t lock)
953ff289 166{
a68ab351 167 gomp_set_nest_lock_30 (omp_nest_lock_arg (lock));
953ff289
DN
168}
169
170void
a68ab351 171gomp_unset_lock__30 (omp_lock_arg_t lock)
953ff289 172{
a68ab351 173 gomp_unset_lock_30 (omp_lock_arg (lock));
953ff289
DN
174}
175
176void
a68ab351
JJ
177gomp_unset_nest_lock__30 (omp_nest_lock_arg_t lock)
178{
179 gomp_unset_nest_lock_30 (omp_nest_lock_arg (lock));
180}
181
182int32_t
183gomp_test_lock__30 (omp_lock_arg_t lock)
184{
185 return gomp_test_lock_30 (omp_lock_arg (lock));
186}
187
188int32_t
189gomp_test_nest_lock__30 (omp_nest_lock_arg_t lock)
953ff289 190{
a68ab351 191 return gomp_test_nest_lock_30 (omp_nest_lock_arg (lock));
953ff289
DN
192}
193
a68ab351 194#ifdef LIBGOMP_GNU_SYMBOL_VERSIONING
953ff289 195void
a68ab351 196gomp_init_lock__25 (omp_lock_25_arg_t lock)
953ff289 197{
a68ab351
JJ
198#ifndef OMP_LOCK_25_DIRECT
199 omp_lock_25_arg (lock) = malloc (sizeof (omp_lock_25_t));
200#endif
201 gomp_init_lock_25 (omp_lock_25_arg (lock));
202}
203
204void
205gomp_init_nest_lock__25 (omp_nest_lock_25_arg_t lock)
206{
207#ifndef OMP_NEST_LOCK_25_DIRECT
208 omp_nest_lock_25_arg (lock) = malloc (sizeof (omp_nest_lock_25_t));
209#endif
210 gomp_init_nest_lock_25 (omp_nest_lock_25_arg (lock));
211}
212
213void
214gomp_destroy_lock__25 (omp_lock_25_arg_t lock)
215{
216 gomp_destroy_lock_25 (omp_lock_25_arg (lock));
217#ifndef OMP_LOCK_25_DIRECT
218 free (omp_lock_25_arg (lock));
219 omp_lock_25_arg (lock) = NULL;
220#endif
221}
222
223void
224gomp_destroy_nest_lock__25 (omp_nest_lock_25_arg_t lock)
225{
226 gomp_destroy_nest_lock_25 (omp_nest_lock_25_arg (lock));
227#ifndef OMP_NEST_LOCK_25_DIRECT
228 free (omp_nest_lock_25_arg (lock));
229 omp_nest_lock_25_arg (lock) = NULL;
230#endif
953ff289
DN
231}
232
a68ab351
JJ
233void
234gomp_set_lock__25 (omp_lock_25_arg_t lock)
235{
236 gomp_set_lock_25 (omp_lock_25_arg (lock));
237}
238
239void
240gomp_set_nest_lock__25 (omp_nest_lock_25_arg_t lock)
241{
242 gomp_set_nest_lock_25 (omp_nest_lock_25_arg (lock));
243}
244
245void
246gomp_unset_lock__25 (omp_lock_25_arg_t lock)
247{
248 gomp_unset_lock_25 (omp_lock_25_arg (lock));
249}
250
251void
252gomp_unset_nest_lock__25 (omp_nest_lock_25_arg_t lock)
253{
254 gomp_unset_nest_lock_25 (omp_nest_lock_25_arg (lock));
255}
256
257int32_t
258gomp_test_lock__25 (omp_lock_25_arg_t lock)
259{
260 return gomp_test_lock_25 (omp_lock_25_arg (lock));
261}
262
263int32_t
264gomp_test_nest_lock__25 (omp_nest_lock_25_arg_t lock)
265{
266 return gomp_test_nest_lock_25 (omp_nest_lock_25_arg (lock));
267}
268
269omp_lock_symver (omp_init_lock_)
270omp_lock_symver (omp_destroy_lock_)
271omp_lock_symver (omp_set_lock_)
272omp_lock_symver (omp_unset_lock_)
273omp_lock_symver (omp_test_lock_)
274omp_lock_symver (omp_init_nest_lock_)
275omp_lock_symver (omp_destroy_nest_lock_)
276omp_lock_symver (omp_set_nest_lock_)
277omp_lock_symver (omp_unset_nest_lock_)
278omp_lock_symver (omp_test_nest_lock_)
279#endif
280
e7385332
JJ
281#define TO_INT(x) ((x) > INT_MIN ? (x) < INT_MAX ? (x) : INT_MAX : INT_MIN)
282
953ff289
DN
283void
284omp_set_dynamic_ (const int32_t *set)
285{
286 omp_set_dynamic (*set);
287}
288
289void
290omp_set_dynamic_8_ (const int64_t *set)
291{
e7385332 292 omp_set_dynamic (!!*set);
953ff289
DN
293}
294
10508db8
KCY
295#pragma GCC diagnostic push
296#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
953ff289
DN
297void
298omp_set_nested_ (const int32_t *set)
299{
300 omp_set_nested (*set);
301}
302
303void
304omp_set_nested_8_ (const int64_t *set)
305{
e7385332 306 omp_set_nested (!!*set);
953ff289 307}
10508db8 308#pragma GCC diagnostic pop
953ff289
DN
309
310void
311omp_set_num_threads_ (const int32_t *set)
312{
313 omp_set_num_threads (*set);
314}
315
316void
317omp_set_num_threads_8_ (const int64_t *set)
318{
e7385332 319 omp_set_num_threads (TO_INT (*set));
953ff289
DN
320}
321
322int32_t
323omp_get_dynamic_ (void)
324{
325 return omp_get_dynamic ();
326}
327
10508db8
KCY
328#pragma GCC diagnostic push
329#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
953ff289
DN
330int32_t
331omp_get_nested_ (void)
332{
333 return omp_get_nested ();
334}
10508db8 335#pragma GCC diagnostic pop
953ff289
DN
336
337int32_t
338omp_in_parallel_ (void)
339{
340 return omp_in_parallel ();
341}
342
953ff289
DN
343int32_t
344omp_get_max_threads_ (void)
345{
346 return omp_get_max_threads ();
347}
348
349int32_t
350omp_get_num_procs_ (void)
351{
352 return omp_get_num_procs ();
353}
354
355int32_t
356omp_get_num_threads_ (void)
357{
358 return omp_get_num_threads ();
359}
360
361int32_t
362omp_get_thread_num_ (void)
363{
364 return omp_get_thread_num ();
365}
366
953ff289
DN
367double
368omp_get_wtick_ (void)
369{
370 return omp_get_wtick ();
371}
372
373double
374omp_get_wtime_ (void)
375{
376 return omp_get_wtime ();
377}
a68ab351
JJ
378
379void
d9a6bd32 380omp_set_schedule_ (const int32_t *kind, const int32_t *chunk_size)
a68ab351 381{
d9a6bd32 382 omp_set_schedule (*kind, *chunk_size);
a68ab351
JJ
383}
384
385void
d9a6bd32 386omp_set_schedule_8_ (const int32_t *kind, const int64_t *chunk_size)
a68ab351 387{
d9a6bd32 388 omp_set_schedule (*kind, TO_INT (*chunk_size));
a68ab351
JJ
389}
390
391void
d9a6bd32 392omp_get_schedule_ (int32_t *kind, int32_t *chunk_size)
a68ab351
JJ
393{
394 omp_sched_t k;
d9a6bd32
JJ
395 int cs;
396 omp_get_schedule (&k, &cs);
28567c40
JJ
397 /* For now mask off GFS_MONOTONIC, because OpenMP 4.5 code will not
398 expect to see it. */
399 *kind = k & ~GFS_MONOTONIC;
d9a6bd32 400 *chunk_size = cs;
a68ab351
JJ
401}
402
403void
d9a6bd32 404omp_get_schedule_8_ (int32_t *kind, int64_t *chunk_size)
a68ab351
JJ
405{
406 omp_sched_t k;
d9a6bd32
JJ
407 int cs;
408 omp_get_schedule (&k, &cs);
28567c40
JJ
409 /* See above. */
410 *kind = k & ~GFS_MONOTONIC;
d9a6bd32 411 *chunk_size = cs;
a68ab351
JJ
412}
413
414int32_t
415omp_get_thread_limit_ (void)
416{
417 return omp_get_thread_limit ();
418}
419
420void
421omp_set_max_active_levels_ (const int32_t *levels)
422{
423 omp_set_max_active_levels (*levels);
424}
425
426void
427omp_set_max_active_levels_8_ (const int64_t *levels)
428{
e7385332 429 omp_set_max_active_levels (TO_INT (*levels));
a68ab351
JJ
430}
431
432int32_t
433omp_get_max_active_levels_ (void)
434{
435 return omp_get_max_active_levels ();
436}
437
8949b985
KCY
438int32_t
439omp_get_supported_active_levels_ (void)
440{
441 return omp_get_supported_active_levels ();
442}
443
a68ab351
JJ
444int32_t
445omp_get_level_ (void)
446{
447 return omp_get_level ();
448}
449
450int32_t
451omp_get_ancestor_thread_num_ (const int32_t *level)
452{
453 return omp_get_ancestor_thread_num (*level);
454}
455
456int32_t
457omp_get_ancestor_thread_num_8_ (const int64_t *level)
458{
e7385332 459 return omp_get_ancestor_thread_num (TO_INT (*level));
a68ab351
JJ
460}
461
462int32_t
463omp_get_team_size_ (const int32_t *level)
464{
465 return omp_get_team_size (*level);
466}
467
468int32_t
469omp_get_team_size_8_ (const int64_t *level)
470{
e7385332 471 return omp_get_team_size (TO_INT (*level));
a68ab351
JJ
472}
473
474int32_t
475omp_get_active_level_ (void)
476{
477 return omp_get_active_level ();
478}
20906c66
JJ
479
480int32_t
481omp_in_final_ (void)
482{
483 return omp_in_final ();
484}
acf0174b 485
0ec4e93f
JJ
486int32_t
487omp_in_explicit_task_ (void)
488{
489 return omp_in_explicit_task ();
490}
491
07dd3bcd
JJ
492void
493omp_set_num_teams_ (const int32_t *num_teams)
494{
495 omp_set_num_teams (*num_teams);
496}
497
498void
499omp_set_num_teams_8_ (const int64_t *num_teams)
500{
be093b8d 501 omp_set_num_teams (TO_INT (*num_teams));
07dd3bcd
JJ
502}
503
504int32_t
505omp_get_max_teams_ (void)
506{
507 return omp_get_max_teams ();
508}
509
510void
511omp_set_teams_thread_limit_ (const int32_t *thread_limit)
512{
513 omp_set_teams_thread_limit (*thread_limit);
514}
515
516void
517omp_set_teams_thread_limit_8_ (const int64_t *thread_limit)
518{
519 omp_set_teams_thread_limit (TO_INT (*thread_limit));
520}
521
522int32_t
523omp_get_teams_thread_limit_ (void)
524{
525 return omp_get_teams_thread_limit ();
526}
527
acf0174b
JJ
528int32_t
529omp_get_cancellation_ (void)
530{
531 return omp_get_cancellation ();
532}
533
534int32_t
535omp_get_proc_bind_ (void)
536{
537 return omp_get_proc_bind ();
538}
539
d9a6bd32
JJ
540int32_t
541omp_get_num_places_ (void)
542{
543 return omp_get_num_places ();
544}
545
546int32_t
547omp_get_place_num_procs_ (const int32_t *place_num)
548{
549 return omp_get_place_num_procs (*place_num);
550}
551
552int32_t
553omp_get_place_num_procs_8_ (const int64_t *place_num)
554{
555 return omp_get_place_num_procs (TO_INT (*place_num));
556}
557
558void
559omp_get_place_proc_ids_ (const int32_t *place_num, int32_t *ids)
560{
ac8a1965 561 omp_get_place_proc_ids (*place_num, (int *) ids);
d9a6bd32
JJ
562}
563
564void
565omp_get_place_proc_ids_8_ (const int64_t *place_num, int64_t *ids)
566{
567 gomp_get_place_proc_ids_8 (TO_INT (*place_num), ids);
568}
569
570int32_t
571omp_get_place_num_ (void)
572{
573 return omp_get_place_num ();
574}
575
576int32_t
577omp_get_partition_num_places_ (void)
578{
579 return omp_get_partition_num_places ();
580}
581
582void
583omp_get_partition_place_nums_ (int32_t *place_nums)
584{
ac8a1965 585 omp_get_partition_place_nums ((int *) place_nums);
d9a6bd32
JJ
586}
587
588void
589omp_get_partition_place_nums_8_ (int64_t *place_nums)
590{
591 if (gomp_places_list == NULL)
592 return;
593
594 struct gomp_thread *thr = gomp_thread ();
595 if (thr->place == 0)
596 gomp_init_affinity ();
597
598 unsigned int i;
599 for (i = 0; i < thr->ts.place_partition_len; i++)
600 *place_nums++ = (int64_t) thr->ts.place_partition_off + i;
601}
602
acf0174b
JJ
603void
604omp_set_default_device_ (const int32_t *device_num)
605{
606 return omp_set_default_device (*device_num);
607}
608
609void
610omp_set_default_device_8_ (const int64_t *device_num)
611{
612 return omp_set_default_device (TO_INT (*device_num));
613}
614
615int32_t
616omp_get_default_device_ (void)
617{
618 return omp_get_default_device ();
619}
620
621int32_t
622omp_get_num_devices_ (void)
623{
624 return omp_get_num_devices ();
625}
626
627int32_t
628omp_get_num_teams_ (void)
629{
630 return omp_get_num_teams ();
631}
632
633int32_t
634omp_get_team_num_ (void)
635{
636 return omp_get_team_num ();
637}
638
639int32_t
640omp_is_initial_device_ (void)
641{
642 return omp_is_initial_device ();
643}
d9a6bd32
JJ
644
645int32_t
646omp_get_initial_device_ (void)
647{
648 return omp_get_initial_device ();
649}
650
0bac793e
CLT
651int32_t
652omp_get_device_num_ (void)
653{
654 return omp_get_device_num ();
655}
656
d9a6bd32
JJ
657int32_t
658omp_get_max_task_priority_ (void)
659{
660 return omp_get_max_task_priority ();
661}
28567c40 662
a6d22fb2
KCY
663void
664omp_fulfill_event_ (intptr_t event)
665{
666 omp_fulfill_event ((omp_event_handle_t) event);
667}
668
28567c40
JJ
669void
670omp_set_affinity_format_ (const char *format, size_t format_len)
671{
672 gomp_set_affinity_format (format, format_len);
673}
674
675int32_t
676omp_get_affinity_format_ (char *buffer, size_t buffer_len)
677{
678 size_t len = strlen (gomp_affinity_format_var);
679 if (buffer_len)
680 {
681 if (len < buffer_len)
682 {
683 memcpy (buffer, gomp_affinity_format_var, len);
684 memset (buffer + len, ' ', buffer_len - len);
685 }
686 else
687 memcpy (buffer, gomp_affinity_format_var, buffer_len);
688 }
689 return len;
690}
691
692void
693omp_display_affinity_ (const char *format, size_t format_len)
694{
695 char *fmt = NULL, fmt_buf[256];
696 char buf[512];
697 if (format_len)
698 {
699 fmt = format_len < 256 ? fmt_buf : gomp_malloc (format_len + 1);
700 memcpy (fmt, format, format_len);
701 fmt[format_len] = '\0';
702 }
703 struct gomp_thread *thr = gomp_thread ();
704 size_t ret
705 = gomp_display_affinity (buf, sizeof buf,
706 format_len ? fmt : gomp_affinity_format_var,
707 gomp_thread_self (), &thr->ts, thr->place);
708 if (ret < sizeof buf)
709 {
710 buf[ret] = '\n';
fe0827ee 711 gomp_print_string (buf, ret + 1);
28567c40
JJ
712 }
713 else
714 {
715 char *b = gomp_malloc (ret + 1);
716 gomp_display_affinity (buf, sizeof buf,
717 format_len ? fmt : gomp_affinity_format_var,
718 gomp_thread_self (), &thr->ts, thr->place);
719 b[ret] = '\n';
fe0827ee 720 gomp_print_string (b, ret + 1);
28567c40
JJ
721 free (b);
722 }
723 if (fmt && fmt != fmt_buf)
724 free (fmt);
725}
726
727int32_t
728omp_capture_affinity_ (char *buffer, const char *format,
729 size_t buffer_len, size_t format_len)
730{
731 char *fmt = NULL, fmt_buf[256];
732 if (format_len)
733 {
734 fmt = format_len < 256 ? fmt_buf : gomp_malloc (format_len + 1);
735 memcpy (fmt, format, format_len);
736 fmt[format_len] = '\0';
737 }
738 struct gomp_thread *thr = gomp_thread ();
739 size_t ret
740 = gomp_display_affinity (buffer, buffer_len,
741 format_len ? fmt : gomp_affinity_format_var,
742 gomp_thread_self (), &thr->ts, thr->place);
743 if (fmt && fmt != fmt_buf)
744 free (fmt);
745 if (ret < buffer_len)
746 memset (buffer + ret, ' ', buffer_len - ret);
747 return ret;
748}
749
750int32_t
751omp_pause_resource_ (const int32_t *kind, const int32_t *device_num)
752{
753 return omp_pause_resource (*kind, *device_num);
754}
755
756int32_t
757omp_pause_resource_all_ (const int32_t *kind)
758{
759 return omp_pause_resource_all (*kind);
760}
fff15bad
TB
761
762intptr_t
763omp_init_allocator_ (const intptr_t *memspace, const int32_t *ntraits,
764 const omp_alloctrait_t *traits)
765{
766 return (intptr_t) omp_init_allocator ((omp_memspace_handle_t) *memspace,
767 (int) *ntraits, traits);
768}
769
770intptr_t
771omp_init_allocator_8_ (const intptr_t *memspace, const int64_t *ntraits,
772 const omp_alloctrait_t *traits)
773{
774 return (intptr_t) omp_init_allocator ((omp_memspace_handle_t) *memspace,
775 (int) *ntraits, traits);
776}
777
778void
779omp_destroy_allocator_ (const intptr_t *allocator)
780{
781 omp_destroy_allocator ((omp_allocator_handle_t) *allocator);
782}
783
784void
785omp_set_default_allocator_ (const intptr_t *allocator)
786{
787 omp_set_default_allocator ((omp_allocator_handle_t) *allocator);
788}
789
790intptr_t
791omp_get_default_allocator_ ()
792{
793 return (intptr_t) omp_get_default_allocator ();
794}
7123ae24 795
28665ddc
TS
796#ifndef LIBGOMP_OFFLOADED_ONLY
797
7123ae24
UD
798void
799omp_display_env_ (const int32_t *verbose)
800{
801 omp_display_env (*verbose);
802}
803
804void
805omp_display_env_8_ (const int64_t *verbose)
806{
807 omp_display_env (!!*verbose);
808}
28665ddc
TS
809
810#endif /* LIBGOMP_OFFLOADED_ONLY */