dl-hwcap.h 2.2 KB

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