forked from Bananymous/banan-os
LibC: Implement {sig,_,}{longjmp,setjmp}
This commit is contained in:
@@ -5,6 +5,7 @@ set(USERSPACE_TESTS
|
||||
test-mmap-shared
|
||||
test-mouse
|
||||
test-popen
|
||||
test-setjmp
|
||||
test-sort
|
||||
test-tcp
|
||||
test-udp
|
||||
|
||||
8
userspace/tests/test-setjmp/CMakeLists.txt
Normal file
8
userspace/tests/test-setjmp/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
set(SOURCES
|
||||
main.cpp
|
||||
)
|
||||
|
||||
add_executable(test-setjmp ${SOURCES})
|
||||
banan_link_library(test-setjmp libc)
|
||||
|
||||
install(TARGETS test-setjmp OPTIONAL)
|
||||
22
userspace/tests/test-setjmp/main.cpp
Normal file
22
userspace/tests/test-setjmp/main.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
|
||||
jmp_buf env;
|
||||
|
||||
void iterate()
|
||||
{
|
||||
static volatile int count = 0;
|
||||
if (count < 10)
|
||||
{
|
||||
count = count + 1;
|
||||
longjmp(env, count);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("start\n");
|
||||
if (int ret = setjmp(env))
|
||||
printf("longjmp %d\n", ret);
|
||||
iterate();
|
||||
}
|
||||
Reference in New Issue
Block a user