sigcontext.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /* Copyright (C) 2002-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  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. <https://www.gnu.org/licenses/>. */
  14. #ifndef _BITS_SIGCONTEXT_H
  15. #define _BITS_SIGCONTEXT_H 1
  16. #if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
  17. # error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
  18. #endif
  19. #include <bits/types.h>
  20. #define FP_XSTATE_MAGIC1 0x46505853U
  21. #define FP_XSTATE_MAGIC2 0x46505845U
  22. #define FP_XSTATE_MAGIC2_SIZE sizeof (FP_XSTATE_MAGIC2)
  23. struct _fpx_sw_bytes
  24. {
  25. __uint32_t magic1;
  26. __uint32_t extended_size;
  27. __uint64_t xstate_bv;
  28. __uint32_t xstate_size;
  29. __uint32_t __glibc_reserved1[7];
  30. };
  31. struct _fpreg
  32. {
  33. unsigned short significand[4];
  34. unsigned short exponent;
  35. };
  36. struct _fpxreg
  37. {
  38. unsigned short significand[4];
  39. unsigned short exponent;
  40. unsigned short __glibc_reserved1[3];
  41. };
  42. struct _xmmreg
  43. {
  44. __uint32_t element[4];
  45. };
  46. #ifndef __x86_64__
  47. struct _fpstate
  48. {
  49. /* Regular FPU environment. */
  50. __uint32_t cw;
  51. __uint32_t sw;
  52. __uint32_t tag;
  53. __uint32_t ipoff;
  54. __uint32_t cssel;
  55. __uint32_t dataoff;
  56. __uint32_t datasel;
  57. struct _fpreg _st[8];
  58. unsigned short status;
  59. unsigned short magic;
  60. /* FXSR FPU environment. */
  61. __uint32_t _fxsr_env[6];
  62. __uint32_t mxcsr;
  63. __uint32_t __glibc_reserved1;
  64. struct _fpxreg _fxsr_st[8];
  65. struct _xmmreg _xmm[8];
  66. __uint32_t __glibc_reserved2[56];
  67. };
  68. #ifndef sigcontext_struct
  69. /* Kernel headers before 2.1.1 define a struct sigcontext_struct, but
  70. we need sigcontext. Some packages have come to rely on
  71. sigcontext_struct being defined on 32-bit x86, so define this for
  72. their benefit. */
  73. # define sigcontext_struct sigcontext
  74. #endif
  75. #define X86_FXSR_MAGIC 0x0000
  76. struct sigcontext
  77. {
  78. unsigned short gs, __gsh;
  79. unsigned short fs, __fsh;
  80. unsigned short es, __esh;
  81. unsigned short ds, __dsh;
  82. unsigned long edi;
  83. unsigned long esi;
  84. unsigned long ebp;
  85. unsigned long esp;
  86. unsigned long ebx;
  87. unsigned long edx;
  88. unsigned long ecx;
  89. unsigned long eax;
  90. unsigned long trapno;
  91. unsigned long err;
  92. unsigned long eip;
  93. unsigned short cs, __csh;
  94. unsigned long eflags;
  95. unsigned long esp_at_signal;
  96. unsigned short ss, __ssh;
  97. struct _fpstate * fpstate;
  98. unsigned long oldmask;
  99. unsigned long cr2;
  100. };
  101. #else /* __x86_64__ */
  102. struct _fpstate
  103. {
  104. /* FPU environment matching the 64-bit FXSAVE layout. */
  105. __uint16_t cwd;
  106. __uint16_t swd;
  107. __uint16_t ftw;
  108. __uint16_t fop;
  109. __uint64_t rip;
  110. __uint64_t rdp;
  111. __uint32_t mxcsr;
  112. __uint32_t mxcr_mask;
  113. struct _fpxreg _st[8];
  114. struct _xmmreg _xmm[16];
  115. __uint32_t __glibc_reserved1[24];
  116. };
  117. struct sigcontext
  118. {
  119. __uint64_t r8;
  120. __uint64_t r9;
  121. __uint64_t r10;
  122. __uint64_t r11;
  123. __uint64_t r12;
  124. __uint64_t r13;
  125. __uint64_t r14;
  126. __uint64_t r15;
  127. __uint64_t rdi;
  128. __uint64_t rsi;
  129. __uint64_t rbp;
  130. __uint64_t rbx;
  131. __uint64_t rdx;
  132. __uint64_t rax;
  133. __uint64_t rcx;
  134. __uint64_t rsp;
  135. __uint64_t rip;
  136. __uint64_t eflags;
  137. unsigned short cs;
  138. unsigned short gs;
  139. unsigned short fs;
  140. unsigned short __pad0;
  141. __uint64_t err;
  142. __uint64_t trapno;
  143. __uint64_t oldmask;
  144. __uint64_t cr2;
  145. __extension__ union
  146. {
  147. struct _fpstate * fpstate;
  148. __uint64_t __fpstate_word;
  149. };
  150. __uint64_t __reserved1 [8];
  151. };
  152. #endif /* __x86_64__ */
  153. struct _xsave_hdr
  154. {
  155. __uint64_t xstate_bv;
  156. __uint64_t __glibc_reserved1[2];
  157. __uint64_t __glibc_reserved2[5];
  158. };
  159. struct _ymmh_state
  160. {
  161. __uint32_t ymmh_space[64];
  162. };
  163. struct _xstate
  164. {
  165. struct _fpstate fpstate;
  166. struct _xsave_hdr xstate_hdr;
  167. struct _ymmh_state ymmh;
  168. };
  169. #endif /* _BITS_SIGCONTEXT_H */