Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / breakpad / src / common / android / include / sys / user.h
1 // Copyright (c) 2012, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
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
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 //     * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 #ifndef GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_USER_H
31 #define GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_USER_H
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif  // __cplusplus
36
37 // These types are used with ptrace(), more specifically with
38 // PTRACE_GETREGS, PTRACE_GETFPREGS and PTRACE_GETVFPREGS respectively.
39 //
40 // They are also defined, sometimes with different names, in <asm/user.h>
41 //
42
43 #if defined(__arm__)
44
45 #define _ARM_USER_H  1  // Prevent <asm/user.h> conflicts
46
47 // Note: on ARM, GLibc uses user_regs instead of user_regs_struct.
48 struct user_regs {
49   // Note: Entries 0-15 match r0..r15
50   //       Entry 16 is used to store the CPSR register.
51   //       Entry 17 is used to store the "orig_r0" value.
52   unsigned long int uregs[18];
53 };
54
55 // Same here: user_fpregs instead of user_fpregs_struct.
56 struct user_fpregs {
57   struct fp_reg {
58     unsigned int sign1:1;
59     unsigned int unused:15;
60     unsigned int sign2:1;
61     unsigned int exponent:14;
62     unsigned int j:1;
63     unsigned int mantissa1:31;
64     unsigned int mantissa0:32;
65   } fpregs[8];
66   unsigned int  fpsr:32;
67   unsigned int  fpcr:32;
68   unsigned char ftype[8];
69   unsigned int  init_flag;
70 };
71
72 // GLibc doesn't define this one in <sys/user.h> though.
73 struct user_vfpregs {
74   unsigned long long  fpregs[32];
75   unsigned long       fpscr;
76 };
77
78 #elif defined(__aarch64__)
79
80 // aarch64 does not have user_regs definitions in <asm/user.h>, instead
81 // use the definitions in <asm/ptrace.h>, which we don't need to redefine here.
82
83 #elif defined(__i386__)
84
85 #define _I386_USER_H 1  // Prevent <asm/user.h> conflicts
86
87 // GLibc-compatible definitions
88 struct user_regs_struct {
89   long ebx, ecx, edx, esi, edi, ebp, eax;
90   long xds, xes, xfs, xgs, orig_eax;
91   long eip, xcs, eflags, esp, xss;
92 };
93
94 struct user_fpregs_struct {
95   long cwd, swd, twd, fip, fcs, foo, fos;
96   long st_space[20];
97 };
98
99 struct user_fpxregs_struct {
100   unsigned short cwd, swd, twd, fop;
101   long fip, fcs, foo, fos, mxcsr, reserved;
102   long st_space[32];
103   long xmm_space[32];
104   long padding[56];
105 };
106
107 struct user {
108   struct user_regs_struct    regs;
109   int                        u_fpvalid;
110   struct user_fpregs_struct  i387;
111   unsigned long              u_tsize;
112   unsigned long              u_dsize;
113   unsigned long              u_ssize;
114   unsigned long              start_code;
115   unsigned long              start_stack;
116   long                       signal;
117   int                        reserved;
118   struct user_regs_struct*   u_ar0;
119   struct user_fpregs_struct* u_fpstate;
120   unsigned long              magic;
121   char                       u_comm [32];
122   int                        u_debugreg [8];
123 };
124
125
126 #elif defined(__mips__)
127
128 #define _ASM_USER_H 1  // Prevent <asm/user.h> conflicts
129
130 struct user_regs_struct {
131   unsigned long long regs[32];
132   unsigned long long lo;
133   unsigned long long hi;
134   unsigned long long epc;
135   unsigned long long badvaddr;
136   unsigned long long status;
137   unsigned long long cause;
138 };
139
140 struct user_fpregs_struct {
141   unsigned long long regs[32];
142   unsigned int fpcsr;
143   unsigned int fir;
144 };
145
146 #elif defined(__x86_64__)
147 #include <sys/types.h>
148 #include_next <sys/user.h>
149
150 // This struct is essentially the same as user_i387_struct in sys/user.h
151 // except that the struct name and individual field names are chosen here
152 // to match the ones used in breakpad for other x86_64 platforms.
153
154 struct user_fpregs_struct {
155   __u16 cwd;
156   __u16 swd;
157   __u16 ftw;
158   __u16 fop;
159   __u64 rip;
160   __u64 rdp;
161   __u32 mxcsr;
162   __u32 mxcr_mask;
163   __u32 st_space[32];   /* 8*16 bytes for each FP-reg = 128 bytes */
164   __u32 xmm_space[64];  /* 16*16 bytes for each XMM-reg = 256 bytes */
165   __u32 padding[24];
166 };
167
168 #else
169 #  error "Unsupported Android CPU ABI"
170 #endif
171
172 #ifdef __cplusplus
173 }  // extern "C"
174 #endif  // __cplusplus
175
176 #endif  // GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_USER_H