1 /* Copyright (C) 2001-2017 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 <http://www.gnu.org/licenses/>. */
18 #ifndef _SYS_UCONTEXT_H
19 #define _SYS_UCONTEXT_H 1
23 #include <bits/types/sigset_t.h>
24 #include <bits/sigcontext.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
144 unsigned long int uc_flags
;
145 struct ucontext
*uc_link
;
147 mcontext_t uc_mcontext
;
149 struct _libc_fpstate __fpregs_mem
;
152 #else /* !__x86_64__ */
154 /* Type for general register. */
157 /* Number of general registers. */
160 # define NGREG __NGREG
163 /* Container for all general registers. */
164 typedef greg_t gregset_t
[__NGREG
];
167 /* Number of each register is the `gregset_t' array. */
171 # define REG_GS REG_GS
173 # define REG_FS REG_FS
175 # define REG_ES REG_ES
177 # define REG_DS REG_DS
179 # define REG_EDI REG_EDI
181 # define REG_ESI REG_ESI
183 # define REG_EBP REG_EBP
185 # define REG_ESP REG_ESP
187 # define REG_EBX REG_EBX
189 # define REG_EDX REG_EDX
191 # define REG_ECX REG_ECX
193 # define REG_EAX REG_EAX
195 # define REG_TRAPNO REG_TRAPNO
197 # define REG_ERR REG_ERR
199 # define REG_EIP REG_EIP
201 # define REG_CS REG_CS
203 # define REG_EFL REG_EFL
205 # define REG_UESP REG_UESP
207 # define REG_SS REG_SS
211 /* Definitions taken from the kernel headers. */
214 unsigned short int __ctx(significand
)[4];
215 unsigned short int __ctx(exponent
);
220 unsigned long int __ctx(cw
);
221 unsigned long int __ctx(sw
);
222 unsigned long int __ctx(tag
);
223 unsigned long int __ctx(ipoff
);
224 unsigned long int __ctx(cssel
);
225 unsigned long int __ctx(dataoff
);
226 unsigned long int __ctx(datasel
);
227 struct _libc_fpreg _st
[8];
228 unsigned long int __ctx(status
);
231 /* Structure to describe FPU registers. */
232 typedef struct _libc_fpstate
*fpregset_t
;
234 /* Context to describe whole processor state. */
237 gregset_t
__ctx(gregs
);
238 /* Due to Linux's history we have to use a pointer here. The SysV/i386
239 ABI requires a struct with the values. */
240 fpregset_t
__ctx(fpregs
);
241 unsigned long int __ctx(oldmask
);
242 unsigned long int __ctx(cr2
);
245 /* Userlevel context. */
246 typedef struct ucontext
248 unsigned long int uc_flags
;
249 struct ucontext
*uc_link
;
251 mcontext_t uc_mcontext
;
253 struct _libc_fpstate __fpregs_mem
;
256 #endif /* !__x86_64__ */
260 #endif /* sys/ucontext.h */