Clang Project

include/x86_64-linux-gnu/sys/ucontext.h
1/* Copyright (C) 2001-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 _SYS_UCONTEXT_H
19#define _SYS_UCONTEXT_H 1
20
21#include <features.h>
22#include <signal.h>
23
24/* We need the signal context definitions even if they are not used
25   included in <signal.h>.  */
26#include <bits/sigcontext.h>
27
28#ifdef __x86_64__
29
30/* Type for general register.  */
31__extension__ typedef long long int greg_t;
32
33/* Number of general registers.  */
34#define NGREG 23
35
36/* Container for all general registers.  */
37typedef greg_t gregset_t[NGREG];
38
39#ifdef __USE_GNU
40/* Number of each register in the `gregset_t' array.  */
41enum
42{
43  REG_R8 = 0,
44define REG_R8 REG_R8
45  REG_R9,
46define REG_R9 REG_R9
47  REG_R10,
48define REG_R10 REG_R10
49  REG_R11,
50define REG_R11 REG_R11
51  REG_R12,
52define REG_R12 REG_R12
53  REG_R13,
54define REG_R13 REG_R13
55  REG_R14,
56define REG_R14 REG_R14
57  REG_R15,
58define REG_R15 REG_R15
59  REG_RDI,
60define REG_RDI REG_RDI
61  REG_RSI,
62define REG_RSI REG_RSI
63  REG_RBP,
64define REG_RBP REG_RBP
65  REG_RBX,
66define REG_RBX REG_RBX
67  REG_RDX,
68define REG_RDX REG_RDX
69  REG_RAX,
70define REG_RAX REG_RAX
71  REG_RCX,
72define REG_RCX REG_RCX
73  REG_RSP,
74define REG_RSP REG_RSP
75  REG_RIP,
76define REG_RIP REG_RIP
77  REG_EFL,
78define REG_EFL REG_EFL
79  REG_CSGSFS, /* Actually short cs, gs, fs, __pad0.  */
80define REG_CSGSFS REG_CSGSFS
81  REG_ERR,
82define REG_ERR REG_ERR
83  REG_TRAPNO,
84define REG_TRAPNO REG_TRAPNO
85  REG_OLDMASK,
86define REG_OLDMASK REG_OLDMASK
87  REG_CR2
88define REG_CR2 REG_CR2
89};
90#endif
91
92struct _libc_fpxreg
93{
94  unsigned short int significand[4];
95  unsigned short int exponent;
96  unsigned short int padding[3];
97};
98
99struct _libc_xmmreg
100{
101  __uint32_t element[4];
102};
103
104struct _libc_fpstate
105{
106  /* 64-bit FXSAVE format.  */
107  __uint16_t cwd;
108  __uint16_t swd;
109  __uint16_t ftw;
110  __uint16_t fop;
111  __uint64_t rip;
112  __uint64_t rdp;
113  __uint32_t mxcsr;
114  __uint32_t mxcr_mask;
115  struct _libc_fpxreg _st[8];
116  struct _libc_xmmreg _xmm[16];
117  __uint32_t padding[24];
118};
119
120/* Structure to describe FPU registers.  */
121typedef struct _libc_fpstate *fpregset_t;
122
123/* Context to describe whole processor state.  */
124typedef struct
125  {
126    gregset_t gregs;
127    /* Note that fpregs is a pointer.  */
128    fpregset_t fpregs;
129    __extension__ unsigned long long __reserved1 [8];
130mcontext_t;
131
132/* Userlevel context.  */
133typedef struct ucontext
134  {
135    unsigned long int uc_flags;
136    struct ucontext *uc_link;
137    stack_t uc_stack;
138    mcontext_t uc_mcontext;
139    __sigset_t uc_sigmask;
140    struct _libc_fpstate __fpregs_mem;
141  } ucontext_t;
142
143#else /* !__x86_64__ */
144
145/* Type for general register.  */
146typedef int greg_t;
147
148/* Number of general registers.  */
149#define NGREG 19
150
151/* Container for all general registers.  */
152typedef greg_t gregset_t[NGREG];
153
154#ifdef __USE_GNU
155/* Number of each register is the `gregset_t' array.  */
156enum
157{
158  REG_GS = 0,
159define REG_GS REG_GS
160  REG_FS,
161define REG_FS REG_FS
162  REG_ES,
163define REG_ES REG_ES
164  REG_DS,
165define REG_DS REG_DS
166  REG_EDI,
167define REG_EDI REG_EDI
168  REG_ESI,
169define REG_ESI REG_ESI
170  REG_EBP,
171define REG_EBP REG_EBP
172  REG_ESP,
173define REG_ESP REG_ESP
174  REG_EBX,
175define REG_EBX REG_EBX
176  REG_EDX,
177define REG_EDX REG_EDX
178  REG_ECX,
179define REG_ECX REG_ECX
180  REG_EAX,
181define REG_EAX REG_EAX
182  REG_TRAPNO,
183define REG_TRAPNO REG_TRAPNO
184  REG_ERR,
185define REG_ERR REG_ERR
186  REG_EIP,
187define REG_EIP REG_EIP
188  REG_CS,
189define REG_CS REG_CS
190  REG_EFL,
191define REG_EFL REG_EFL
192  REG_UESP,
193define REG_UESP REG_UESP
194  REG_SS
195define REG_SS REG_SS
196};
197#endif
198
199/* Definitions taken from the kernel headers.  */
200struct _libc_fpreg
201{
202  unsigned short int significand[4];
203  unsigned short int exponent;
204};
205
206struct _libc_fpstate
207{
208  unsigned long int cw;
209  unsigned long int sw;
210  unsigned long int tag;
211  unsigned long int ipoff;
212  unsigned long int cssel;
213  unsigned long int dataoff;
214  unsigned long int datasel;
215  struct _libc_fpreg _st[8];
216  unsigned long int status;
217};
218
219/* Structure to describe FPU registers.  */
220typedef struct _libc_fpstate *fpregset_t;
221
222/* Context to describe whole processor state.  */
223typedef struct
224  {
225    gregset_t gregs;
226    /* Due to Linux's history we have to use a pointer here.  The SysV/i386
227       ABI requires a struct with the values.  */
228    fpregset_t fpregs;
229    unsigned long int oldmask;
230    unsigned long int cr2;
231  } mcontext_t;
232
233/* Userlevel context.  */
234typedef struct ucontext
235  {
236    unsigned long int uc_flags;
237    struct ucontext *uc_link;
238    stack_t uc_stack;
239    mcontext_t uc_mcontext;
240    __sigset_t uc_sigmask;
241    struct _libc_fpstate __fpregs_mem;
242  } ucontext_t;
243
244#endif /* !__x86_64__ */
245
246#endif /* sys/ucontext.h */
247
_libc_fpxreg::significand
_libc_fpxreg::exponent
_libc_fpxreg::padding
_libc_xmmreg::element
_libc_fpstate::cwd
_libc_fpstate::swd
_libc_fpstate::ftw
_libc_fpstate::fop
_libc_fpstate::rip
_libc_fpstate::rdp
_libc_fpstate::mxcsr
_libc_fpstate::mxcr_mask
_libc_fpstate::_st
_libc_fpstate::_xmm
_libc_fpstate::padding
(anonymous struct)::gregs
(anonymous struct)::fpregs
(anonymous struct)::__reserved1
ucontext::uc_flags
ucontext::uc_link
ucontext::uc_stack
ucontext::uc_mcontext
ucontext::uc_sigmask
ucontext::__fpregs_mem