libcont
About
libcont.
libcont is Continuation library for C.
It is substitute library of setjmp / longjmp.
While longjmp can't jmp to inside stack, libcont can.
This software is part of Mona OS Project.
Requirements
Linux (IA32)
nasm
How to use
1 #include "cont.h"
2
3 // call cont_initialize() at main()
4
5 static int func1(int counter);
6 static void stack_destroy(int counter);
7
8 static Cont c;
9
10 void jmp_inside_test()
11 {
12 int ret = func1(0);
13 if (ret != 0)
14 {
15 printf("jmp inside OK\n");
16 return;
17 }
18 cont_restore(&c, 1);
19 }
20
21 int func1(int counter)
22 {
23 if (counter == 5)
24 {
25 int ret = cont_save(&c);
26 if (ret == 0)
27 {
28 return ret;
29 }
30 else
31 {
32 printf("jmp inside OK [%d]\n", counter);
33 return ret;
34 }
35 }
36 printf("func1 : %x\n", counter);
37 int ret = func1(counter + 1);
38 printf("func1 : %x\n", counter);
39 return ret;
40 }
41
How to install
Download from http://sourceforge.net/projects/libcont
make
Authors
Contact
If you have a good idea, then mail Higepon your suggestion; or better yet, join as a developer and contribute!
