localedata: Months updated from CLDR - Bengali scripts [BZ #21217]
[glibc.git] / sysdeps / powerpc / dl-procinfo.h
blob216d20fbff81981163c5883735ceee9da0b5b0bb
1 /* Processor capability information handling macros. PowerPC version.
2 Copyright (C) 2005-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _DL_PROCINFO_H
20 #define _DL_PROCINFO_H 1
22 #include <ldsodefs.h>
23 #include <sysdep.h> /* This defines the PPC_FEATURE[2]_* macros. */
25 /* The total number of available bits (including those prior to
26 _DL_HWCAP_FIRST). Some of these bits might not be used. */
27 #define _DL_HWCAP_COUNT 64
29 /* Features started at bit 31 and decremented as new features were added. */
30 #define _DL_HWCAP_LAST 31
32 /* AT_HWCAP2 features started at bit 31 and decremented as new features were
33 added. HWCAP2 feature bits start at bit 0. */
34 #define _DL_HWCAP2_LAST 31
36 /* These bits influence library search. */
37 #define HWCAP_IMPORTANT (PPC_FEATURE_HAS_ALTIVEC \
38 + PPC_FEATURE_HAS_DFP)
40 #define _DL_PLATFORMS_COUNT 15
42 #define _DL_FIRST_PLATFORM 32
43 /* Mask to filter out platforms. */
44 #define _DL_HWCAP_PLATFORM (((1ULL << _DL_PLATFORMS_COUNT) - 1) \
45 << _DL_FIRST_PLATFORM)
47 /* Platform bits (relative to _DL_FIRST_PLATFORM). */
48 #define PPC_PLATFORM_POWER4 0
49 #define PPC_PLATFORM_PPC970 1
50 #define PPC_PLATFORM_POWER5 2
51 #define PPC_PLATFORM_POWER5_PLUS 3
52 #define PPC_PLATFORM_POWER6 4
53 #define PPC_PLATFORM_CELL_BE 5
54 #define PPC_PLATFORM_POWER6X 6
55 #define PPC_PLATFORM_POWER7 7
56 #define PPC_PLATFORM_PPCA2 8
57 #define PPC_PLATFORM_PPC405 9
58 #define PPC_PLATFORM_PPC440 10
59 #define PPC_PLATFORM_PPC464 11
60 #define PPC_PLATFORM_PPC476 12
61 #define PPC_PLATFORM_POWER8 13
62 #define PPC_PLATFORM_POWER9 14
64 static inline const char *
65 __attribute__ ((unused))
66 _dl_hwcap_string (int idx)
68 return GLRO(dl_powerpc_cap_flags)[idx];
71 static inline int
72 __attribute__ ((unused))
73 _dl_string_hwcap (const char *str)
75 for (int i = 0; i < _DL_HWCAP_COUNT; ++i)
76 if (strcmp (str, _dl_hwcap_string (i)) == 0)
77 return i;
78 return -1;
81 static inline int
82 __attribute__ ((unused, always_inline))
83 _dl_string_platform (const char *str)
85 if (str == NULL)
86 return -1;
88 if (strncmp (str, "power", 5) == 0)
90 int ret;
91 str += 5;
92 switch (*str)
94 case '4':
95 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER4;
96 break;
97 case '5':
98 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER5;
99 if (str[1] == '+')
101 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER5_PLUS;
102 ++str;
104 break;
105 case '6':
106 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER6;
107 if (str[1] == 'x')
109 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER6X;
110 ++str;
112 break;
113 case '7':
114 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER7;
115 break;
116 case '8':
117 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER8;
118 break;
119 case '9':
120 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER9;
121 break;
122 default:
123 return -1;
125 if (str[1] == '\0')
126 return ret;
128 else if (strncmp (str, "ppc", 3) == 0)
130 if (strcmp (str + 3, "970") == 0)
131 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC970;
132 else if (strcmp (str + 3, "-cell-be") == 0)
133 return _DL_FIRST_PLATFORM + PPC_PLATFORM_CELL_BE;
134 else if (strcmp (str + 3, "a2") == 0)
135 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPCA2;
136 else if (strcmp (str + 3, "405") == 0)
137 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC405;
138 else if (strcmp (str + 3, "440") == 0)
139 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC440;
140 else if (strcmp (str + 3, "464") == 0)
141 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC464;
142 else if (strcmp (str + 3, "476") == 0)
143 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC476;
146 return -1;
149 #if IS_IN (rtld)
150 static inline int
151 __attribute__ ((unused))
152 _dl_procinfo (unsigned int type, unsigned long int word)
154 switch(type)
156 case AT_HWCAP:
157 _dl_printf ("AT_HWCAP: ");
159 for (int i = 0; i <= _DL_HWCAP_LAST; ++i)
160 if (word & (1 << i))
161 _dl_printf (" %s", _dl_hwcap_string (i));
162 break;
163 case AT_HWCAP2:
165 unsigned int offset = _DL_HWCAP_LAST + 1;
167 _dl_printf ("AT_HWCAP2: ");
169 /* We have to go through them all because the kernel added the
170 AT_HWCAP2 features starting with the high bits. */
171 for (int i = 0; i <= _DL_HWCAP2_LAST; ++i)
172 if (word & (1 << i))
173 _dl_printf (" %s", _dl_hwcap_string (offset + i));
174 break;
176 default:
177 /* This should not happen. */
178 return -1;
180 _dl_printf ("\n");
181 return 0;
183 #endif
185 #endif /* dl-procinfo.h */