ttcontext.c - plan9port - [fork] Plan 9 from user space
HTML git clone git://src.adamsgaard.dk/plan9port
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
ttcontext.c (384B)
---
1 #include "../threadimpl.h"
2 #undef exits
3
4
5 ucontext_t c0, c1;
6 char stack[65536];
7
8 void
9 go(void *v)
10 {
11 print("hello, world\n");
12 setcontext(&c0);
13 }
14
15 void
16 main(void)
17 {
18 // print("in main\n");
19 getcontext(&c1);
20 c1.uc_stack.ss_sp = stack;
21 c1.uc_stack.ss_size = sizeof stack;
22 makecontext(&c1, go, 1, 0);
23 if(getcontext(&c0) == 0)
24 setcontext(&c1);
25 print("back in main\n");
26 exits(0);
27 }