ifunc-impl-list.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Internal header file for __libc_supported_implementations.
  2. Copyright (C) 2012-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  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. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #ifndef _IFUNC_IMPL_LIST_H
  16. #define _IFUNC_IMPL_LIST_H 1
  17. #include <stdbool.h>
  18. #include <stddef.h>
  19. struct libc_ifunc_impl
  20. {
  21. /* The name of function to be tested. */
  22. const char *name;
  23. /* The address of function to be tested. */
  24. void (*fn) (void);
  25. /* True if this implementation is usable on this machine. */
  26. bool usable;
  27. };
  28. /* Add an IFUNC implementation, IMPL, for function FUNC, to ARRAY with
  29. USABLE at index I and advance I by one. */
  30. #define IFUNC_IMPL_ADD(array, max, func, usable, impl) \
  31. extern __typeof (func) impl attribute_hidden; \
  32. if (n < max) (array)[n++] = (struct libc_ifunc_impl) { #impl, (void (*) (void)) impl, (usable) };
  33. /* Return the number of IFUNC implementations, N, for function FUNC if
  34. string NAME matches FUNC. */
  35. #define IFUNC_IMPL(max, name, func, ...) \
  36. if (strcmp (name, #func) == 0) \
  37. { size_t n = 0;\
  38. __VA_ARGS__; \
  39. return n; \
  40. }
  41. /* Fill ARRAY of MAX elements with IFUNC implementations for function
  42. NAME and return the number of valid entries. */
  43. extern size_t __libc_ifunc_impl_list (const char *name,
  44. struct libc_ifunc_impl *array,
  45. size_t max);
  46. #endif /* ifunc-impl-list.h */