| 1 | /* x86 version of hardware capability information handling macros. |
| 2 | Copyright (C) 2017 Free Software Foundation, Inc. |
| 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 |
| 16 | <http://www.gnu.org/licenses/>. */ |
| 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 |
| 27 | # define HWCAP_COUNT 2 |
| 28 | # define HWCAP_IMPORTANT (HWCAP_X86_SSE2 | HWCAP_X86_AVX512_1) |
| 29 | #elif defined __x86_64__ |
| 30 | /* For 64 bit, only cover x86-64 platforms and capabilities. */ |
| 31 | # define HWCAP_PLATFORMS_START 2 |
| 32 | # define HWCAP_PLATFORMS_COUNT 4 |
| 33 | # define HWCAP_START 1 |
| 34 | # define HWCAP_COUNT 2 |
| 35 | # define HWCAP_IMPORTANT (HWCAP_X86_AVX512_1) |
| 36 | #else |
| 37 | /* For 32 bit, only cover i586, i686 and SSE2. */ |
| 38 | # define HWCAP_PLATFORMS_START 0 |
| 39 | # define HWCAP_PLATFORMS_COUNT 2 |
| 40 | # define HWCAP_START 0 |
| 41 | # define HWCAP_COUNT 1 |
| 42 | # define HWCAP_IMPORTANT (HWCAP_X86_SSE2) |
| 43 | #endif |
| 44 | |
| 45 | enum |
| 46 | { |
| 47 | HWCAP_X86_SSE2 = 1 << 0, |
| 48 | HWCAP_X86_AVX512_1 = 1 << 1 |
| 49 | }; |
| 50 | |
| 51 | static inline const char * |
| 52 | __attribute__ ((unused)) |
| 53 | _dl_hwcap_string (int idx) |
| 54 | { |
| 55 | return GLRO(dl_x86_hwcap_flags)[idx]; |
| 56 | }; |
| 57 | |
| 58 | static inline int |
| 59 | __attribute__ ((unused, always_inline)) |
| 60 | _dl_string_hwcap (const char *str) |
| 61 | { |
| 62 | int i; |
| 63 | |
| 64 | for (i = HWCAP_START; i < HWCAP_COUNT; i++) |
| 65 | { |
| 66 | if (strcmp (str, GLRO(dl_x86_hwcap_flags)[i]) == 0) |
| 67 | return i; |
| 68 | } |
| 69 | return -1; |
| 70 | }; |
| 71 | |
| 72 | /* We cannot provide a general printing function. */ |
| 73 | #define _dl_procinfo(type, word) -1 |
| 74 | |
| 75 | #endif /* dl-hwcap.h */ |
| 76 | |