From f4bb329c748a9c1de2a373b5ddeb1e4baf6ac8d8 Mon Sep 17 00:00:00 2001 From: Kazuho Oku Date: Fri, 1 Jan 2016 06:24:49 +0900 Subject: use _setjmp/_longjmp on OS X --- include/mruby/throw.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/mruby/throw.h b/include/mruby/throw.h index 7f720d512..77ef5ac21 100644 --- a/include/mruby/throw.h +++ b/include/mruby/throw.h @@ -20,11 +20,19 @@ typedef mrb_int mrb_jmpbuf_impl; #include -#define MRB_TRY(buf) do { if (setjmp((buf)->impl) == 0) { +#if defined(__APPLE__) +#define MRB_SETJMP _setjmp +#define MRB_LONGJMP _longjmp +#else +#define MRB_SETJMP setjmp +#define MRB_LONGJMP longjmp +#endif + +#define MRB_TRY(buf) do { if (MRB_SETJMP((buf)->impl) == 0) { #define MRB_CATCH(buf) } else { #define MRB_END_EXC(buf) } } while(0) -#define MRB_THROW(buf) longjmp((buf)->impl, 1); +#define MRB_THROW(buf) MRB_LONGJMP((buf)->impl, 1); #define mrb_jmpbuf_impl jmp_buf #endif -- cgit v1.2.3