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_ARM_LINUX_UCONTEXT_H_
6 #define SANDBOX_LINUX_SYSTEM_HEADERS_ARM_LINUX_UCONTEXT_H_
7 
8 #include <stddef.h>
9 
10 #if !defined(__BIONIC_HAVE_UCONTEXT_T)
11 #if !defined(__native_client_nonsfi__)
12 #include <asm/sigcontext.h>
13 #else
14 // In PNaCl toolchain, sigcontext and stack_t is not defined. So here declare
15 // them.
16 struct sigcontext {
17   unsigned long trap_no;
18   unsigned long error_code;
19   unsigned long oldmask;
20   unsigned long arm_r0;
21   unsigned long arm_r1;
22   unsigned long arm_r2;
23   unsigned long arm_r3;
24   unsigned long arm_r4;
25   unsigned long arm_r5;
26   unsigned long arm_r6;
27   unsigned long arm_r7;
28   unsigned long arm_r8;
29   unsigned long arm_r9;
30   unsigned long arm_r10;
31   unsigned long arm_fp;
32   unsigned long arm_ip;
33   unsigned long arm_sp;
34   unsigned long arm_lr;
35   unsigned long arm_pc;
36   unsigned long arm_cpsr;
37   unsigned long fault_address;
38 };
39 
40 typedef struct sigaltstack {
41   void* ss_sp;
42   int ss_flags;
43   size_t ss_size;
44 } stack_t;
45 
46 #endif
47 
48 // We also need greg_t for the sandbox, include it in this header as well.
49 typedef unsigned long greg_t;
50 
51 // typedef unsigned long sigset_t;
52 typedef struct ucontext {
53   unsigned long uc_flags;
54   struct ucontext* uc_link;
55   stack_t uc_stack;
56   struct sigcontext uc_mcontext;
57   sigset_t uc_sigmask;
58   /* Allow for uc_sigmask growth.  Glibc uses a 1024-bit sigset_t.  */
59   int __not_used[32 - (sizeof(sigset_t) / sizeof(int))];
60   /* Last for extensibility.  Eight byte aligned because some
61      coprocessors require eight byte alignment.  */
62   unsigned long uc_regspace[128] __attribute__((__aligned__(8)));
63 } ucontext_t;
64 
65 #else
66 #include <sys/ucontext.h>
67 #endif  // __BIONIC_HAVE_UCONTEXT_T
68 
69 #endif  // SANDBOX_LINUX_SYSTEM_HEADERS_ARM_LINUX_UCONTEXT_H_
70