Blob


1 #define setcontext(u) _setmcontext(&(u)->mc)
2 #define getcontext(u) _getmcontext(&(u)->mc)
3 typedef struct mcontext mcontext_t;
4 typedef struct ucontext ucontext_t;
5 struct mcontext
6 {
7 ulong pc; /* lr */
8 ulong cr; /* mfcr */
9 ulong ctr; /* mfcr */
10 ulong xer; /* mfcr */
11 ulong sp; /* callee saved: r1 */
12 ulong toc; /* callee saved: r2 */
13 ulong r3; /* first arg to function, return register: r3 */
14 ulong gpr[19]; /* callee saved: r13-r31 */
15 // XXX: currently do not save vector registers or floating-point state
16 // ulong pad;
17 // uvlong fpr[18]; /* callee saved: f14-f31 */
18 // ulong vr[4*12]; /* callee saved: v20-v31, 256-bits each */
19 };
21 struct ucontext
22 {
23 struct {
24 void *ss_sp;
25 uint ss_size;
26 } uc_stack;
27 sigset_t uc_sigmask;
28 mcontext_t mc;
29 };
31 void makecontext(ucontext_t*, void(*)(void), int, ...);
32 int swapcontext(ucontext_t*, ucontext_t*);
33 int _getmcontext(mcontext_t*);
34 void _setmcontext(mcontext_t*);