1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef SANDBOX_LINUX_SYSTEM_HEADERS_ANDROID_I386_UCONTEXT_H_ 6 #define SANDBOX_LINUX_SYSTEM_HEADERS_ANDROID_I386_UCONTEXT_H_ 7 8 #include <stddef.h> 9 #include <stdint.h> 10 11 // We do something compatible with glibc. Hopefully, at some point Android will 12 // provide that for us, and __BIONIC_HAVE_UCONTEXT_T should be defined. 13 // This is mostly copied from breakpad (common/android/include/sys/ucontext.h), 14 // except we do use sigset_t for uc_sigmask instead of a custom type. 15 16 #if !defined(__BIONIC_HAVE_UCONTEXT_T) 17 #if !defined(__native_client_nonsfi__) 18 #include <asm/sigcontext.h> 19 #else 20 // In PNaCl toolchain, sigcontext is not defined. So here declare it. 21 typedef struct sigaltstack { 22 void* ss_sp; 23 int ss_flags; 24 size_t ss_size; 25 } stack_t; 26 #endif 27 28 /* 80-bit floating-point register */ 29 struct _libc_fpreg { 30 unsigned short significand[4]; 31 unsigned short exponent; 32 }; 33 34 /* Simple floating-point state, see FNSTENV instruction */ 35 struct _libc_fpstate { 36 unsigned long cw; 37 unsigned long sw; 38 unsigned long tag; 39 unsigned long ipoff; 40 unsigned long cssel; 41 unsigned long dataoff; 42 unsigned long datasel; 43 struct _libc_fpreg _st[8]; 44 unsigned long status; 45 }; 46 47 typedef uint32_t greg_t; 48 49 typedef struct { 50 uint32_t gregs[19]; 51 struct _libc_fpstate* fpregs; 52 uint32_t oldmask; 53 uint32_t cr2; 54 } mcontext_t; 55 56 enum { 57 REG_GS = 0, 58 REG_FS, 59 REG_ES, 60 REG_DS, 61 REG_EDI, 62 REG_ESI, 63 REG_EBP, 64 REG_ESP, 65 REG_EBX, 66 REG_EDX, 67 REG_ECX, 68 REG_EAX, 69 REG_TRAPNO, 70 REG_ERR, 71 REG_EIP, 72 REG_CS, 73 REG_EFL, 74 REG_UESP, 75 REG_SS, 76 }; 77 78 typedef struct ucontext { 79 uint32_t uc_flags; 80 struct ucontext* uc_link; 81 stack_t uc_stack; 82 mcontext_t uc_mcontext; 83 // Android and PNaCl toolchain's sigset_t has only 32 bits, though Linux 84 // ABI requires 64 bits. 85 union { 86 sigset_t uc_sigmask; 87 uint32_t kernel_sigmask[2]; 88 }; 89 struct _libc_fpstate __fpregs_mem; 90 } ucontext_t; 91 92 #else 93 #include <sys/ucontext.h> 94 #endif // __BIONIC_HAVE_UCONTEXT_T 95 96 #endif // SANDBOX_LINUX_SYSTEM_HEADERS_ANDROID_I386_UCONTEXT_H_ 97