ucontext.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* Copyright (C) 2001-2026 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. <https://www.gnu.org/licenses/>. */
  14. #ifndef _SYS_UCONTEXT_H
  15. #define _SYS_UCONTEXT_H 1
  16. #include <features.h>
  17. #include <bits/types.h>
  18. #include <bits/types/sigset_t.h>
  19. #include <bits/types/stack_t.h>
  20. #ifdef __USE_MISC
  21. # define __ctx(fld) fld
  22. #else
  23. # define __ctx(fld) __ ## fld
  24. #endif
  25. /* Type for general register. */
  26. __extension__ typedef long long int greg_t;
  27. /* Number of general registers. */
  28. #define __NGREG 23
  29. #ifdef __USE_MISC
  30. # define NGREG __NGREG
  31. #endif
  32. /* Container for all general registers. */
  33. typedef greg_t gregset_t[__NGREG];
  34. #ifdef __USE_GNU
  35. /* Number of each register in the `gregset_t' array. */
  36. enum
  37. {
  38. REG_R8 = 0,
  39. # define REG_R8 REG_R8
  40. REG_R9,
  41. # define REG_R9 REG_R9
  42. REG_R10,
  43. # define REG_R10 REG_R10
  44. REG_R11,
  45. # define REG_R11 REG_R11
  46. REG_R12,
  47. # define REG_R12 REG_R12
  48. REG_R13,
  49. # define REG_R13 REG_R13
  50. REG_R14,
  51. # define REG_R14 REG_R14
  52. REG_R15,
  53. # define REG_R15 REG_R15
  54. REG_RDI,
  55. # define REG_RDI REG_RDI
  56. REG_RSI,
  57. # define REG_RSI REG_RSI
  58. REG_RBP,
  59. # define REG_RBP REG_RBP
  60. REG_RSP,
  61. # define REG_RSP REG_RSP
  62. REG_RBX,
  63. # define REG_RBX REG_RBX
  64. REG_RDX,
  65. # define REG_RDX REG_RDX
  66. REG_RCX,
  67. # define REG_RCX REG_RCX
  68. REG_RAX,
  69. # define REG_RAX REG_RAX
  70. REG_RIP,
  71. # define REG_RIP REG_RIP
  72. REG_CS, /* Actually int cs, pad. */
  73. # define REG_CS REG_CS
  74. REG_RFL,
  75. # define REG_RFL REG_RFL
  76. REG_ERR,
  77. # define REG_ERR REG_ERR
  78. REG_TRAPNO,
  79. # define REG_TRAPNO REG_TRAPNO
  80. REG_OLDMASK,
  81. # define REG_OLDMASK REG_OLDMASK
  82. REG_CR2
  83. # define REG_CR2 REG_CR2
  84. };
  85. #endif
  86. struct _libc_fpxreg
  87. {
  88. unsigned short int __ctx(significand)[4];
  89. unsigned short int __ctx(exponent);
  90. unsigned short int __glibc_reserved1[3];
  91. };
  92. struct _libc_xmmreg
  93. {
  94. __uint32_t __ctx(element)[4];
  95. };
  96. struct _libc_fpstate
  97. {
  98. /* 64-bit FXSAVE format. */
  99. __uint16_t __ctx(cwd);
  100. __uint16_t __ctx(swd);
  101. __uint16_t __ctx(ftw);
  102. __uint16_t __ctx(fop);
  103. __uint64_t __ctx(rip);
  104. __uint64_t __ctx(rdp);
  105. __uint32_t __ctx(mxcsr);
  106. __uint32_t __ctx(mxcr_mask);
  107. struct _libc_fpxreg _st[8];
  108. struct _libc_xmmreg _xmm[16];
  109. __uint32_t __glibc_reserved1[24];
  110. };
  111. /* Structure to describe FPU registers. */
  112. typedef struct _libc_fpstate *fpregset_t;
  113. /* Context to describe whole processor state. */
  114. typedef struct
  115. {
  116. gregset_t __ctx(gregs);
  117. /* Note that fpregs is a pointer. */
  118. fpregset_t __ctx(fpregs);
  119. __extension__ unsigned long long __reserved1 [8];
  120. } mcontext_t;
  121. /* Userlevel context. */
  122. typedef struct ucontext_t
  123. {
  124. unsigned long int __ctx(uc_flags);
  125. struct ucontext_t *uc_link;
  126. stack_t uc_stack;
  127. mcontext_t uc_mcontext;
  128. sigset_t uc_sigmask;
  129. struct _libc_fpstate __fpregs_mem;
  130. __extension__ unsigned long long int __ssp[4];
  131. } ucontext_t;
  132. #undef __ctx
  133. #endif /* sys/ucontext.h */