• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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_SERVICES_ANDROID_X86_64_UCONTEXT_H_
6 #define SANDBOX_LINUX_SERVICES_ANDROID_X86_64_UCONTEXT_H_
7 
8 // We do something compatible with glibc. Hopefully, at some point Android will
9 // provide that for us, and __BIONIC_HAVE_UCONTEXT_T should be defined.
10 // Spec:
11 // http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-AMD64/LSB-Core-AMD64/libc-ddefs.html#AEN5668
12 
13 #if !defined(__BIONIC_HAVE_UCONTEXT_T)
14 #include <asm/sigcontext.h>
15 
16 struct _libc_fpxreg {
17   unsigned short significand[4];
18   unsigned short exponent;
19   unsigned short padding[3];
20 };
21 
22 struct _libc_xmmreg {
23   uint32_t element[4];
24 };
25 
26 struct _libc_fpstate {
27   uint16_t cwd;
28   uint16_t swd;
29   uint16_t twd;
30   uint16_t fop;
31   uint64_t rip;
32   uint64_t rdp;
33   uint32_t mxcsr;
34   uint32_t mxcsr_mask;
35   struct _libc_fpxreg _st[8];
36   struct _libc_xmmreg _xmm[16];
37   uint32_t padding[24];
38 };
39 
40 typedef uint64_t greg_t;
41 
42 typedef struct {
43   greg_t gregs[23];
44   struct _libc_fpstate* fpregs;
45   unsigned long __reserved1[8];
46 } mcontext_t;
47 
48 enum {
49   REG_R8 = 0,
50   REG_R9,
51   REG_R10,
52   REG_R11,
53   REG_R12,
54   REG_R13,
55   REG_R14,
56   REG_R15,
57   REG_RDI,
58   REG_RSI,
59   REG_RBP,
60   REG_RBX,
61   REG_RDX,
62   REG_RAX,
63   REG_RCX,
64   REG_RSP,
65   REG_RIP,
66   REG_EFL,
67   REG_CSGSFS,
68   REG_ERR,
69   REG_TRAPNO,
70   REG_OLDMASK,
71   REG_CR2,
72   NGREG,
73 };
74 
75 typedef struct ucontext {
76   unsigned long uc_flags;
77   struct ucontext* uc_link;
78   stack_t uc_stack;
79   mcontext_t uc_mcontext;
80   sigset_t uc_sigmask;
81   struct _libc_fpstate __fpregs_mem;
82 } ucontext_t;
83 
84 #else
85 #include <sys/ucontext.h>
86 #endif  // __BIONIC_HAVE_UCONTEXT_T
87 
88 #endif  // SANDBOX_LINUX_SERVICES_ANDROID_X86_64_UCONTEXT_H_
89