]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/blob - libc/include/sys/ucontext.h
Merge "Update bionic NOTICE files."
[android-sdk/platform-bionic.git] / libc / include / sys / ucontext.h
1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *  * Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *    the documentation and/or other materials provided with the
13  *    distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
29 #ifndef _SYS_UCONTEXT_H_
30 #define _SYS_UCONTEXT_H_
32 #include <signal.h>
33 #include <sys/user.h>
35 __BEGIN_DECLS
37 #if defined(__arm__)
39 enum {
40   REG_R0 = 0,
41   REG_R1,
42   REG_R2,
43   REG_R3,
44   REG_R4,
45   REG_R5,
46   REG_R6,
47   REG_R7,
48   REG_R8,
49   REG_R9,
50   REG_R10,
51   REG_R11,
52   REG_R12,
53   REG_R13,
54   REG_R14,
55   REG_R15,
56 };
58 #define NGREG 18 /* Like glibc. */
60 typedef int greg_t;
61 typedef greg_t gregset_t[NGREG];
63 #include <asm/sigcontext.h>
64 typedef struct sigcontext mcontext_t;
66 typedef struct ucontext {
67   unsigned long uc_flags;
68   struct ucontext* uc_link;
69   stack_t uc_stack;
70   mcontext_t uc_mcontext;
71   sigset_t uc_sigmask;
72   // Android has a wrong (smaller) sigset_t on ARM.
73   uint32_t __padding_rt_sigset;
74   // The kernel adds extra padding after uc_sigmask to match glibc sigset_t on ARM.
75   char __padding[120];
76   unsigned long uc_regspace[128] __attribute__((__aligned__(8)));
77 } ucontext_t;
79 #elif defined(__aarch64__)
81 #define NGREG 34 /* x0..x30 + sp + pc + pstate */
82 typedef unsigned long greg_t;
83 typedef greg_t gregset_t[NGREG];
85 #include <asm/sigcontext.h>
86 typedef struct sigcontext mcontext_t;
88 typedef struct ucontext {
89   unsigned long uc_flags;
90   struct ucontext *uc_link;
91   stack_t uc_stack;
92   sigset_t uc_sigmask;
93   // The kernel adds extra padding after uc_sigmask to match glibc sigset_t on ARM64.
94   char __padding[128 - sizeof(sigset_t)];
95   mcontext_t uc_mcontext;
96 } ucontext_t;
98 #elif defined(__i386__)
100 enum {
101   REG_GS = 0,
102   REG_FS,
103   REG_ES,
104   REG_DS,
105   REG_EDI,
106   REG_ESI,
107   REG_EBP,
108   REG_ESP,
109   REG_EBX,
110   REG_EDX,
111   REG_ECX,
112   REG_EAX,
113   REG_TRAPNO,
114   REG_ERR,
115   REG_EIP,
116   REG_CS,
117   REG_EFL,
118   REG_UESP,
119   REG_SS,
120   NGREG
121 };
123 typedef int greg_t;
124 typedef greg_t gregset_t[NGREG];
126 struct _libc_fpreg {
127   unsigned short significand[4];
128   unsigned short exponent;
129 };
131 struct _libc_fpstate {
132   unsigned long cw;
133   unsigned long sw;
134   unsigned long tag;
135   unsigned long ipoff;
136   unsigned long cssel;
137   unsigned long dataoff;
138   unsigned long datasel;
139   struct _libc_fpreg _st[8];
140   unsigned long status;
141 };
143 typedef struct _libc_fpstate* fpregset_t;
145 typedef struct {
146   gregset_t gregs;
147   fpregset_t fpregs;
148   unsigned long oldmask;
149   unsigned long cr2;
150 } mcontext_t;
152 typedef struct ucontext {
153   unsigned long uc_flags;
154   struct ucontext* uc_link;
155   stack_t uc_stack;
156   mcontext_t uc_mcontext;
157   sigset_t uc_sigmask;
158   // Android has a wrong (smaller) sigset_t on x86.
159   uint32_t __padding_rt_sigset;
160   struct _libc_fpstate __fpregs_mem;
161 } ucontext_t;
163 #elif defined(__mips__)
165 /* glibc doesn't have names for MIPS registers. */
167 #define NGREG 32
168 #define NFPREG 32
170 typedef unsigned long long greg_t;
171 typedef greg_t gregset_t[NGREG];
173 typedef struct fpregset {
174   union {
175     double fp_dregs[NFPREG];
176     struct {
177       float _fp_fregs;
178       unsigned _fp_pad;
179     } fp_fregs[NFPREG];
180   } fp_r;
181 } fpregset_t;
183 typedef struct {
184   unsigned regmask;
185   unsigned status;
186   greg_t pc;
187   gregset_t gregs;
188   fpregset_t fpregs;
189   unsigned fp_owned;
190   unsigned fpc_csr;
191   unsigned fpc_eir;
192   unsigned used_math;
193   unsigned dsp;
194   greg_t mdhi;
195   greg_t mdlo;
196   unsigned long hi1;
197   unsigned long lo1;
198   unsigned long hi2;
199   unsigned long lo2;
200   unsigned long hi3;
201   unsigned long lo3;
202 } mcontext_t;
204 typedef struct ucontext {
205   unsigned long uc_flags;
206   struct ucontext* uc_link;
207   stack_t uc_stack;
208   mcontext_t uc_mcontext;
209   sigset_t uc_sigmask;
210 } ucontext_t;
212 #elif defined(__mips64__)
214 #error TODO
216 #elif defined(__x86_64__)
218 enum {
219   REG_R8 = 0,
220   REG_R9,
221   REG_R10,
222   REG_R11,
223   REG_R12,
224   REG_R13,
225   REG_R14,
226   REG_R15,
227   REG_RDI,
228   REG_RSI,
229   REG_RBP,
230   REG_RBX,
231   REG_RDX,
232   REG_RAX,
233   REG_RCX,
234   REG_RSP,
235   REG_RIP,
236   REG_EFL,
237   REG_CSGSFS,
238   REG_ERR,
239   REG_TRAPNO,
240   REG_OLDMASK,
241   REG_CR2,
242   NGREG
243 };
245 typedef long greg_t;
246 typedef greg_t gregset_t[NGREG];
248 struct _libc_fpxreg {
249   unsigned short significand[4];
250   unsigned short exponent;
251   unsigned short padding[3];
252 };
254 struct _libc_xmmreg {
255   uint32_t element[4];
256 };
258 struct _libc_fpstate {
259   uint16_t cwd;
260   uint16_t swd;
261   uint16_t ftw;
262   uint16_t fop;
263   uint64_t rip;
264   uint64_t rdp;
265   uint32_t mxcsr;
266   uint32_t mxcr_mask;
267   struct _libc_fpxreg _st[8];
268   struct _libc_xmmreg _xmm[16];
269   uint32_t padding[24];
270 };
272 typedef struct _libc_fpstate* fpregset_t;
274 typedef struct {
275   gregset_t gregs;
276   fpregset_t fpregs;
277   unsigned long __reserved1[8];
278 } mcontext_t;
280 typedef struct ucontext {
281   unsigned long uc_flags;
282   struct ucontext* uc_link;
283   stack_t uc_stack;
284   mcontext_t uc_mcontext;
285   sigset_t uc_sigmask;
286   struct _libc_fpstate __fpregs_mem;
287 } ucontext_t;
289 #endif
291 __END_DECLS
293 #endif /* _SYS_UCONTEXT_H_ */