diff options
Diffstat (limited to 'test/cothreads/simple.c')
-rw-r--r-- | test/cothreads/simple.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/cothreads/simple.c b/test/cothreads/simple.c new file mode 100644 index 000000000..3e1e950de --- /dev/null +++ b/test/cothreads/simple.c @@ -0,0 +1,23 @@ +#include <stdio.h> +#include "cothreads.h" + +// cothread_context is passed in argv +int loopfunc(int argc,char **argv) { + fprintf(stderr,"SIMPLE: in loopfunc\n"); + cothread_switch((cothread_context *)cothread_main(argv)); +} + +int main(int argc,char *argv[]) { + cothread_context *ctx; + cothread_state *state; + + ctx = cothread_init(); + state = cothread_create(ctx); + cothread_setfunc(state,loopfunc,0,(char **)ctx); + + fprintf(stderr,"SIMPLE: about to switch to cothread 1\n"); + cothread_switch(state); + fprintf(stderr,"SIMPLE: back from cothread_switch\n"); + + return 0; +} |