+++ /dev/null
-254a858ae7ae (Jakub Jelinek 2026-01-02 09:53:48 +0100 1) /* Copyright (C) 2018-2026 Free Software Foundation, Inc.
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 2) Contributed by Jakub Jelinek <jakub@redhat.com>.
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 3)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 4) This file is part of the GNU Offloading and Multi Processing Library
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 5) (libgomp).
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 6)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 7) Libgomp is free software; you can redistribute it and/or modify it
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 8) under the terms of the GNU General Public License as published by
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 9) the Free Software Foundation; either version 3, or (at your option)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 10) any later version.
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 11)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 12) Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 13) WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 14) FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 15) more details.
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 16)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 17) Under Section 7 of GPL version 3, you are granted additional
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 18) permissions described in the GCC Runtime Library Exception, version
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 19) 3.1, as published by the Free Software Foundation.
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 20)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 21) You should have received a copy of the GNU General Public License and
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 22) a copy of the GCC Runtime Library Exception along with this program;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 23) see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 24) <http://www.gnu.org/licenses/>. */
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 25)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 26) #include "libgomp.h"
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 27) #include <string.h>
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 28) #include <stdio.h>
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 29) #include <stdlib.h>
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 30) #ifdef HAVE_UNISTD_H
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 31) #include <unistd.h>
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 32) #endif
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 33) #ifdef HAVE_INTTYPES_H
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 34) # include <inttypes.h> /* For PRIx64. */
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 35) #endif
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 36) #ifdef HAVE_UNAME
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 37) #include <sys/utsname.h>
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 38) #endif
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 39)
-3749c3aff651 (Jakub Jelinek 2021-10-01 10:42:07 +0200 40) ialias_redirect (omp_get_team_num)
-3749c3aff651 (Jakub Jelinek 2021-10-01 10:42:07 +0200 41) ialias_redirect (omp_get_num_teams)
-3749c3aff651 (Jakub Jelinek 2021-10-01 10:42:07 +0200 42)
-91df4397a140 (Jakub Jelinek 2020-01-10 21:42:00 +0100 43) bool
-fe0827eed09d (Tom de Vries 2018-12-13 18:04:05 +0000 44) gomp_print_string (const char *str, size_t len)
-fe0827eed09d (Tom de Vries 2018-12-13 18:04:05 +0000 45) {
-91df4397a140 (Jakub Jelinek 2020-01-10 21:42:00 +0100 46) return fwrite (str, 1, len, stderr) != len;
-fe0827eed09d (Tom de Vries 2018-12-13 18:04:05 +0000 47) }
-fe0827eed09d (Tom de Vries 2018-12-13 18:04:05 +0000 48)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 49) void
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 50) gomp_set_affinity_format (const char *format, size_t len)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 51) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 52) if (len < gomp_affinity_format_len)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 53) memcpy (gomp_affinity_format_var, format, len);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 54) else
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 55) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 56) char *p;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 57) if (gomp_affinity_format_len)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 58) p = gomp_realloc (gomp_affinity_format_var, len + 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 59) else
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 60) p = gomp_malloc (len + 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 61) memcpy (p, format, len);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 62) gomp_affinity_format_var = p;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 63) gomp_affinity_format_len = len + 1;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 64) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 65) gomp_affinity_format_var[len] = '\0';
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 66) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 67)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 68) void
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 69) omp_set_affinity_format (const char *format)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 70) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 71) gomp_set_affinity_format (format, strlen (format));
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 72) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 73)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 74) size_t
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 75) omp_get_affinity_format (char *buffer, size_t size)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 76) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 77) size_t len = strlen (gomp_affinity_format_var);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 78) if (size)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 79) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 80) if (len < size)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 81) memcpy (buffer, gomp_affinity_format_var, len + 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 82) else
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 83) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 84) memcpy (buffer, gomp_affinity_format_var, size - 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 85) buffer[size - 1] = '\0';
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 86) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 87) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 88) return len;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 89) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 90)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 91) void
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 92) gomp_display_string (char *buffer, size_t size, size_t *ret,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 93) const char *str, size_t len)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 94) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 95) size_t r = *ret;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 96) if (size && r < size)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 97) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 98) size_t l = len;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 99) if (size - r < len)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 100) l = size - r;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 101) memcpy (buffer + r, str, l);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 102) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 103) *ret += len;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 104) if (__builtin_expect (r > *ret, 0))
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 105) gomp_fatal ("overflow in omp_capture_affinity");
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 106) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 107)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 108) static void
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 109) gomp_display_repeat (char *buffer, size_t size, size_t *ret,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 110) char c, size_t len)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 111) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 112) size_t r = *ret;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 113) if (size && r < size)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 114) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 115) size_t l = len;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 116) if (size - r < len)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 117) l = size - r;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 118) memset (buffer + r, c, l);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 119) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 120) *ret += len;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 121) if (__builtin_expect (r > *ret, 0))
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 122) gomp_fatal ("overflow in omp_capture_affinity");
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 123) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 124)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 125) static void
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 126) gomp_display_num (char *buffer, size_t size, size_t *ret,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 127) bool zero, bool right, size_t sz, char *buf)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 128) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 129) size_t l = strlen (buf);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 130) if (sz == (size_t) -1 || l >= sz)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 131) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 132) gomp_display_string (buffer, size, ret, buf, l);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 133) return;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 134) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 135) if (zero)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 136) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 137) if (buf[0] == '-')
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 138) gomp_display_string (buffer, size, ret, buf, 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 139) else if (buf[0] == '0' && buf[1] == 'x')
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 140) gomp_display_string (buffer, size, ret, buf, 2);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 141) gomp_display_repeat (buffer, size, ret, '0', sz - l);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 142) if (buf[0] == '-')
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 143) gomp_display_string (buffer, size, ret, buf + 1, l - 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 144) else if (buf[0] == '0' && buf[1] == 'x')
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 145) gomp_display_string (buffer, size, ret, buf + 2, l - 2);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 146) else
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 147) gomp_display_string (buffer, size, ret, buf, l);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 148) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 149) else if (right)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 150) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 151) gomp_display_repeat (buffer, size, ret, ' ', sz - l);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 152) gomp_display_string (buffer, size, ret, buf, l);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 153) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 154) else
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 155) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 156) gomp_display_string (buffer, size, ret, buf, l);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 157) gomp_display_repeat (buffer, size, ret, ' ', sz - l);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 158) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 159) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 160)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 161) static void
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 162) gomp_display_int (char *buffer, size_t size, size_t *ret,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 163) bool zero, bool right, size_t sz, int num)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 164) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 165) char buf[3 * sizeof (int) + 2];
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 166) sprintf (buf, "%d", num);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 167) gomp_display_num (buffer, size, ret, zero, right, sz, buf);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 168) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 169)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 170) static void
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 171) gomp_display_string_len (char *buffer, size_t size, size_t *ret,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 172) bool right, size_t sz, char *str, size_t len)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 173) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 174) if (sz == (size_t) -1 || len >= sz)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 175) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 176) gomp_display_string (buffer, size, ret, str, len);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 177) return;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 178) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 179)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 180) if (right)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 181) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 182) gomp_display_repeat (buffer, size, ret, ' ', sz - len);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 183) gomp_display_string (buffer, size, ret, str, len);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 184) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 185) else
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 186) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 187) gomp_display_string (buffer, size, ret, str, len);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 188) gomp_display_repeat (buffer, size, ret, ' ', sz - len);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 189) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 190) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 191)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 192) static void
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 193) gomp_display_hostname (char *buffer, size_t size, size_t *ret,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 194) bool right, size_t sz)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 195) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 196) #ifdef HAVE_GETHOSTNAME
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 197) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 198) char buf[256];
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 199) char *b = buf;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 200) size_t len = 256;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 201) do
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 202) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 203) b[len - 1] = '\0';
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 204) if (gethostname (b, len - 1) == 0)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 205) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 206) size_t l = strlen (b);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 207) if (l < len - 1)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 208) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 209) gomp_display_string_len (buffer, size, ret,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 210) right, sz, b, l);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 211) if (b != buf)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 212) free (b);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 213) return;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 214) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 215) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 216) if (len == 1048576)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 217) break;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 218) len = len * 2;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 219) if (len == 512)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 220) b = gomp_malloc (len);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 221) else
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 222) b = gomp_realloc (b, len);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 223) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 224) while (1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 225) if (b != buf)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 226) free (b);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 227) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 228) #endif
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 229) #ifdef HAVE_UNAME
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 230) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 231) struct utsname buf;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 232) if (uname (&buf) == 0)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 233) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 234) gomp_display_string_len (buffer, size, ret, right, sz,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 235) buf.nodename, strlen (buf.nodename));
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 236) return;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 237) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 238) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 239) #endif
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 240) gomp_display_string_len (buffer, size, ret, right, sz, "node", 4);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 241) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 242)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 243) struct affinity_types_struct {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 244) char long_str[18];
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 245) char long_len;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 246) char short_c; };
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 247)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 248) static struct affinity_types_struct affinity_types[] =
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 249) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 250) #define AFFINITY_TYPE(l, s) \
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 251) { #l, sizeof (#l) - 1, s }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 252) AFFINITY_TYPE (team_num, 't'),
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 253) AFFINITY_TYPE (num_teams, 'T'),
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 254) AFFINITY_TYPE (nesting_level, 'L'),
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 255) AFFINITY_TYPE (thread_num, 'n'),
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 256) AFFINITY_TYPE (num_threads, 'N'),
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 257) AFFINITY_TYPE (ancestor_tnum, 'a'),
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 258) AFFINITY_TYPE (host, 'H'),
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 259) AFFINITY_TYPE (process_id, 'P'),
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 260) AFFINITY_TYPE (native_thread_id, 'i'),
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 261) AFFINITY_TYPE (thread_affinity, 'A')
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 262) #undef AFFINITY_TYPE
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 263) };
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 264)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 265) size_t
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 266) gomp_display_affinity (char *buffer, size_t size,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 267) const char *format, gomp_thread_handle handle,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 268) struct gomp_team_state *ts, unsigned int place)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 269) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 270) size_t ret = 0;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 271) do
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 272) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 273) const char *p = strchr (format, '%');
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 274) bool zero = false;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 275) bool right = false;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 276) size_t sz = -1;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 277) char c;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 278) int val;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 279) if (p == NULL)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 280) p = strchr (format, '\0');
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 281) if (p != format)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 282) gomp_display_string (buffer, size, &ret,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 283) format, p - format);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 284) if (*p == '\0')
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 285) break;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 286) p++;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 287) if (*p == '%')
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 288) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 289) gomp_display_string (buffer, size, &ret, "%", 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 290) format = p + 1;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 291) continue;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 292) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 293) if (*p == '0')
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 294) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 295) zero = true;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 296) p++;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 297) if (*p != '.')
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 298) gomp_fatal ("leading zero not followed by dot in affinity format");
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 299) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 300) if (*p == '.')
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 301) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 302) right = true;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 303) p++;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 304) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 305) if (*p >= '1' && *p <= '9')
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 306) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 307) char *end;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 308) sz = strtoul (p, &end, 10);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 309) p = end;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 310) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 311) else if (zero || right)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 312) gomp_fatal ("leading zero or right justification in affinity format "
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 313) "requires size");
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 314) c = *p;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 315) if (c == '{')
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 316) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 317) int i;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 318) for (i = 0;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 319) i < sizeof (affinity_types) / sizeof (affinity_types[0]); ++i)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 320) if (strncmp (p + 1, affinity_types[i].long_str,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 321) affinity_types[i].long_len) == 0
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 322) && p[affinity_types[i].long_len + 1] == '}')
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 323) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 324) c = affinity_types[i].short_c;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 325) p += affinity_types[i].long_len + 1;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 326) break;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 327) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 328) if (c == '{')
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 329) {
-9c9d3aef2f66 (Frank Scheiner 2025-11-25 16:58:23 -0700 330) const char *q = strchr (p + 1, '}');
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 331) if (q)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 332) gomp_fatal ("unsupported long type name '%.*s' in affinity "
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 333) "format", (int) (q - (p + 1)), p + 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 334) else
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 335) gomp_fatal ("unterminated long type name '%s' in affinity "
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 336) "format", p + 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 337) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 338) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 339) switch (c)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 340) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 341) case 't':
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 342) val = omp_get_team_num ();
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 343) goto do_int;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 344) case 'T':
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 345) val = omp_get_num_teams ();
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 346) goto do_int;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 347) case 'L':
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 348) val = ts->level;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 349) goto do_int;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 350) case 'n':
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 351) val = ts->team_id;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 352) goto do_int;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 353) case 'N':
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 354) val = ts->team ? ts->team->nthreads : 1;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 355) goto do_int;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 356) case 'a':
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 357) val = ts->team ? ts->team->prev_ts.team_id : -1;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 358) goto do_int;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 359) case 'H':
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 360) gomp_display_hostname (buffer, size, &ret, right, sz);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 361) break;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 362) case 'P':
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 363) #ifdef HAVE_GETPID
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 364) val = getpid ();
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 365) #else
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 366) val = 0;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 367) #endif
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 368) goto do_int;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 369) case 'i':
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 370) #if defined(LIBGOMP_USE_PTHREADS) && defined(__GNUC__)
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 371) {
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 372) char buf[3 * (sizeof (handle) + sizeof (uintptr_t) + sizeof (int))
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 373) + 4];
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 374) /* This macro returns expr unmodified for integral or pointer
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 375) types and 0 for anything else (e.g. aggregates). */
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 376) #define gomp_nonaggregate(expr) \
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 377) __builtin_choose_expr (__builtin_classify_type (expr) == 1 \
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 378) || __builtin_classify_type (expr) == 5, expr, 0)
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 379) /* This macro returns expr unmodified for integral types,
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 380) (uintptr_t) (expr) for pointer types and 0 for anything else
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 381) (e.g. aggregates). */
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 382) #define gomp_integral(expr) \
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 383) __builtin_choose_expr (__builtin_classify_type (expr) == 5, \
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 384) (uintptr_t) gomp_nonaggregate (expr), \
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 385) gomp_nonaggregate (expr))
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 386)
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 387) if (sizeof (gomp_integral (handle)) == sizeof (unsigned long))
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 388) sprintf (buf, "0x%lx", (unsigned long) gomp_integral (handle));
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 389) #if defined (HAVE_INTTYPES_H) && defined (PRIx64)
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 390) else if (sizeof (gomp_integral (handle)) == sizeof (uint64_t))
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 391) sprintf (buf, "0x%" PRIx64, (uint64_t) gomp_integral (handle));
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 392) #else
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 393) else if (sizeof (gomp_integral (handle))
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 394) == sizeof (unsigned long long))
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 395) sprintf (buf, "0x%llx",
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 396) (unsigned long long) gomp_integral (handle));
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 397) #endif
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 398) else
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 399) sprintf (buf, "0x%x", (unsigned int) gomp_integral (handle));
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 400) gomp_display_num (buffer, size, &ret, zero, right, sz, buf);
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 401) break;
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 402) }
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 403) #else
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 404) val = 0;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 405) goto do_int;
-9666c52203b7 (Jakub Jelinek 2018-11-09 21:17:40 +0100 406) #endif
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 407) case 'A':
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 408) if (sz == (size_t) -1)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 409) gomp_display_affinity_place (buffer, size, &ret,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 410) place - 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 411) else if (right)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 412) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 413) size_t len = 0;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 414) gomp_display_affinity_place (NULL, 0, &len, place - 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 415) if (len < sz)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 416) gomp_display_repeat (buffer, size, &ret, ' ', sz - len);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 417) gomp_display_affinity_place (buffer, size, &ret, place - 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 418) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 419) else
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 420) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 421) size_t start = ret;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 422) gomp_display_affinity_place (buffer, size, &ret, place - 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 423) if (ret - start < sz)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 424) gomp_display_repeat (buffer, size, &ret, ' ', sz - (ret - start));
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 425) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 426) break;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 427) do_int:
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 428) gomp_display_int (buffer, size, &ret, zero, right, sz, val);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 429) break;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 430) default:
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 431) gomp_fatal ("unsupported type %c in affinity format", c);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 432) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 433) format = p + 1;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 434) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 435) while (1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 436) return ret;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 437) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 438)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 439) size_t
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 440) omp_capture_affinity (char *buffer, size_t size, const char *format)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 441) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 442) struct gomp_thread *thr = gomp_thread ();
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 443) size_t ret
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 444) = gomp_display_affinity (buffer, size,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 445) format && *format
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 446) ? format : gomp_affinity_format_var,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 447) gomp_thread_self (), &thr->ts, thr->place);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 448) if (size)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 449) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 450) if (ret >= size)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 451) buffer[size - 1] = '\0';
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 452) else
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 453) buffer[ret] = '\0';
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 454) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 455) return ret;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 456) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 457) ialias (omp_capture_affinity)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 458)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 459) void
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 460) omp_display_affinity (const char *format)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 461) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 462) char buf[512];
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 463) char *b;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 464) size_t ret = ialias_call (omp_capture_affinity) (buf, sizeof buf, format);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 465) if (ret < sizeof buf)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 466) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 467) buf[ret] = '\n';
-fe0827eed09d (Tom de Vries 2018-12-13 18:04:05 +0000 468) gomp_print_string (buf, ret + 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 469) return;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 470) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 471) b = gomp_malloc (ret + 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 472) ialias_call (omp_capture_affinity) (b, ret + 1, format);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 473) b[ret] = '\n';
-fe0827eed09d (Tom de Vries 2018-12-13 18:04:05 +0000 474) gomp_print_string (b, ret + 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 475) free (b);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 476) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 477)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 478) void
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 479) gomp_display_affinity_thread (gomp_thread_handle handle,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 480) struct gomp_team_state *ts, unsigned int place)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 481) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 482) char buf[512];
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 483) char *b;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 484) size_t ret = gomp_display_affinity (buf, sizeof buf, gomp_affinity_format_var,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 485) handle, ts, place);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 486) if (ret < sizeof buf)
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 487) {
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 488) buf[ret] = '\n';
-fe0827eed09d (Tom de Vries 2018-12-13 18:04:05 +0000 489) gomp_print_string (buf, ret + 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 490) return;
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 491) }
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 492) b = gomp_malloc (ret + 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 493) gomp_display_affinity (b, ret + 1, gomp_affinity_format_var,
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 494) handle, ts, place);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 495) b[ret] = '\n';
-fe0827eed09d (Tom de Vries 2018-12-13 18:04:05 +0000 496) gomp_print_string (b, ret + 1);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 497) free (b);
-28567c40e2c7 (Jakub Jelinek 2018-11-08 18:13:04 +0100 498) }