1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/crashreporter/google-breakpad/src/common/android/include/sys/ucontext.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,175 @@ 1.4 +// Copyright (c) 2012, Google Inc. 1.5 +// All rights reserved. 1.6 +// 1.7 +// Redistribution and use in source and binary forms, with or without 1.8 +// modification, are permitted provided that the following conditions are 1.9 +// met: 1.10 +// 1.11 +// * Redistributions of source code must retain the above copyright 1.12 +// notice, this list of conditions and the following disclaimer. 1.13 +// * Redistributions in binary form must reproduce the above 1.14 +// copyright notice, this list of conditions and the following disclaimer 1.15 +// in the documentation and/or other materials provided with the 1.16 +// distribution. 1.17 +// * Neither the name of Google Inc. nor the names of its 1.18 +// contributors may be used to endorse or promote products derived from 1.19 +// this software without specific prior written permission. 1.20 +// 1.21 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.22 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.23 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.24 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.25 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.26 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.27 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.28 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.29 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.30 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.31 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.32 + 1.33 +#ifndef GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_UCONTEXT_H 1.34 +#define GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_UCONTEXT_H 1.35 + 1.36 +#include <sys/cdefs.h> 1.37 +#include <signal.h> 1.38 + 1.39 +#ifdef __cplusplus 1.40 +extern "C" { 1.41 +#endif // __cplusplus 1.42 + 1.43 +#ifndef __BIONIC_HAVE_UCONTEXT_T 1.44 + 1.45 +// Ensure that 'stack_t' is defined. 1.46 +#include <asm/signal.h> 1.47 + 1.48 +// This version of the Android C library headers do not provide ucontext_t. 1.49 +// Provide custom definitions for Google Breakpad. 1.50 +#if defined(__arm__) 1.51 + 1.52 +// Ensure that 'struct sigcontext' is defined. 1.53 +#include <asm/sigcontext.h> 1.54 +typedef struct sigcontext mcontext_t; 1.55 + 1.56 +// The ARM kernel uses a 64-bit signal mask. 1.57 +typedef uint32_t kernel_sigmask_t[2]; 1.58 + 1.59 +typedef struct ucontext { 1.60 + uint32_t uc_flags; 1.61 + struct ucontext* uc_link; 1.62 + stack_t uc_stack; 1.63 + mcontext_t uc_mcontext; 1.64 + kernel_sigmask_t uc_sigmask; 1.65 + // Other fields are not used by Google Breakpad. Don't define them. 1.66 +} ucontext_t; 1.67 + 1.68 +#elif defined(__i386__) 1.69 + 1.70 +/* 80-bit floating-point register */ 1.71 +struct _libc_fpreg { 1.72 + unsigned short significand[4]; 1.73 + unsigned short exponent; 1.74 +}; 1.75 + 1.76 +/* Simple floating-point state, see FNSTENV instruction */ 1.77 +struct _libc_fpstate { 1.78 + unsigned long cw; 1.79 + unsigned long sw; 1.80 + unsigned long tag; 1.81 + unsigned long ipoff; 1.82 + unsigned long cssel; 1.83 + unsigned long dataoff; 1.84 + unsigned long datasel; 1.85 + struct _libc_fpreg _st[8]; 1.86 + unsigned long status; 1.87 +}; 1.88 + 1.89 +typedef uint32_t greg_t; 1.90 + 1.91 +typedef struct { 1.92 + uint32_t gregs[19]; 1.93 + struct _libc_fpstate* fpregs; 1.94 + uint32_t oldmask; 1.95 + uint32_t cr2; 1.96 +} mcontext_t; 1.97 + 1.98 +enum { 1.99 + REG_GS = 0, 1.100 + REG_FS, 1.101 + REG_ES, 1.102 + REG_DS, 1.103 + REG_EDI, 1.104 + REG_ESI, 1.105 + REG_EBP, 1.106 + REG_ESP, 1.107 + REG_EBX, 1.108 + REG_EDX, 1.109 + REG_ECX, 1.110 + REG_EAX, 1.111 + REG_TRAPNO, 1.112 + REG_ERR, 1.113 + REG_EIP, 1.114 + REG_CS, 1.115 + REG_EFL, 1.116 + REG_UESP, 1.117 + REG_SS, 1.118 +}; 1.119 + 1.120 +// The i386 kernel uses a 64-bit signal mask. 1.121 +typedef uint32_t kernel_sigmask_t[2]; 1.122 + 1.123 +typedef struct ucontext { 1.124 + uint32_t uc_flags; 1.125 + struct ucontext* uc_link; 1.126 + stack_t uc_stack; 1.127 + mcontext_t uc_mcontext; 1.128 + kernel_sigmask_t uc_sigmask; 1.129 + struct _libc_fpstate __fpregs_mem; 1.130 +} ucontext_t; 1.131 + 1.132 +#elif defined(__mips__) 1.133 + 1.134 +// Not supported by Google Breakpad at this point, but just in case. 1.135 +typedef struct { 1.136 + uint32_t regmask; 1.137 + uint32_t status; 1.138 + uint64_t pc; 1.139 + uint64_t gregs[32]; 1.140 + uint64_t fpregs[32]; 1.141 + uint32_t acx; 1.142 + uint32_t fpc_csr; 1.143 + uint32_t fpc_eir; 1.144 + uint32_t used_math; 1.145 + uint32_t dsp; 1.146 + uint64_t mdhi; 1.147 + uint64_t mdlo; 1.148 + uint32_t hi1; 1.149 + uint32_t lo1; 1.150 + uint32_t hi2; 1.151 + uint32_t lo2; 1.152 + uint32_t hi3; 1.153 + uint32_t lo3; 1.154 +} mcontext_t; 1.155 + 1.156 +// The MIPS kernel uses a 128-bit signal mask. 1.157 +typedef uint32_t kernel_sigmask_t[4]; 1.158 + 1.159 +typedef struct ucontext { 1.160 + uint32_t uc_flags; 1.161 + struct ucontext* uc_link; 1.162 + stack_t uc_stack; 1.163 + mcontext_t uc_mcontext; 1.164 + kernel_sigmask_t uc_sigmask; 1.165 + // Other fields are not used by Google Breakpad. Don't define them. 1.166 +} ucontext_t; 1.167 + 1.168 +#else 1.169 +# error "Unsupported Android CPU ABI!" 1.170 +#endif 1.171 + 1.172 +#endif // __BIONIC_HAVE_UCONTEXT_T 1.173 + 1.174 +#ifdef __cplusplus 1.175 +} // extern "C" 1.176 +#endif // __cplusplus 1.177 + 1.178 +#endif // GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_UCONTEXT_H