ucontext.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /* Copyright (C) 2001-2016 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. <http://www.gnu.org/licenses/>. */
  14. #ifndef _SYS_UCONTEXT_H
  15. #define _SYS_UCONTEXT_H 1
  16. #include <features.h>
  17. #include <signal.h>
  18. /* We need the signal context definitions even if they are not used
  19. included in <signal.h>. */
  20. #include <bits/sigcontext.h>
  21. #ifdef __x86_64__
  22. /* Type for general register. */
  23. __extension__ typedef long long int greg_t;
  24. /* Number of general registers. */
  25. #define NGREG 23
  26. /* Container for all general registers. */
  27. typedef greg_t gregset_t[NGREG];
  28. #ifdef __USE_GNU
  29. /* Number of each register in the `gregset_t' array. */
  30. enum
  31. {
  32. REG_R8 = 0,
  33. # define REG_R8 REG_R8
  34. REG_R9,
  35. # define REG_R9 REG_R9
  36. REG_R10,
  37. # define REG_R10 REG_R10
  38. REG_R11,
  39. # define REG_R11 REG_R11
  40. REG_R12,
  41. # define REG_R12 REG_R12
  42. REG_R13,
  43. # define REG_R13 REG_R13
  44. REG_R14,
  45. # define REG_R14 REG_R14
  46. REG_R15,
  47. # define REG_R15 REG_R15
  48. REG_RDI,
  49. # define REG_RDI REG_RDI
  50. REG_RSI,
  51. # define REG_RSI REG_RSI
  52. REG_RBP,
  53. # define REG_RBP REG_RBP
  54. REG_RBX,
  55. # define REG_RBX REG_RBX
  56. REG_RDX,
  57. # define REG_RDX REG_RDX
  58. REG_RAX,
  59. # define REG_RAX REG_RAX
  60. REG_RCX,
  61. # define REG_RCX REG_RCX
  62. REG_RSP,
  63. # define REG_RSP REG_RSP
  64. REG_RIP,
  65. # define REG_RIP REG_RIP
  66. REG_EFL,
  67. # define REG_EFL REG_EFL
  68. REG_CSGSFS, /* Actually short cs, gs, fs, __pad0. */
  69. # define REG_CSGSFS REG_CSGSFS
  70. REG_ERR,
  71. # define REG_ERR REG_ERR
  72. REG_TRAPNO,
  73. # define REG_TRAPNO REG_TRAPNO
  74. REG_OLDMASK,
  75. # define REG_OLDMASK REG_OLDMASK
  76. REG_CR2
  77. # define REG_CR2 REG_CR2
  78. };
  79. #endif
  80. struct _libc_fpxreg
  81. {
  82. unsigned short int significand[4];
  83. unsigned short int exponent;
  84. unsigned short int padding[3];
  85. };
  86. struct _libc_xmmreg
  87. {
  88. __uint32_t element[4];
  89. };
  90. struct _libc_fpstate
  91. {
  92. /* 64-bit FXSAVE format. */
  93. __uint16_t cwd;
  94. __uint16_t swd;
  95. __uint16_t ftw;
  96. __uint16_t fop;
  97. __uint64_t rip;
  98. __uint64_t rdp;
  99. __uint32_t mxcsr;
  100. __uint32_t mxcr_mask;
  101. struct _libc_fpxreg _st[8];
  102. struct _libc_xmmreg _xmm[16];
  103. __uint32_t padding[24];
  104. };
  105. /* Structure to describe FPU registers. */
  106. typedef struct _libc_fpstate *fpregset_t;
  107. /* Context to describe whole processor state. */
  108. typedef struct
  109. {
  110. gregset_t gregs;
  111. /* Note that fpregs is a pointer. */
  112. fpregset_t fpregs;
  113. __extension__ unsigned long long __reserved1 [8];
  114. } mcontext_t;
  115. /* Userlevel context. */
  116. typedef struct ucontext
  117. {
  118. unsigned long int uc_flags;
  119. struct ucontext *uc_link;
  120. stack_t uc_stack;
  121. mcontext_t uc_mcontext;
  122. __sigset_t uc_sigmask;
  123. struct _libc_fpstate __fpregs_mem;
  124. } ucontext_t;
  125. #else /* !__x86_64__ */
  126. /* Type for general register. */
  127. typedef int greg_t;
  128. /* Number of general registers. */
  129. #define NGREG 19
  130. /* Container for all general registers. */
  131. typedef greg_t gregset_t[NGREG];
  132. #ifdef __USE_GNU
  133. /* Number of each register is the `gregset_t' array. */
  134. enum
  135. {
  136. REG_GS = 0,
  137. # define REG_GS REG_GS
  138. REG_FS,
  139. # define REG_FS REG_FS
  140. REG_ES,
  141. # define REG_ES REG_ES
  142. REG_DS,
  143. # define REG_DS REG_DS
  144. REG_EDI,
  145. # define REG_EDI REG_EDI
  146. REG_ESI,
  147. # define REG_ESI REG_ESI
  148. REG_EBP,
  149. # define REG_EBP REG_EBP
  150. REG_ESP,
  151. # define REG_ESP REG_ESP
  152. REG_EBX,
  153. # define REG_EBX REG_EBX
  154. REG_EDX,
  155. # define REG_EDX REG_EDX
  156. REG_ECX,
  157. # define REG_ECX REG_ECX
  158. REG_EAX,
  159. # define REG_EAX REG_EAX
  160. REG_TRAPNO,
  161. # define REG_TRAPNO REG_TRAPNO
  162. REG_ERR,
  163. # define REG_ERR REG_ERR
  164. REG_EIP,
  165. # define REG_EIP REG_EIP
  166. REG_CS,
  167. # define REG_CS REG_CS
  168. REG_EFL,
  169. # define REG_EFL REG_EFL
  170. REG_UESP,
  171. # define REG_UESP REG_UESP
  172. REG_SS
  173. # define REG_SS REG_SS
  174. };
  175. #endif
  176. /* Definitions taken from the kernel headers. */
  177. struct _libc_fpreg
  178. {
  179. unsigned short int significand[4];
  180. unsigned short int exponent;
  181. };
  182. struct _libc_fpstate
  183. {
  184. unsigned long int cw;
  185. unsigned long int sw;
  186. unsigned long int tag;
  187. unsigned long int ipoff;
  188. unsigned long int cssel;
  189. unsigned long int dataoff;
  190. unsigned long int datasel;
  191. struct _libc_fpreg _st[8];
  192. unsigned long int status;
  193. };
  194. /* Structure to describe FPU registers. */
  195. typedef struct _libc_fpstate *fpregset_t;
  196. /* Context to describe whole processor state. */
  197. typedef struct
  198. {
  199. gregset_t gregs;
  200. /* Due to Linux's history we have to use a pointer here. The SysV/i386
  201. ABI requires a struct with the values. */
  202. fpregset_t fpregs;
  203. unsigned long int oldmask;
  204. unsigned long int cr2;
  205. } mcontext_t;
  206. /* Userlevel context. */
  207. typedef struct ucontext
  208. {
  209. unsigned long int uc_flags;
  210. struct ucontext *uc_link;
  211. stack_t uc_stack;
  212. mcontext_t uc_mcontext;
  213. __sigset_t uc_sigmask;
  214. struct _libc_fpstate __fpregs_mem;
  215. } ucontext_t;
  216. #endif /* !__x86_64__ */
  217. #endif /* sys/ucontext.h */