1 | /* Copyright (C) 2002-2016 Free Software Foundation, Inc. |
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 |
15 | License along with the GNU C Library; if not, see |
16 | <http://www.gnu.org/licenses/>. */ |
17 | |
18 | #ifndef _BITS_SIGCONTEXT_H |
19 | #define _BITS_SIGCONTEXT_H 1 |
20 | |
21 | #if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H |
22 | # error "Never use <bits/sigcontext.h> directly; include <signal.h> instead." |
23 | #endif |
24 | |
25 | #define FP_XSTATE_MAGIC1 0x46505853U |
26 | #define FP_XSTATE_MAGIC2 0x46505845U |
27 | #define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2) |
28 | |
29 | struct _fpx_sw_bytes |
30 | { |
31 | __uint32_t magic1; |
32 | __uint32_t extended_size; |
33 | __uint64_t xstate_bv; |
34 | __uint32_t xstate_size; |
35 | __uint32_t padding[7]; |
36 | }; |
37 | |
38 | struct _fpreg |
39 | { |
40 | unsigned short significand[4]; |
41 | unsigned short exponent; |
42 | }; |
43 | |
44 | struct _fpxreg |
45 | { |
46 | unsigned short significand[4]; |
47 | unsigned short exponent; |
48 | unsigned short padding[3]; |
49 | }; |
50 | |
51 | struct _xmmreg |
52 | { |
53 | __uint32_t element[4]; |
54 | }; |
55 | |
56 | |
57 | |
58 | #ifndef __x86_64__ |
59 | |
60 | struct _fpstate |
61 | { |
62 | /* Regular FPU environment. */ |
63 | __uint32_t cw; |
64 | __uint32_t sw; |
65 | __uint32_t tag; |
66 | __uint32_t ipoff; |
67 | __uint32_t cssel; |
68 | __uint32_t dataoff; |
69 | __uint32_t datasel; |
70 | struct _fpreg _st[8]; |
71 | unsigned short status; |
72 | unsigned short magic; |
73 | |
74 | /* FXSR FPU environment. */ |
75 | __uint32_t _fxsr_env[6]; |
76 | __uint32_t mxcsr; |
77 | __uint32_t reserved; |
78 | struct _fpxreg _fxsr_st[8]; |
79 | struct _xmmreg _xmm[8]; |
80 | __uint32_t padding[56]; |
81 | }; |
82 | |
83 | #ifndef sigcontext_struct |
84 | /* Kernel headers before 2.1.1 define a struct sigcontext_struct, but |
85 | we need sigcontext. Some packages have come to rely on |
86 | sigcontext_struct being defined on 32-bit x86, so define this for |
87 | their benefit. */ |
88 | # define sigcontext_struct sigcontext |
89 | #endif |
90 | |
91 | #define X86_FXSR_MAGIC 0x0000 |
92 | |
93 | struct sigcontext |
94 | { |
95 | unsigned short gs, __gsh; |
96 | unsigned short fs, __fsh; |
97 | unsigned short es, __esh; |
98 | unsigned short ds, __dsh; |
99 | unsigned long edi; |
100 | unsigned long esi; |
101 | unsigned long ebp; |
102 | unsigned long esp; |
103 | unsigned long ebx; |
104 | unsigned long edx; |
105 | unsigned long ecx; |
106 | unsigned long eax; |
107 | unsigned long trapno; |
108 | unsigned long err; |
109 | unsigned long eip; |
110 | unsigned short cs, __csh; |
111 | unsigned long eflags; |
112 | unsigned long esp_at_signal; |
113 | unsigned short ss, __ssh; |
114 | struct _fpstate * fpstate; |
115 | unsigned long oldmask; |
116 | unsigned long cr2; |
117 | }; |
118 | |
119 | #else /* __x86_64__ */ |
120 | |
121 | struct _fpstate |
122 | { |
123 | /* FPU environment matching the 64-bit FXSAVE layout. */ |
124 | __uint16_t cwd; |
125 | __uint16_t swd; |
126 | __uint16_t ftw; |
127 | __uint16_t fop; |
128 | __uint64_t rip; |
129 | __uint64_t rdp; |
130 | __uint32_t mxcsr; |
131 | __uint32_t mxcr_mask; |
132 | struct _fpxreg _st[8]; |
133 | struct _xmmreg _xmm[16]; |
134 | __uint32_t padding[24]; |
135 | }; |
136 | |
137 | struct sigcontext |
138 | { |
139 | __uint64_t r8; |
140 | __uint64_t r9; |
141 | __uint64_t r10; |
142 | __uint64_t r11; |
143 | __uint64_t r12; |
144 | __uint64_t r13; |
145 | __uint64_t r14; |
146 | __uint64_t r15; |
147 | __uint64_t rdi; |
148 | __uint64_t rsi; |
149 | __uint64_t rbp; |
150 | __uint64_t rbx; |
151 | __uint64_t rdx; |
152 | __uint64_t rax; |
153 | __uint64_t rcx; |
154 | __uint64_t rsp; |
155 | __uint64_t rip; |
156 | __uint64_t eflags; |
157 | unsigned short cs; |
158 | unsigned short gs; |
159 | unsigned short fs; |
160 | unsigned short __pad0; |
161 | __uint64_t err; |
162 | __uint64_t trapno; |
163 | __uint64_t oldmask; |
164 | __uint64_t cr2; |
165 | __extension__ union |
166 | { |
167 | struct _fpstate * fpstate; |
168 | __uint64_t __fpstate_word; |
169 | }; |
170 | __uint64_t __reserved1 [8]; |
171 | }; |
172 | |
173 | #endif /* __x86_64__ */ |
174 | |
175 | struct _xsave_hdr |
176 | { |
177 | __uint64_t xstate_bv; |
178 | __uint64_t reserved1[2]; |
179 | __uint64_t reserved2[5]; |
180 | }; |
181 | |
182 | struct _ymmh_state |
183 | { |
184 | __uint32_t ymmh_space[64]; |
185 | }; |
186 | |
187 | struct _xstate |
188 | { |
189 | struct _fpstate fpstate; |
190 | struct _xsave_hdr xstate_hdr; |
191 | struct _ymmh_state ymmh; |
192 | }; |
193 | |
194 | #endif /* _BITS_SIGCONTEXT_H */ |
195 | |