1 /* Copyright (C) 2001-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
18 #ifndef _SYS_UCONTEXT_H
19 #define _SYS_UCONTEXT_H 1
23 #include <bits/types.h>
24 #include <bits/types/sigset_t.h>
25 #include <bits/types/stack_t.h>
29 # define __ctx(fld) fld
31 # define __ctx(fld) __ ## fld
36 /* Type for general register. */
37 __extension__
typedef long long int greg_t
;
39 /* Number of general registers. */
42 # define NGREG __NGREG
45 /* Container for all general registers. */
46 typedef greg_t gregset_t
[__NGREG
];
49 /* Number of each register in the `gregset_t' array. */
53 # define REG_R8 REG_R8
55 # define REG_R9 REG_R9
57 # define REG_R10 REG_R10
59 # define REG_R11 REG_R11
61 # define REG_R12 REG_R12
63 # define REG_R13 REG_R13
65 # define REG_R14 REG_R14
67 # define REG_R15 REG_R15
69 # define REG_RDI REG_RDI
71 # define REG_RSI REG_RSI
73 # define REG_RBP REG_RBP
75 # define REG_RBX REG_RBX
77 # define REG_RDX REG_RDX
79 # define REG_RAX REG_RAX
81 # define REG_RCX REG_RCX
83 # define REG_RSP REG_RSP
85 # define REG_RIP REG_RIP
87 # define REG_EFL REG_EFL
88 REG_CSGSFS
, /* Actually short cs, gs, fs, __pad0. */
89 # define REG_CSGSFS REG_CSGSFS
91 # define REG_ERR REG_ERR
93 # define REG_TRAPNO REG_TRAPNO
95 # define REG_OLDMASK REG_OLDMASK
97 # define REG_CR2 REG_CR2
103 unsigned short int __ctx(significand
)[4];
104 unsigned short int __ctx(exponent
);
105 unsigned short int __glibc_reserved1
[3];
110 __uint32_t
__ctx(element
)[4];
115 /* 64-bit FXSAVE format. */
116 __uint16_t
__ctx(cwd
);
117 __uint16_t
__ctx(swd
);
118 __uint16_t
__ctx(ftw
);
119 __uint16_t
__ctx(fop
);
120 __uint64_t
__ctx(rip
);
121 __uint64_t
__ctx(rdp
);
122 __uint32_t
__ctx(mxcsr
);
123 __uint32_t
__ctx(mxcr_mask
);
124 struct _libc_fpxreg _st
[8];
125 struct _libc_xmmreg _xmm
[16];
126 __uint32_t __glibc_reserved1
[24];
129 /* Structure to describe FPU registers. */
130 typedef struct _libc_fpstate
*fpregset_t
;
132 /* Context to describe whole processor state. */
135 gregset_t
__ctx(gregs
);
136 /* Note that fpregs is a pointer. */
137 fpregset_t
__ctx(fpregs
);
138 __extension__
unsigned long long __reserved1
[8];
141 /* Userlevel context. */
142 typedef struct ucontext_t
144 unsigned long int __ctx(uc_flags
);
145 struct ucontext_t
*uc_link
;
147 mcontext_t uc_mcontext
;
149 struct _libc_fpstate __fpregs_mem
;
150 __extension__
unsigned long long int __ssp
[4];
153 #else /* !__x86_64__ */
155 /* Type for general register. */
158 /* Number of general registers. */
161 # define NGREG __NGREG
164 /* Container for all general registers. */
165 typedef greg_t gregset_t
[__NGREG
];
168 /* Number of each register is the `gregset_t' array. */
172 # define REG_GS REG_GS
174 # define REG_FS REG_FS
176 # define REG_ES REG_ES
178 # define REG_DS REG_DS
180 # define REG_EDI REG_EDI
182 # define REG_ESI REG_ESI
184 # define REG_EBP REG_EBP
186 # define REG_ESP REG_ESP
188 # define REG_EBX REG_EBX
190 # define REG_EDX REG_EDX
192 # define REG_ECX REG_ECX
194 # define REG_EAX REG_EAX
196 # define REG_TRAPNO REG_TRAPNO
198 # define REG_ERR REG_ERR
200 # define REG_EIP REG_EIP
202 # define REG_CS REG_CS
204 # define REG_EFL REG_EFL
206 # define REG_UESP REG_UESP
208 # define REG_SS REG_SS
212 /* Definitions taken from the kernel headers. */
215 unsigned short int __ctx(significand
)[4];
216 unsigned short int __ctx(exponent
);
221 unsigned long int __ctx(cw
);
222 unsigned long int __ctx(sw
);
223 unsigned long int __ctx(tag
);
224 unsigned long int __ctx(ipoff
);
225 unsigned long int __ctx(cssel
);
226 unsigned long int __ctx(dataoff
);
227 unsigned long int __ctx(datasel
);
228 struct _libc_fpreg _st
[8];
229 unsigned long int __ctx(status
);
232 /* Structure to describe FPU registers. */
233 typedef struct _libc_fpstate
*fpregset_t
;
235 /* Context to describe whole processor state. */
238 gregset_t
__ctx(gregs
);
239 /* Due to Linux's history we have to use a pointer here. The SysV/i386
240 ABI requires a struct with the values. */
241 fpregset_t
__ctx(fpregs
);
242 unsigned long int __ctx(oldmask
);
243 unsigned long int __ctx(cr2
);
246 /* Userlevel context. */
247 typedef struct ucontext_t
249 unsigned long int __ctx(uc_flags
);
250 struct ucontext_t
*uc_link
;
252 mcontext_t uc_mcontext
;
254 struct _libc_fpstate __fpregs_mem
;
255 unsigned long int __ssp
[4];
258 #endif /* !__x86_64__ */
262 #endif /* sys/ucontext.h */