Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | // Copyright (c) 2012, Google Inc. |
michael@0 | 2 | // All rights reserved. |
michael@0 | 3 | // |
michael@0 | 4 | // Redistribution and use in source and binary forms, with or without |
michael@0 | 5 | // modification, are permitted provided that the following conditions are |
michael@0 | 6 | // met: |
michael@0 | 7 | // |
michael@0 | 8 | // * Redistributions of source code must retain the above copyright |
michael@0 | 9 | // notice, this list of conditions and the following disclaimer. |
michael@0 | 10 | // * Redistributions in binary form must reproduce the above |
michael@0 | 11 | // copyright notice, this list of conditions and the following disclaimer |
michael@0 | 12 | // in the documentation and/or other materials provided with the |
michael@0 | 13 | // distribution. |
michael@0 | 14 | // * Neither the name of Google Inc. nor the names of its |
michael@0 | 15 | // contributors may be used to endorse or promote products derived from |
michael@0 | 16 | // this software without specific prior written permission. |
michael@0 | 17 | // |
michael@0 | 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
michael@0 | 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
michael@0 | 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
michael@0 | 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
michael@0 | 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@0 | 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@0 | 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
michael@0 | 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
michael@0 | 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
michael@0 | 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
michael@0 | 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 29 | |
michael@0 | 30 | #ifndef GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_UCONTEXT_H |
michael@0 | 31 | #define GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_UCONTEXT_H |
michael@0 | 32 | |
michael@0 | 33 | #include <sys/cdefs.h> |
michael@0 | 34 | #include <signal.h> |
michael@0 | 35 | |
michael@0 | 36 | #ifdef __cplusplus |
michael@0 | 37 | extern "C" { |
michael@0 | 38 | #endif // __cplusplus |
michael@0 | 39 | |
michael@0 | 40 | #ifndef __BIONIC_HAVE_UCONTEXT_T |
michael@0 | 41 | |
michael@0 | 42 | // Ensure that 'stack_t' is defined. |
michael@0 | 43 | #include <asm/signal.h> |
michael@0 | 44 | |
michael@0 | 45 | // This version of the Android C library headers do not provide ucontext_t. |
michael@0 | 46 | // Provide custom definitions for Google Breakpad. |
michael@0 | 47 | #if defined(__arm__) |
michael@0 | 48 | |
michael@0 | 49 | // Ensure that 'struct sigcontext' is defined. |
michael@0 | 50 | #include <asm/sigcontext.h> |
michael@0 | 51 | typedef struct sigcontext mcontext_t; |
michael@0 | 52 | |
michael@0 | 53 | // The ARM kernel uses a 64-bit signal mask. |
michael@0 | 54 | typedef uint32_t kernel_sigmask_t[2]; |
michael@0 | 55 | |
michael@0 | 56 | typedef struct ucontext { |
michael@0 | 57 | uint32_t uc_flags; |
michael@0 | 58 | struct ucontext* uc_link; |
michael@0 | 59 | stack_t uc_stack; |
michael@0 | 60 | mcontext_t uc_mcontext; |
michael@0 | 61 | kernel_sigmask_t uc_sigmask; |
michael@0 | 62 | // Other fields are not used by Google Breakpad. Don't define them. |
michael@0 | 63 | } ucontext_t; |
michael@0 | 64 | |
michael@0 | 65 | #elif defined(__i386__) |
michael@0 | 66 | |
michael@0 | 67 | /* 80-bit floating-point register */ |
michael@0 | 68 | struct _libc_fpreg { |
michael@0 | 69 | unsigned short significand[4]; |
michael@0 | 70 | unsigned short exponent; |
michael@0 | 71 | }; |
michael@0 | 72 | |
michael@0 | 73 | /* Simple floating-point state, see FNSTENV instruction */ |
michael@0 | 74 | struct _libc_fpstate { |
michael@0 | 75 | unsigned long cw; |
michael@0 | 76 | unsigned long sw; |
michael@0 | 77 | unsigned long tag; |
michael@0 | 78 | unsigned long ipoff; |
michael@0 | 79 | unsigned long cssel; |
michael@0 | 80 | unsigned long dataoff; |
michael@0 | 81 | unsigned long datasel; |
michael@0 | 82 | struct _libc_fpreg _st[8]; |
michael@0 | 83 | unsigned long status; |
michael@0 | 84 | }; |
michael@0 | 85 | |
michael@0 | 86 | typedef uint32_t greg_t; |
michael@0 | 87 | |
michael@0 | 88 | typedef struct { |
michael@0 | 89 | uint32_t gregs[19]; |
michael@0 | 90 | struct _libc_fpstate* fpregs; |
michael@0 | 91 | uint32_t oldmask; |
michael@0 | 92 | uint32_t cr2; |
michael@0 | 93 | } mcontext_t; |
michael@0 | 94 | |
michael@0 | 95 | enum { |
michael@0 | 96 | REG_GS = 0, |
michael@0 | 97 | REG_FS, |
michael@0 | 98 | REG_ES, |
michael@0 | 99 | REG_DS, |
michael@0 | 100 | REG_EDI, |
michael@0 | 101 | REG_ESI, |
michael@0 | 102 | REG_EBP, |
michael@0 | 103 | REG_ESP, |
michael@0 | 104 | REG_EBX, |
michael@0 | 105 | REG_EDX, |
michael@0 | 106 | REG_ECX, |
michael@0 | 107 | REG_EAX, |
michael@0 | 108 | REG_TRAPNO, |
michael@0 | 109 | REG_ERR, |
michael@0 | 110 | REG_EIP, |
michael@0 | 111 | REG_CS, |
michael@0 | 112 | REG_EFL, |
michael@0 | 113 | REG_UESP, |
michael@0 | 114 | REG_SS, |
michael@0 | 115 | }; |
michael@0 | 116 | |
michael@0 | 117 | // The i386 kernel uses a 64-bit signal mask. |
michael@0 | 118 | typedef uint32_t kernel_sigmask_t[2]; |
michael@0 | 119 | |
michael@0 | 120 | typedef struct ucontext { |
michael@0 | 121 | uint32_t uc_flags; |
michael@0 | 122 | struct ucontext* uc_link; |
michael@0 | 123 | stack_t uc_stack; |
michael@0 | 124 | mcontext_t uc_mcontext; |
michael@0 | 125 | kernel_sigmask_t uc_sigmask; |
michael@0 | 126 | struct _libc_fpstate __fpregs_mem; |
michael@0 | 127 | } ucontext_t; |
michael@0 | 128 | |
michael@0 | 129 | #elif defined(__mips__) |
michael@0 | 130 | |
michael@0 | 131 | // Not supported by Google Breakpad at this point, but just in case. |
michael@0 | 132 | typedef struct { |
michael@0 | 133 | uint32_t regmask; |
michael@0 | 134 | uint32_t status; |
michael@0 | 135 | uint64_t pc; |
michael@0 | 136 | uint64_t gregs[32]; |
michael@0 | 137 | uint64_t fpregs[32]; |
michael@0 | 138 | uint32_t acx; |
michael@0 | 139 | uint32_t fpc_csr; |
michael@0 | 140 | uint32_t fpc_eir; |
michael@0 | 141 | uint32_t used_math; |
michael@0 | 142 | uint32_t dsp; |
michael@0 | 143 | uint64_t mdhi; |
michael@0 | 144 | uint64_t mdlo; |
michael@0 | 145 | uint32_t hi1; |
michael@0 | 146 | uint32_t lo1; |
michael@0 | 147 | uint32_t hi2; |
michael@0 | 148 | uint32_t lo2; |
michael@0 | 149 | uint32_t hi3; |
michael@0 | 150 | uint32_t lo3; |
michael@0 | 151 | } mcontext_t; |
michael@0 | 152 | |
michael@0 | 153 | // The MIPS kernel uses a 128-bit signal mask. |
michael@0 | 154 | typedef uint32_t kernel_sigmask_t[4]; |
michael@0 | 155 | |
michael@0 | 156 | typedef struct ucontext { |
michael@0 | 157 | uint32_t uc_flags; |
michael@0 | 158 | struct ucontext* uc_link; |
michael@0 | 159 | stack_t uc_stack; |
michael@0 | 160 | mcontext_t uc_mcontext; |
michael@0 | 161 | kernel_sigmask_t uc_sigmask; |
michael@0 | 162 | // Other fields are not used by Google Breakpad. Don't define them. |
michael@0 | 163 | } ucontext_t; |
michael@0 | 164 | |
michael@0 | 165 | #else |
michael@0 | 166 | # error "Unsupported Android CPU ABI!" |
michael@0 | 167 | #endif |
michael@0 | 168 | |
michael@0 | 169 | #endif // __BIONIC_HAVE_UCONTEXT_T |
michael@0 | 170 | |
michael@0 | 171 | #ifdef __cplusplus |
michael@0 | 172 | } // extern "C" |
michael@0 | 173 | #endif // __cplusplus |
michael@0 | 174 | |
michael@0 | 175 | #endif // GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_UCONTEXT_H |