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 /*
16 // XXX: currently do not save vector registers or floating-point state
17 //	ulong	pad;
18 //	uvlong	fpr[18];	/ * callee saved: f14-f31 * /
19 //	ulong	vr[4*12];	/ * callee saved: v20-v31, 256-bits each * /
20 */
21 };
22 
23 struct ucontext
24 {
25 	struct {
26 		void *ss_sp;
27 		uint ss_size;
28 	} uc_stack;
29 	sigset_t uc_sigmask;
30 	mcontext_t mc;
31 };
32 
33 void makecontext(ucontext_t*, void(*)(void), int, ...);
34 int swapcontext(ucontext_t*, ucontext_t*);
35 int _getmcontext(mcontext_t*);
36 void _setmcontext(mcontext_t*);
37