• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- ucontext.h ----------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 // ===----------------------------------------------------------------------===
9 
10 #ifndef GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_UCONTEXT_H
11 #define GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_UCONTEXT_H
12 
13 #include <sys/cdefs.h>
14 #include <signal.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif  // __cplusplus
19 
20 #ifndef __BIONIC_HAVE_UCONTEXT_T
21 
22 // Ensure that 'stack_t' is defined.
23 #include <asm/signal.h>
24 
25 // This version of the Android C library headers do not provide ucontext_t.
26 // Provide custom definitions for Google Breakpad.
27 #if defined(__arm__)
28 
29 // Ensure that 'struct sigcontext' is defined.
30 #include <asm/sigcontext.h>
31 typedef struct sigcontext mcontext_t;
32 
33 // The ARM kernel uses a 64-bit signal mask.
34 typedef uint32_t  kernel_sigmask_t[2];
35 
36 typedef struct ucontext {
37   uint32_t uc_flags;
38   struct ucontext* uc_link;
39   stack_t uc_stack;
40   mcontext_t uc_mcontext;
41   kernel_sigmask_t uc_sigmask;
42   // Other fields are not used by Google Breakpad. Don't define them.
43 } ucontext_t;
44 
45 #elif defined(__i386__)
46 
47 /* 80-bit floating-point register */
48 struct _libc_fpreg {
49   unsigned short significand[4];
50   unsigned short exponent;
51 };
52 
53 /* Simple floating-point state, see FNSTENV instruction */
54 struct _libc_fpstate {
55   unsigned long cw;
56   unsigned long sw;
57   unsigned long tag;
58   unsigned long ipoff;
59   unsigned long cssel;
60   unsigned long dataoff;
61   unsigned long datasel;
62   struct _libc_fpreg _st[8];
63   unsigned long status;
64 };
65 
66 typedef uint32_t  greg_t;
67 
68 typedef struct {
69   uint32_t gregs[19];
70   struct _libc_fpstate* fpregs;
71   uint32_t oldmask;
72   uint32_t cr2;
73 } mcontext_t;
74 
75 enum {
76   REG_GS = 0,
77   REG_FS,
78   REG_ES,
79   REG_DS,
80   REG_EDI,
81   REG_ESI,
82   REG_EBP,
83   REG_ESP,
84   REG_EBX,
85   REG_EDX,
86   REG_ECX,
87   REG_EAX,
88   REG_TRAPNO,
89   REG_ERR,
90   REG_EIP,
91   REG_CS,
92   REG_EFL,
93   REG_UESP,
94   REG_SS,
95 };
96 
97 // The i386 kernel uses a 64-bit signal mask.
98 typedef uint32_t kernel_sigmask_t[2];
99 
100 typedef struct ucontext {
101   uint32_t uc_flags;
102   struct ucontext* uc_link;
103   stack_t uc_stack;
104   mcontext_t uc_mcontext;
105   kernel_sigmask_t uc_sigmask;
106   struct _libc_fpstate __fpregs_mem;
107 } ucontext_t;
108 
109 #elif defined(__mips__)
110 
111 typedef struct {
112   uint32_t regmask;
113   uint32_t status;
114   uint64_t pc;
115   uint64_t gregs[32];
116   uint64_t fpregs[32];
117   uint32_t acx;
118   uint32_t fpc_csr;
119   uint32_t fpc_eir;
120   uint32_t used_math;
121   uint32_t dsp;
122   uint64_t mdhi;
123   uint64_t mdlo;
124   uint32_t hi1;
125   uint32_t lo1;
126   uint32_t hi2;
127   uint32_t lo2;
128   uint32_t hi3;
129   uint32_t lo3;
130 } mcontext_t;
131 
132 // The MIPS kernel uses a 128-bit signal mask.
133 typedef uint32_t kernel_sigmask_t[4];
134 
135 typedef struct ucontext {
136   uint32_t uc_flags;
137   struct ucontext* uc_link;
138   stack_t uc_stack;
139   mcontext_t uc_mcontext;
140   kernel_sigmask_t uc_sigmask;
141   // Other fields are not used by Google Breakpad. Don't define them.
142 } ucontext_t;
143 
144 #else
145 #  error "Unsupported Android CPU ABI!"
146 #endif
147 
148 #endif  // __BIONIC_HAVE_UCONTEXT_T
149 
150 #ifdef __cplusplus
151 }  // extern "C"
152 #endif  // __cplusplus
153 
154 #endif  // GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_UCONTEXT_H
155