]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/x86/sys/ucontext.h
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / x86 / sys / ucontext.h
CommitLineData
2b778ceb 1/* Copyright (C) 2001-2021 Free Software Foundation, Inc.
c9cf6dde
AJ
2 This file is part of the GNU C Library.
3
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.
8
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.
13
14 You should have received a copy of the GNU Lesser General Public
59ba27a6 15 License along with the GNU C Library; if not, see
5a82c748 16 <https://www.gnu.org/licenses/>. */
c9cf6dde
AJ
17
18#ifndef _SYS_UCONTEXT_H
19#define _SYS_UCONTEXT_H 1
20
21#include <features.h>
c9cf6dde 22
4fa9b3bf 23#include <bits/types.h>
cfed8ece 24#include <bits/types/sigset_t.h>
0bcec532 25#include <bits/types/stack_t.h>
c66b29f9 26
c9cf6dde 27
139904b7
JM
28#ifdef __USE_MISC
29# define __ctx(fld) fld
30#else
31# define __ctx(fld) __ ## fld
32#endif
33
d5e05119 34#ifdef __x86_64__
30ee7c7b 35
c9cf6dde 36/* Type for general register. */
d5e05119 37__extension__ typedef long long int greg_t;
c9cf6dde
AJ
38
39/* Number of general registers. */
139904b7
JM
40#define __NGREG 23
41#ifdef __USE_MISC
42# define NGREG __NGREG
43#endif
c9cf6dde
AJ
44
45/* Container for all general registers. */
139904b7 46typedef greg_t gregset_t[__NGREG];
c9cf6dde
AJ
47
48#ifdef __USE_GNU
49/* Number of each register in the `gregset_t' array. */
50enum
51{
30ee7c7b 52 REG_R8 = 0,
c9cf6dde
AJ
53# define REG_R8 REG_R8
54 REG_R9,
55# define REG_R9 REG_R9
56 REG_R10,
57# define REG_R10 REG_R10
58 REG_R11,
59# define REG_R11 REG_R11
60 REG_R12,
61# define REG_R12 REG_R12
62 REG_R13,
63# define REG_R13 REG_R13
64 REG_R14,
65# define REG_R14 REG_R14
66 REG_R15,
67# define REG_R15 REG_R15
68 REG_RDI,
69# define REG_RDI REG_RDI
70 REG_RSI,
71# define REG_RSI REG_RSI
72 REG_RBP,
73# define REG_RBP REG_RBP
c9cf6dde
AJ
74 REG_RBX,
75# define REG_RBX REG_RBX
76 REG_RDX,
77# define REG_RDX REG_RDX
c9cf6dde
AJ
78 REG_RAX,
79# define REG_RAX REG_RAX
30ee7c7b
AJ
80 REG_RCX,
81# define REG_RCX REG_RCX
82 REG_RSP,
83# define REG_RSP REG_RSP
84 REG_RIP,
85# define REG_RIP REG_RIP
86 REG_EFL,
87# define REG_EFL REG_EFL
46a1b875
AJ
88 REG_CSGSFS, /* Actually short cs, gs, fs, __pad0. */
89# define REG_CSGSFS REG_CSGSFS
30ee7c7b
AJ
90 REG_ERR,
91# define REG_ERR REG_ERR
09b4d75f 92 REG_TRAPNO,
30ee7c7b 93# define REG_TRAPNO REG_TRAPNO
09b4d75f
AJ
94 REG_OLDMASK,
95# define REG_OLDMASK REG_OLDMASK
96 REG_CR2
97# define REG_CR2 REG_CR2
30ee7c7b
AJ
98};
99#endif
100
101struct _libc_fpxreg
102{
139904b7
JM
103 unsigned short int __ctx(significand)[4];
104 unsigned short int __ctx(exponent);
fd9f30f6 105 unsigned short int __glibc_reserved1[3];
30ee7c7b
AJ
106};
107
108struct _libc_xmmreg
109{
487549c4 110 __uint32_t __ctx(element)[4];
30ee7c7b
AJ
111};
112
113struct _libc_fpstate
114{
115 /* 64-bit FXSAVE format. */
139904b7
JM
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);
30ee7c7b
AJ
124 struct _libc_fpxreg _st[8];
125 struct _libc_xmmreg _xmm[16];
fd9f30f6 126 __uint32_t __glibc_reserved1[24];
30ee7c7b
AJ
127};
128
129/* Structure to describe FPU registers. */
130typedef struct _libc_fpstate *fpregset_t;
131
132/* Context to describe whole processor state. */
133typedef struct
134 {
139904b7 135 gregset_t __ctx(gregs);
30ee7c7b 136 /* Note that fpregs is a pointer. */
139904b7 137 fpregset_t __ctx(fpregs);
d5e05119 138 __extension__ unsigned long long __reserved1 [8];
30ee7c7b
AJ
139} mcontext_t;
140
141/* Userlevel context. */
25128773 142typedef struct ucontext_t
30ee7c7b 143 {
3d452dab 144 unsigned long int __ctx(uc_flags);
25128773 145 struct ucontext_t *uc_link;
30ee7c7b
AJ
146 stack_t uc_stack;
147 mcontext_t uc_mcontext;
cfed8ece 148 sigset_t uc_sigmask;
30ee7c7b 149 struct _libc_fpstate __fpregs_mem;
25123a1c 150 __extension__ unsigned long long int __ssp[4];
30ee7c7b
AJ
151 } ucontext_t;
152
d5e05119 153#else /* !__x86_64__ */
30ee7c7b
AJ
154
155/* Type for general register. */
156typedef int greg_t;
157
158/* Number of general registers. */
139904b7
JM
159#define __NGREG 19
160#ifdef __USE_MISC
161# define NGREG __NGREG
162#endif
30ee7c7b
AJ
163
164/* Container for all general registers. */
139904b7 165typedef greg_t gregset_t[__NGREG];
30ee7c7b
AJ
166
167#ifdef __USE_GNU
168/* Number of each register is the `gregset_t' array. */
169enum
170{
171 REG_GS = 0,
172# define REG_GS REG_GS
173 REG_FS,
174# define REG_FS REG_FS
175 REG_ES,
176# define REG_ES REG_ES
177 REG_DS,
178# define REG_DS REG_DS
179 REG_EDI,
180# define REG_EDI REG_EDI
181 REG_ESI,
182# define REG_ESI REG_ESI
183 REG_EBP,
184# define REG_EBP REG_EBP
185 REG_ESP,
186# define REG_ESP REG_ESP
187 REG_EBX,
188# define REG_EBX REG_EBX
189 REG_EDX,
190# define REG_EDX REG_EDX
191 REG_ECX,
192# define REG_ECX REG_ECX
193 REG_EAX,
194# define REG_EAX REG_EAX
c9cf6dde
AJ
195 REG_TRAPNO,
196# define REG_TRAPNO REG_TRAPNO
197 REG_ERR,
198# define REG_ERR REG_ERR
30ee7c7b
AJ
199 REG_EIP,
200# define REG_EIP REG_EIP
c9cf6dde
AJ
201 REG_CS,
202# define REG_CS REG_CS
203 REG_EFL,
204# define REG_EFL REG_EFL
30ee7c7b
AJ
205 REG_UESP,
206# define REG_UESP REG_UESP
c9cf6dde
AJ
207 REG_SS
208# define REG_SS REG_SS
209};
210#endif
211
212/* Definitions taken from the kernel headers. */
213struct _libc_fpreg
214{
139904b7
JM
215 unsigned short int __ctx(significand)[4];
216 unsigned short int __ctx(exponent);
c9cf6dde
AJ
217};
218
c9cf6dde
AJ
219struct _libc_fpstate
220{
139904b7
JM
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);
30ee7c7b 228 struct _libc_fpreg _st[8];
139904b7 229 unsigned long int __ctx(status);
c9cf6dde
AJ
230};
231
232/* Structure to describe FPU registers. */
30ee7c7b 233typedef struct _libc_fpstate *fpregset_t;
c9cf6dde
AJ
234
235/* Context to describe whole processor state. */
236typedef struct
237 {
139904b7 238 gregset_t __ctx(gregs);
30ee7c7b
AJ
239 /* Due to Linux's history we have to use a pointer here. The SysV/i386
240 ABI requires a struct with the values. */
139904b7
JM
241 fpregset_t __ctx(fpregs);
242 unsigned long int __ctx(oldmask);
243 unsigned long int __ctx(cr2);
c9cf6dde
AJ
244 } mcontext_t;
245
246/* Userlevel context. */
25128773 247typedef struct ucontext_t
c9cf6dde 248 {
3d452dab 249 unsigned long int __ctx(uc_flags);
25128773 250 struct ucontext_t *uc_link;
c9cf6dde
AJ
251 stack_t uc_stack;
252 mcontext_t uc_mcontext;
cfed8ece 253 sigset_t uc_sigmask;
c9cf6dde 254 struct _libc_fpstate __fpregs_mem;
25123a1c 255 unsigned long int __ssp[4];
c9cf6dde
AJ
256 } ucontext_t;
257
d5e05119 258#endif /* !__x86_64__ */
30ee7c7b 259
139904b7
JM
260#undef __ctx
261
c9cf6dde 262#endif /* sys/ucontext.h */