1 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
2  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
3 
4 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
5 #define MINSIGSTKSZ 2048
6 #define SIGSTKSZ 8192
7 #endif
8 
9 #ifdef _GNU_SOURCE
10 enum { REG_R8 = 0 };
11 #define REG_R8 REG_R8
12 enum { REG_R9 = 1 };
13 #define REG_R9 REG_R9
14 enum { REG_R10 = 2 };
15 #define REG_R10 REG_R10
16 enum { REG_R11 = 3 };
17 #define REG_R11 REG_R11
18 enum { REG_R12 = 4 };
19 #define REG_R12 REG_R12
20 enum { REG_R13 = 5 };
21 #define REG_R13 REG_R13
22 enum { REG_R14 = 6 };
23 #define REG_R14 REG_R14
24 enum { REG_R15 = 7 };
25 #define REG_R15 REG_R15
26 enum { REG_RDI = 8 };
27 #define REG_RDI REG_RDI
28 enum { REG_RSI = 9 };
29 #define REG_RSI REG_RSI
30 enum { REG_RBP = 10 };
31 #define REG_RBP REG_RBP
32 enum { REG_RBX = 11 };
33 #define REG_RBX REG_RBX
34 enum { REG_RDX = 12 };
35 #define REG_RDX REG_RDX
36 enum { REG_RAX = 13 };
37 #define REG_RAX REG_RAX
38 enum { REG_RCX = 14 };
39 #define REG_RCX REG_RCX
40 enum { REG_RSP = 15 };
41 #define REG_RSP REG_RSP
42 enum { REG_RIP = 16 };
43 #define REG_RIP REG_RIP
44 enum { REG_EFL = 17 };
45 #define REG_EFL REG_EFL
46 enum { REG_CSGSFS = 18 };
47 #define REG_CSGSFS REG_CSGSFS
48 enum { REG_ERR = 19 };
49 #define REG_ERR REG_ERR
50 enum { REG_TRAPNO = 20 };
51 #define REG_TRAPNO REG_TRAPNO
52 enum { REG_OLDMASK = 21 };
53 #define REG_OLDMASK REG_OLDMASK
54 enum { REG_CR2 = 22 };
55 #define REG_CR2 REG_CR2
56 #endif
57 
58 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
59 typedef long long greg_t, gregset_t[23];
60 typedef struct _fpstate {
61 	unsigned short cwd, swd, ftw, fop;
62 	unsigned long long rip, rdp;
63 	unsigned mxcsr, mxcr_mask;
64 	struct {
65 		unsigned short significand[4], exponent, padding[3];
66 	} _st[8];
67 	struct {
68 		unsigned element[4];
69 	} _xmm[16];
70 	unsigned padding[24];
71 } *fpregset_t;
72 struct sigcontext {
73 	unsigned long r8, r9, r10, r11, r12, r13, r14, r15;
74 	unsigned long rdi, rsi, rbp, rbx, rdx, rax, rcx, rsp, rip, eflags;
75 	unsigned short cs, gs, fs, __pad0;
76 	unsigned long err, trapno, oldmask, cr2;
77 	struct _fpstate *fpstate;
78 	unsigned long __reserved1[8];
79 };
80 typedef struct {
81 	gregset_t gregs;
82 	fpregset_t fpregs;
83 	unsigned long long __reserved1[8];
84 } mcontext_t;
85 #else
86 typedef struct {
87 	unsigned long __space[32];
88 } mcontext_t;
89 #endif
90 
91 struct sigaltstack {
92 	void *ss_sp;
93 	int ss_flags;
94 	size_t ss_size;
95 };
96 
97 typedef struct __ucontext {
98 	unsigned long uc_flags;
99 	struct __ucontext *uc_link;
100 	stack_t uc_stack;
101 	mcontext_t uc_mcontext;
102 	sigset_t uc_sigmask;
103 	unsigned long __fpregs_mem[64];
104 } ucontext_t;
105 
106 #define SA_NOCLDSTOP  1
107 #define SA_NOCLDWAIT  2
108 #define SA_SIGINFO    4
109 #define SA_ONSTACK    0x08000000
110 #define SA_RESTART    0x10000000
111 #define SA_NODEFER    0x40000000
112 #define SA_RESETHAND  0x80000000
113 #define SA_RESTORER   0x04000000
114 
115 #endif
116 
117 #define SIGHUP    1
118 #define SIGINT    2
119 #define SIGQUIT   3
120 #define SIGILL    4
121 #define SIGTRAP   5
122 #define SIGABRT   6
123 #define SIGIOT    SIGABRT
124 #define SIGBUS    7
125 #define SIGFPE    8
126 #define SIGKILL   9
127 #define SIGUSR1   10
128 #define SIGSEGV   11
129 #define SIGUSR2   12
130 #define SIGPIPE   13
131 #define SIGALRM   14
132 #define SIGTERM   15
133 #define SIGSTKFLT 16
134 #define SIGCHLD   17
135 #define SIGCONT   18
136 #define SIGSTOP   19
137 #define SIGTSTP   20
138 #define SIGTTIN   21
139 #define SIGTTOU   22
140 #define SIGURG    23
141 #define SIGXCPU   24
142 #define SIGXFSZ   25
143 #define SIGVTALRM 26
144 #define SIGPROF   27
145 #define SIGWINCH  28
146 #define SIGIO     29
147 #define SIGPOLL   29
148 #define SIGPWR    30
149 #define SIGSYS    31
150 #define SIGUNUSED SIGSYS
151 
152 #define _NSIG 65
153 
154