1
0

sigcontext.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Copyright (C) 2002-2026 Free Software Foundation, Inc.
  17. This file is part of the GNU C Library.
  18. The GNU C Library is free software; you can redistribute it and/or
  19. modify it under the terms of the GNU Lesser General Public
  20. License as published by the Free Software Foundation; either
  21. version 2.1 of the License, or (at your option) any later version.
  22. The GNU C Library is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  25. Lesser General Public License for more details.
  26. You should have received a copy of the GNU Lesser General Public
  27. License along with the GNU C Library; if not, see
  28. <https://www.gnu.org/licenses/>. */
  29. #ifndef _BITS_SIGCONTEXT_H
  30. #define _BITS_SIGCONTEXT_H 1
  31. #if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
  32. # error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
  33. #endif
  34. #include <bits/types.h>
  35. #define FP_XSTATE_MAGIC1 0x46505853U
  36. #define FP_XSTATE_MAGIC2 0x46505845U
  37. #define FP_XSTATE_MAGIC2_SIZE sizeof (FP_XSTATE_MAGIC2)
  38. struct _fpx_sw_bytes
  39. {
  40. __uint32_t magic1;
  41. __uint32_t extended_size;
  42. __uint64_t xstate_bv;
  43. __uint32_t xstate_size;
  44. __uint32_t __glibc_reserved1[7];
  45. };
  46. struct _fpreg
  47. {
  48. unsigned short significand[4];
  49. unsigned short exponent;
  50. };
  51. struct _fpxreg
  52. {
  53. unsigned short significand[4];
  54. unsigned short exponent;
  55. unsigned short __glibc_reserved1[3];
  56. };
  57. struct _xmmreg
  58. {
  59. __uint32_t element[4];
  60. };
  61. #ifndef __x86_64__
  62. struct _fpstate
  63. {
  64. /* Regular FPU environment. */
  65. __uint32_t cw;
  66. __uint32_t sw;
  67. __uint32_t tag;
  68. __uint32_t ipoff;
  69. __uint32_t cssel;
  70. __uint32_t dataoff;
  71. __uint32_t datasel;
  72. struct _fpreg _st[8];
  73. unsigned short status;
  74. unsigned short magic;
  75. /* FXSR FPU environment. */
  76. __uint32_t _fxsr_env[6];
  77. __uint32_t mxcsr;
  78. __uint32_t __glibc_reserved1;
  79. struct _fpxreg _fxsr_st[8];
  80. struct _xmmreg _xmm[8];
  81. __uint32_t __glibc_reserved2[56];
  82. };
  83. #ifndef sigcontext_struct
  84. /* Kernel headers before 2.1.1 define a struct sigcontext_struct, but
  85. we need sigcontext. Some packages have come to rely on
  86. sigcontext_struct being defined on 32-bit x86, so define this for
  87. their benefit. */
  88. # define sigcontext_struct sigcontext
  89. #endif
  90. #define X86_FXSR_MAGIC 0x0000
  91. struct sigcontext
  92. {
  93. unsigned short gs, __gsh;
  94. unsigned short fs, __fsh;
  95. unsigned short es, __esh;
  96. unsigned short ds, __dsh;
  97. unsigned long edi;
  98. unsigned long esi;
  99. unsigned long ebp;
  100. unsigned long esp;
  101. unsigned long ebx;
  102. unsigned long edx;
  103. unsigned long ecx;
  104. unsigned long eax;
  105. unsigned long trapno;
  106. unsigned long err;
  107. unsigned long eip;
  108. unsigned short cs, __csh;
  109. unsigned long eflags;
  110. unsigned long esp_at_signal;
  111. unsigned short ss, __ssh;
  112. struct _fpstate * fpstate;
  113. unsigned long oldmask;
  114. unsigned long cr2;
  115. };
  116. #else /* __x86_64__ */
  117. struct _fpstate
  118. {
  119. /* FPU environment matching the 64-bit FXSAVE layout. */
  120. __uint16_t cwd;
  121. __uint16_t swd;
  122. __uint16_t ftw;
  123. __uint16_t fop;
  124. __uint64_t rip;
  125. __uint64_t rdp;
  126. __uint32_t mxcsr;
  127. __uint32_t mxcr_mask;
  128. struct _fpxreg _st[8];
  129. struct _xmmreg _xmm[16];
  130. __uint32_t __glibc_reserved1[24];
  131. };
  132. struct sigcontext
  133. {
  134. __uint64_t r8;
  135. __uint64_t r9;
  136. __uint64_t r10;
  137. __uint64_t r11;
  138. __uint64_t r12;
  139. __uint64_t r13;
  140. __uint64_t r14;
  141. __uint64_t r15;
  142. __uint64_t rdi;
  143. __uint64_t rsi;
  144. __uint64_t rbp;
  145. __uint64_t rbx;
  146. __uint64_t rdx;
  147. __uint64_t rax;
  148. __uint64_t rcx;
  149. __uint64_t rsp;
  150. __uint64_t rip;
  151. __uint64_t eflags;
  152. unsigned short cs;
  153. unsigned short gs;
  154. unsigned short fs;
  155. unsigned short __pad0;
  156. __uint64_t err;
  157. __uint64_t trapno;
  158. __uint64_t oldmask;
  159. __uint64_t cr2;
  160. __extension__ union
  161. {
  162. struct _fpstate * fpstate;
  163. __uint64_t __fpstate_word;
  164. };
  165. __uint64_t __reserved1 [8];
  166. };
  167. #endif /* __x86_64__ */
  168. struct _xsave_hdr
  169. {
  170. __uint64_t xstate_bv;
  171. __uint64_t __glibc_reserved1[2];
  172. __uint64_t __glibc_reserved2[5];
  173. };
  174. struct _ymmh_state
  175. {
  176. __uint32_t ymmh_space[64];
  177. };
  178. struct _xstate
  179. {
  180. struct _fpstate fpstate;
  181. struct _xsave_hdr xstate_hdr;
  182. struct _ymmh_state ymmh;
  183. };
  184. #endif /* _BITS_SIGCONTEXT_H */