ucontext.h 5.3 KB

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