From 9b5c23e7c88535f49dfbc8d5028ff5c82704435a Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 27 Sep 2023 21:08:08 -0700 Subject: Integration with setjmp/longjmp. Defining libpng bindings, with longjmp catching, is now possible. * autoload.c (ffi_set_entries): Add setjmp symbol, which is a new macro in stdlib/ffi.tl. * ffi.c (jmp_buf_s): New symbol variable. (mk_jmp_buf, rt_setjmp, longjmp_wrap): New functions. (ffi_init): Initialize jmp_buf_s. Register sys:rt-setjmp and longjmp intrinsics. * ffi.h (jmp_buf_s): Declared. * stdlib/ffi.h (setjmp): New macro. Rather than introducing a new special operator, we use a run-time support function called sys:rt-setjmp, which takes functional arguments. * unwind.[ch] (uw_snapshot, uw_restore): New functions. The rt_setjmp function needs these to restore our unwind frame stack into a sane state after catching a longjmp, which bails without unwinding it, leaving the pointers referring to frames that no longer exist. * tests/017/setjmp.tl, * tests/017/setjmp.expected: New files. * txr.1: Documented. --- autoload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'autoload.c') diff --git a/autoload.c b/autoload.c index fef8ab0d..a939cbfc 100644 --- a/autoload.c +++ b/autoload.c @@ -575,7 +575,7 @@ static val ffi_set_entries(val fun) lit("deffi-union"), lit("typedef"), lit("sizeof"), lit("alignof"), lit("offsetof"), lit("arraysize"), lit("elemsize"), lit("elemtype"), lit("ffi"), lit("carray-ref"), lit("carray-sub"), - lit("sub-buf"), lit("znew"), + lit("sub-buf"), lit("znew"), lit("setjmp"), nil }; autoload_set(al_fun, name, fun); -- cgit v1.2.3