]>
Commit | Line | Data |
---|---|---|
1432d38e | 1 | /* x86 version of hardware capability information handling macros. |
04277e02 | 2 | Copyright (C) 2017-2019 Free Software Foundation, Inc. |
1432d38e L |
3 | |
4 | The GNU C Library is free software; you can redistribute it and/or | |
5 | modify it under the terms of the GNU Lesser General Public | |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the License, or (at your option) any later version. | |
8 | ||
9 | The GNU C Library is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | Lesser General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU Lesser General Public | |
15 | License along with the GNU C Library; if not, see | |
5a82c748 | 16 | <https://www.gnu.org/licenses/>. */ |
1432d38e L |
17 | |
18 | #ifndef _DL_HWCAP_H | |
19 | #define _DL_HWCAP_H | |
20 | ||
21 | #if IS_IN (ldconfig) | |
22 | /* Since ldconfig processes both i386 and x86-64 libraries, it needs | |
23 | to cover all platforms and hardware capabilities. */ | |
24 | # define HWCAP_PLATFORMS_START 0 | |
25 | # define HWCAP_PLATFORMS_COUNT 4 | |
26 | # define HWCAP_START 0 | |
45ff3463 L |
27 | # define HWCAP_COUNT 3 |
28 | # define HWCAP_IMPORTANT \ | |
29 | (HWCAP_X86_SSE2 | HWCAP_X86_64 | HWCAP_X86_AVX512_1) | |
1432d38e L |
30 | #elif defined __x86_64__ |
31 | /* For 64 bit, only cover x86-64 platforms and capabilities. */ | |
32 | # define HWCAP_PLATFORMS_START 2 | |
33 | # define HWCAP_PLATFORMS_COUNT 4 | |
34 | # define HWCAP_START 1 | |
45ff3463 L |
35 | # define HWCAP_COUNT 3 |
36 | # define HWCAP_IMPORTANT (HWCAP_X86_64 | HWCAP_X86_AVX512_1) | |
1432d38e L |
37 | #else |
38 | /* For 32 bit, only cover i586, i686 and SSE2. */ | |
39 | # define HWCAP_PLATFORMS_START 0 | |
40 | # define HWCAP_PLATFORMS_COUNT 2 | |
41 | # define HWCAP_START 0 | |
42 | # define HWCAP_COUNT 1 | |
43 | # define HWCAP_IMPORTANT (HWCAP_X86_SSE2) | |
44 | #endif | |
45 | ||
46 | enum | |
47 | { | |
48 | HWCAP_X86_SSE2 = 1 << 0, | |
45ff3463 L |
49 | HWCAP_X86_64 = 1 << 1, |
50 | HWCAP_X86_AVX512_1 = 1 << 2 | |
1432d38e L |
51 | }; |
52 | ||
53 | static inline const char * | |
54 | __attribute__ ((unused)) | |
55 | _dl_hwcap_string (int idx) | |
56 | { | |
57 | return GLRO(dl_x86_hwcap_flags)[idx]; | |
58 | }; | |
59 | ||
60 | static inline int | |
61 | __attribute__ ((unused, always_inline)) | |
62 | _dl_string_hwcap (const char *str) | |
63 | { | |
64 | int i; | |
65 | ||
66 | for (i = HWCAP_START; i < HWCAP_COUNT; i++) | |
67 | { | |
68 | if (strcmp (str, GLRO(dl_x86_hwcap_flags)[i]) == 0) | |
69 | return i; | |
70 | } | |
71 | return -1; | |
72 | }; | |
73 | ||
74 | /* We cannot provide a general printing function. */ | |
75 | #define _dl_procinfo(type, word) -1 | |
76 | ||
77 | #endif /* dl-hwcap.h */ |