ucontext.h 5.3 KB

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