diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-01-01 10:15:55 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-01-01 10:15:55 +0900 |
| commit | 4683b89b84cd5999847e2a9bc3f05a4732cc81a3 (patch) | |
| tree | b69b6d316245a4d7ae9ba406257d23df41d5f02a | |
| parent | 38b9c2d3085e6d300ec36b5a38e31f8b4927c4fc (diff) | |
| parent | 121c6e30aafdc05a7b0a25b85fe663d07c1bfcab (diff) | |
| download | mruby-4683b89b84cd5999847e2a9bc3f05a4732cc81a3.tar.gz mruby-4683b89b84cd5999847e2a9bc3f05a4732cc81a3.zip | |
Merge pull request #3068 from kazuho/kazuho/osx-_setjmp
use _setjmp/_longjmp on OS X
| -rw-r--r-- | include/mruby/throw.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/include/mruby/throw.h b/include/mruby/throw.h index 7f720d512..e4b0f1f2b 100644 --- a/include/mruby/throw.h +++ b/include/mruby/throw.h @@ -20,11 +20,19 @@ typedef mrb_int mrb_jmpbuf_impl; #include <setjmp.h> -#define MRB_TRY(buf) do { if (setjmp((buf)->impl) == 0) { +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#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 |
