LibC: Implement {sig,_,}{longjmp,setjmp}

This commit is contained in:
2024-08-07 17:03:26 +03:00
parent 91d513a672
commit 6fedf06150
8 changed files with 113 additions and 6 deletions

View 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)

View 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();
}