* import/setjmp.hb: new file to support setjmp.

* test: test setjmp.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4113 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
Minero Aoki 2008-12-23 17:54:11 +00:00
parent 0d9cdf252d
commit 4cb2818d45
4 changed files with 53 additions and 0 deletions

View File

@ -1,3 +1,9 @@
Wed Dec 24 02:54:06 2008 Minero Aoki <aamine@loveruby.net>
* import/setjmp.hb: new file to support setjmp.
* test: test setjmp.
Mon Dec 15 00:05:16 2008 Minero Aoki <aamine@loveruby.net>
* introduce virtual stack again, for only local variables and tmp

9
import/setjmp.hb Normal file
View File

@ -0,0 +1,9 @@
// setjmp.hb
typedef char[160] jmp_buf;
typedef char[160] sigjmp_buf;
extern int setjmp(jmp_buf buf);
extern int sigsetjmp(sigjmp_buf buf, int savesigs);
extern void longjmp(jmp_buf buf, int value);
extern void siglongjmp(sigjmp_buf buf, int value);

34
test/setjmptest.cb Normal file
View File

@ -0,0 +1,34 @@
import stdio;
import setjmp;
int
main(void)
{
func1();
return 0;
}
static jmp_buf buf;
void
func1(void)
{
if (setjmp(buf) == 0) {
func2(buf);
}
puts("OK");
}
void
func2(jmp_buf buf)
{
func3(buf);
puts("func2: NG");
}
void
func3(jmp_buf buf)
{
longjmp(buf, 1);
puts("func3: NG");
}

View File

@ -323,6 +323,10 @@ test_36_alloca() {
assert_out "17;17;17;17" ./alloca2
}
test_37_setjmp() {
assert_out "OK" ./setjmptest
}
###
### Local Assertions
###