ucontext.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 <features.h>
  18. #include <bits/wordsize.h>
  19. #include <stdint.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. /* 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. 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. unsigned 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 /* __WORDSIZE == 32 */
  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 /* __WORDSIZE == 32 */
  217. #endif /* ucontext.h */