Add GLRO(dl_hwcap2) for new AT_HWCAP2 auxv_t a_type.
[glibc.git] / sysdeps / powerpc / dl-procinfo.h
blob7732ed2226210ccbcbc20b77e89115d05a12c01e
1 /* Processor capability information handling macros. PowerPC version.
2 Copyright (C) 2005, 2006 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_* macros. */
25 /* There are 25 bits used, but they are bits 7..31. */
26 #define _DL_HWCAP_FIRST 7
27 #define _DL_HWCAP_COUNT 32
29 /* These bits influence library search. */
30 #define HWCAP_IMPORTANT (PPC_FEATURE_HAS_ALTIVEC \
31 + PPC_FEATURE_HAS_DFP)
33 #define _DL_PLATFORMS_COUNT 14
35 #define _DL_FIRST_PLATFORM 32
36 /* Mask to filter out platforms. */
37 #define _DL_HWCAP_PLATFORM (((1ULL << _DL_PLATFORMS_COUNT) - 1) \
38 << _DL_FIRST_PLATFORM)
40 /* Platform bits (relative to _DL_FIRST_PLATFORM). */
41 #define PPC_PLATFORM_POWER4 0
42 #define PPC_PLATFORM_PPC970 1
43 #define PPC_PLATFORM_POWER5 2
44 #define PPC_PLATFORM_POWER5_PLUS 3
45 #define PPC_PLATFORM_POWER6 4
46 #define PPC_PLATFORM_CELL_BE 5
47 #define PPC_PLATFORM_POWER6X 6
48 #define PPC_PLATFORM_POWER7 7
49 #define PPC_PLATFORM_PPCA2 8
50 #define PPC_PLATFORM_PPC405 9
51 #define PPC_PLATFORM_PPC440 10
52 #define PPC_PLATFORM_PPC464 11
53 #define PPC_PLATFORM_PPC476 12
54 #define PPC_PLATFORM_POWER8 13
56 static inline const char *
57 __attribute__ ((unused))
58 _dl_hwcap_string (int idx)
60 return GLRO(dl_powerpc_cap_flags)[idx - _DL_HWCAP_FIRST];
63 static inline const char *
64 __attribute__ ((unused))
65 _dl_platform_string (int idx)
67 return GLRO(dl_powerpc_platforms)[idx - _DL_FIRST_PLATFORM];
70 static inline int
71 __attribute__ ((unused))
72 _dl_string_hwcap (const char *str)
74 for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i)
75 if (strcmp (str, _dl_hwcap_string (i)) == 0)
76 return i;
77 return -1;
80 static inline int
81 __attribute__ ((unused, always_inline))
82 _dl_string_platform (const char *str)
84 if (str == NULL)
85 return -1;
87 if (strncmp (str, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_POWER4], 5) == 0)
89 int ret;
90 str += 5;
91 switch (*str)
93 case '4':
94 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER4;
95 break;
96 case '5':
97 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER5;
98 if (str[1] == '+')
100 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER5_PLUS;
101 ++str;
103 break;
104 case '6':
105 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER6;
106 if (str[1] == 'x')
108 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER6X;
109 ++str;
111 break;
112 case '7':
113 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER7;
114 break;
115 case '8':
116 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER8;
117 break;
118 default:
119 return -1;
121 if (str[1] == '\0')
122 return ret;
124 else if (strncmp (str, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC970],
125 3) == 0)
127 if (strcmp (str + 3, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC970]
128 + 3) == 0)
129 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC970;
130 else if (strcmp (str + 3,
131 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_CELL_BE] + 3)
132 == 0)
133 return _DL_FIRST_PLATFORM + PPC_PLATFORM_CELL_BE;
134 else if (strcmp (str + 3,
135 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPCA2] + 3)
136 == 0)
137 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPCA2;
138 else if (strcmp (str + 3,
139 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC405] + 3)
140 == 0)
141 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC405;
142 else if (strcmp (str + 3,
143 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC440] + 3)
144 == 0)
145 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC440;
146 else if (strcmp (str + 3,
147 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC464] + 3)
148 == 0)
149 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC464;
150 else if (strcmp (str + 3,
151 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC476] + 3)
152 == 0)
153 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC476;
156 return -1;
159 #ifdef IS_IN_rtld
160 static inline int
161 __attribute__ ((unused))
162 _dl_procinfo (unsigned int type, unsigned long int word)
164 /* Fallback to unknown output mechanism. */
165 if (type == AT_HWCAP2)
166 return -1;
168 _dl_printf ("AT_HWCAP: ");
170 for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i)
171 if (word & (1 << i))
172 _dl_printf (" %s", _dl_hwcap_string (i));
174 _dl_printf ("\n");
176 return 0;
178 #endif
180 #endif /* dl-procinfo.h */