test-xstate.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Helpers to test XSTATE during signal handling
  2. Copyright (C) 2025-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 _TEST_XSTATE_H
  16. #define _TEST_XSTATE_H
  17. #if defined __x86_64__ || defined __i386__
  18. #define XSTATE_HELPERS_SUPPORTED 1
  19. #define MMXSTATE_BUFFER_SIZE 8
  20. #define XSTATE_BUFFER_SIZE 16
  21. #define SET_MMXSTATE(b) do { \
  22. asm volatile ("movq (%0),%%mm0" :: "r" (b)); \
  23. } while (0)
  24. #define SET_XSTATE(b) do { \
  25. asm volatile ("movups (%0),%%xmm0" :: "r" (b)); \
  26. } while (0)
  27. #define GET_MMXSTATE(b) do { \
  28. asm volatile ("movq %%mm0,(%0)" :: "r" (b)); \
  29. } while (0)
  30. #define GET_XSTATE(b) do { \
  31. asm volatile ("movups %%xmm0,(%0)" :: "r" (b)); \
  32. } while (0)
  33. #else
  34. #define XSTATE_HELPERS_SUPPORTED 0
  35. #define MMXSTATE_BUFFER_SIZE 1
  36. #define XSTATE_BUFFER_SIZE 1
  37. #define SET_XSTATE(b)
  38. #endif
  39. #endif /* _TEST_XSTATE_H */