ucontext.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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 _UCONTEXT_H
  16. #define _UCONTEXT_H 1
  17. #include <bits/wordsize.h>
  18. #include <stdint.h>
  19. /* We need the signal context definitions even if they are not used
  20. included in <signal.h>. */
  21. #include <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. /* 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. struct _libc_fpxreg
  80. {
  81. unsigned short int significand[4];
  82. unsigned short int exponent;
  83. unsigned short int padding[3];
  84. };
  85. struct _libc_xmmreg
  86. {
  87. uint32_t element[4];
  88. };
  89. struct _libc_fpstate
  90. {
  91. /* 64-bit FXSAVE format. */
  92. uint16_t cwd;
  93. uint16_t swd;
  94. uint16_t ftw;
  95. uint16_t fop;
  96. uint64_t rip;
  97. uint64_t rdp;
  98. uint32_t mxcsr;
  99. uint32_t mxcr_mask;
  100. struct _libc_fpxreg _st[8];
  101. struct _libc_xmmreg _xmm[16];
  102. uint32_t padding[24];
  103. };
  104. /* Structure to describe FPU registers. */
  105. typedef struct _libc_fpstate *fpregset_t;
  106. /* Context to describe whole processor state. */
  107. typedef struct
  108. {
  109. gregset_t gregs;
  110. /* Note that fpregs is a pointer. */
  111. fpregset_t fpregs;
  112. unsigned long __reserved1 [8];
  113. } mcontext_t;
  114. /* Userlevel context. */
  115. typedef struct ucontext
  116. {
  117. unsigned long int uc_flags;
  118. struct ucontext *uc_link;
  119. stack_t uc_stack;
  120. mcontext_t uc_mcontext;
  121. __sigset_t uc_sigmask;
  122. struct _libc_fpstate __fpregs_mem;
  123. } ucontext_t;
  124. #else /* __WORDSIZE == 32 */
  125. /* Type for general register. */
  126. typedef int greg_t;
  127. /* Number of general registers. */
  128. #define NGREG 19
  129. /* Container for all general registers. */
  130. typedef greg_t gregset_t[NGREG];
  131. #ifdef __USE_GNU
  132. /* Number of each register is the `gregset_t' array. */
  133. enum
  134. {
  135. REG_GS = 0,
  136. # define REG_GS REG_GS
  137. REG_FS,
  138. # define REG_FS REG_FS
  139. REG_ES,
  140. # define REG_ES REG_ES
  141. REG_DS,
  142. # define REG_DS REG_DS
  143. REG_EDI,
  144. # define REG_EDI REG_EDI
  145. REG_ESI,
  146. # define REG_ESI REG_ESI
  147. REG_EBP,
  148. # define REG_EBP REG_EBP
  149. REG_ESP,
  150. # define REG_ESP REG_ESP
  151. REG_EBX,
  152. # define REG_EBX REG_EBX
  153. REG_EDX,
  154. # define REG_EDX REG_EDX
  155. REG_ECX,
  156. # define REG_ECX REG_ECX
  157. REG_EAX,
  158. # define REG_EAX REG_EAX
  159. REG_TRAPNO,
  160. # define REG_TRAPNO REG_TRAPNO
  161. REG_ERR,
  162. # define REG_ERR REG_ERR
  163. REG_EIP,
  164. # define REG_EIP REG_EIP
  165. REG_CS,
  166. # define REG_CS REG_CS
  167. REG_EFL,
  168. # define REG_EFL REG_EFL
  169. REG_UESP,
  170. # define REG_UESP REG_UESP
  171. REG_SS
  172. # define REG_SS REG_SS
  173. };
  174. #endif
  175. /* Definitions taken from the kernel headers. */
  176. struct _libc_fpreg
  177. {
  178. unsigned short int significand[4];
  179. unsigned short int exponent;
  180. };
  181. struct _libc_fpstate
  182. {
  183. unsigned long int cw;
  184. unsigned long int sw;
  185. unsigned long int tag;
  186. unsigned long int ipoff;
  187. unsigned long int cssel;
  188. unsigned long int dataoff;
  189. unsigned long int datasel;
  190. struct _libc_fpreg _st[8];
  191. unsigned long int status;
  192. };
  193. /* Structure to describe FPU registers. */
  194. typedef struct _libc_fpstate *fpregset_t;
  195. /* Context to describe whole processor state. */
  196. typedef struct
  197. {
  198. gregset_t gregs;
  199. /* Due to Linux's history we have to use a pointer here. The SysV/i386
  200. ABI requires a struct with the values. */
  201. fpregset_t fpregs;
  202. unsigned long int oldmask;
  203. unsigned long int cr2;
  204. } mcontext_t;
  205. /* Userlevel context. */
  206. typedef struct ucontext
  207. {
  208. unsigned long int uc_flags;
  209. struct ucontext *uc_link;
  210. stack_t uc_stack;
  211. mcontext_t uc_mcontext;
  212. __sigset_t uc_sigmask;
  213. struct _libc_fpstate __fpregs_mem;
  214. } ucontext_t;
  215. #endif /* __WORDSIZE == 32 */
  216. #endif /* ucontext.h */