ref: c5c81ebe977ed73579d6c75846447fdb83177ed2
parent: 586508d8b8b602bc87b8b7ed5d21c68d522d9e78
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Wed Feb 12 20:50:02 EST 2025
use sigsetjmp/siglongjmp on posix
--- a/src/dos/platform.h
+++ b/src/dos/platform.h
@@ -32,6 +32,9 @@
#define USED(x) ((void)(x))
#define nelem(x) (int)(sizeof(x)/sizeof((x)[0]))
+#define fl_setjmp(e) setjmp((e))
+#define fl_longjmp(e, v) longjmp((e), (v))
+
#define PATHSEP '\\'
#define PATHSEPSTRING "\\"
#define PATHLISTSEP ':'
--- a/src/flisp.c
+++ b/src/flisp.c
@@ -75,7 +75,7 @@
fl_exception_context_t _ctx; int l__tr, l__ca; \
_ctx.sp = FL(sp); _ctx.frame = FL(curr_frame); _ctx.rdst = FL(readstate); _ctx.prev = FL(exctx); \
_ctx.ngchnd = FL(ngchandles); FL(exctx) = &_ctx; \
- if(!setjmp(_ctx.buf)) \
+ if(!fl_setjmp(_ctx.buf)) \
for(l__tr = 1; l__tr; l__tr = 0, (void)(FL(exctx) = FL(exctx)->prev))
#define FL_CATCH_INC \
@@ -126,7 +126,7 @@
fl_exception_context_t *thisctx = FL(exctx);
if(FL(exctx)->prev) // don't throw past toplevel
FL(exctx) = FL(exctx)->prev;
- longjmp(thisctx->buf, 1);
+ fl_longjmp(thisctx->buf, 1);
}
_Noreturn void
--- a/src/flisp.h
+++ b/src/flisp.h
@@ -251,8 +251,8 @@
#define FL_TRY_EXTERN \
fl_exception_context_t _ctx; int l__tr, l__ca; \
fl_savestate(&_ctx); FL(exctx) = &_ctx; \
- if(!setjmp(_ctx.buf)) \
- for(l__tr=1; l__tr; l__tr=0, (void)(FL(exctx) = FL(exctx)->prev))
+ if(!fl_setjmp(_ctx.buf)) \
+ for(l__tr = 1; l__tr; l__tr = 0, (void)(FL(exctx) = FL(exctx)->prev))
#define FL_CATCH_EXTERN_NO_RESTORE \
else \
--- a/src/macos/platform.h
+++ b/src/macos/platform.h
@@ -34,6 +34,9 @@
#define USED(x) ((void)(x))
#define nelem(x) (int)(sizeof(x)/sizeof((x)[0]))
+#define fl_setjmp(e) setjmp((e))
+#define fl_longjmp(e, v) longjmp((e), (v))
+
#define PATHSEP '/'
#define PATHSEPSTRING "/"
#define PATHLISTSEP ':'
--- a/src/plan9/platform.h
+++ b/src/plan9/platform.h
@@ -25,6 +25,9 @@
int fl_popcount(unsigned int w);
int fl_clz(unsigned int x);
+#define fl_setjmp(e) setjmp((e))
+#define fl_longjmp(e, v) longjmp((e), (v))
+
extern double D_PNAN, D_PINF;
#if defined(__amd64__) || \
--- a/src/posix/platform.h
+++ b/src/posix/platform.h
@@ -61,6 +61,9 @@
#endif
#endif
+#define fl_setjmp(e) sigsetjmp((e), 0)
+#define fl_longjmp(e, v) siglongjmp((e), (v))
+
#define nil NULL
#define USED(x) ((void)(x))
#define nelem(x) (int)(sizeof(x)/sizeof((x)[0]))