Fix infloop in __pthread_disable_asynccancel on x86_64
[glibc.git] / sysdeps / powerpc / dl-procinfo.h
blob254195a94cd4af222ffca6c9b93822a5ba0821b7
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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _DL_PROCINFO_H
21 #define _DL_PROCINFO_H 1
23 #include <ldsodefs.h>
24 #include <sysdep.h> /* This defines the PPC_FEATURE_* macros. */
26 /* There are 25 bits used, but they are bits 7..31. */
27 #define _DL_HWCAP_FIRST 7
28 #define _DL_HWCAP_COUNT 32
30 /* These bits influence library search. */
31 #define HWCAP_IMPORTANT (PPC_FEATURE_HAS_ALTIVEC \
32 + PPC_FEATURE_HAS_DFP)
34 #define _DL_PLATFORMS_COUNT 8
36 #define _DL_FIRST_PLATFORM 32
37 /* Mask to filter out platforms. */
38 #define _DL_HWCAP_PLATFORM (((1ULL << _DL_PLATFORMS_COUNT) - 1) \
39 << _DL_FIRST_PLATFORM)
41 /* Platform bits (relative to _DL_FIRST_PLATFORM). */
42 #define PPC_PLATFORM_POWER4 0
43 #define PPC_PLATFORM_PPC970 1
44 #define PPC_PLATFORM_POWER5 2
45 #define PPC_PLATFORM_POWER5_PLUS 3
46 #define PPC_PLATFORM_POWER6 4
47 #define PPC_PLATFORM_CELL_BE 5
48 #define PPC_PLATFORM_POWER6X 6
49 #define PPC_PLATFORM_POWER7 7
51 static inline const char *
52 __attribute__ ((unused))
53 _dl_hwcap_string (int idx)
55 return GLRO(dl_powerpc_cap_flags)[idx - _DL_HWCAP_FIRST];
58 static inline const char *
59 __attribute__ ((unused))
60 _dl_platform_string (int idx)
62 return GLRO(dl_powerpc_platforms)[idx - _DL_FIRST_PLATFORM];
65 static inline int
66 __attribute__ ((unused))
67 _dl_string_hwcap (const char *str)
69 for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i)
70 if (strcmp (str, _dl_hwcap_string (i)) == 0)
71 return i;
72 return -1;
75 static inline int
76 __attribute__ ((unused, always_inline))
77 _dl_string_platform (const char *str)
79 if (str == NULL)
80 return -1;
82 if (strncmp (str, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_POWER4], 5) == 0)
84 int ret;
85 str += 5;
86 switch (*str)
88 case '4':
89 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER4;
90 break;
91 case '5':
92 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER5;
93 if (str[1] == '+')
95 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER5_PLUS;
96 ++str;
98 break;
99 case '6':
100 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER6;
101 if (str[1] == 'x')
103 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER6X;
104 ++str;
106 break;
107 case '7':
108 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER7;
109 break;
110 default:
111 return -1;
113 if (str[1] == '\0')
114 return ret;
116 else if (strncmp (str, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC970],
117 3) == 0)
119 if (strcmp (str + 3, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC970]
120 + 3) == 0)
121 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC970;
122 else if (strcmp (str + 3,
123 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_CELL_BE] + 3)
124 == 0)
125 return _DL_FIRST_PLATFORM + PPC_PLATFORM_CELL_BE;
128 return -1;
131 #ifdef IS_IN_rtld
132 static inline int
133 __attribute__ ((unused))
134 _dl_procinfo (int word)
136 _dl_printf ("AT_HWCAP: ");
138 for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i)
139 if (word & (1 << i))
140 _dl_printf (" %s", _dl_hwcap_string (i));
142 _dl_printf ("\n");
144 return 0;
146 #endif
148 #endif /* dl-procinfo.h */