Commit Graph

18 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto d9a7d1a6b0 throw.h: add warning about internal-only usage; ref #6702
Document that this header is for mruby core internal use only and
should not be included in user code or mrbgems. When MRB_USE_CXX_EXCEPTION
is defined, C source files including this header fail to compile.
Add example showing mrb_protect_error() as the recommended alternative.

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-13 21:21:08 +09:00
Yukihiro "Matz" Matsumoto f4d6e67656 throw.h: exclude arm64 from mingw64 builtin setjmp/longjmp; fix #6637
__builtin_setjmp/longjmp are x86/x86_64 specific gcc intrinsics
and not supported on arm64. windows arm64 with msys2 clangarm64
now correctly falls through to standard setjmp/longjmp.

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-13 08:41:34 +09:00
dearblue c112e83b5d Removed mrb_jmpbuf_id for C++ exceptions
Use stack variable addresses as identifiers instead of global variable values.
Since the stack variable address is uniquely determined within the call, there is no need to maintain a global variable.
2024-01-21 13:14:41 +09:00
Yukihiro "Matz" Matsumoto 4fc69ce3bc Revert "mruby/throw.h: do not use __builtin_setjmp for GCC; close #5950"
This reverts commit 9cf49d08b4.

This change caused flaky tests on MinGW. I now remember it was introduced
for MINGW64 to address #5133. Sorry.
2023-03-14 19:50:15 +09:00
Yukihiro "Matz" Matsumoto 9cf49d08b4 mruby/throw.h: do not use __builtin_setjmp for GCC; close #5950
https://gcc.gnu.org/onlinedocs/gcc/Nonlocal-Gotos.html
2023-03-13 08:05:55 +09:00
Yukihiro "Matz" Matsumoto e3dd65f761 throw.h: simplified a compilation conditional. 2022-11-02 14:22:04 +09:00
Yukihiro "Matz" Matsumoto 37fac6c089 throw.h: avoid using static member in C++ struct; fix #5846
The initialization causes linkage error with gcc (not clang), caused by
the following gcc bug:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86254
2022-11-02 14:22:03 +09:00
Yukihiro "Matz" Matsumoto 7f5e257f77 Use __builtin_setjmp(), __builtin_longjmp() on MinGW; fix #5133 2020-11-26 20:48:26 +09:00
KOBAYASHI Shuji 3d056d084a Rename MRB_{ENABLE,DISABLE}_ to MRB_{USE,NO}_; close #5163
|        Previous Name         |        New Name         |
|------------------------------|-------------------------|
| MRB_ENABLE_ALL_SYMBOLS       | MRB_USE_ALL_SYMBOLS     |
| MRB_ENABLE_SYMBOLL_ALL       | MRB_USE_ALL_SYMBOLS     |
| MRB_ENABLE_CXX_ABI           | MRB_USE_CXX_ABI         |
| MRB_ENABLE_CXX_EXCEPTION     | MRB_USE_CXX_EXCEPTION   |
| MRB_ENABLE_DEBUG_HOOK        | MRB_USE_DEBUG_HOOK      |
| MRB_DISABLE_DIRECT_THREADING | MRB_NO_DIRECT_THREADING |
| MRB_DISABLE_STDIO            | MRB_NO_STDIO            |
| ENABLE_LINENOISE             | MRB_USE_LINENOISE       |
| ENABLE_READLINE              | MRB_USE_READLINE        |
| DISABLE_MIRB_UNDERSCORE      | MRB_NO_MIRB_UNDERSCORE  |
| DISABLE_GEMS                 | MRB_NO_GEMS             |

* `MRB_ENABLE_SYMBOLL_ALL` seems to be a typo, so it is fixed.
* `MRB_` prefix is added to those without.
* The previous names can also be used for compatibility.
2020-11-21 21:14:40 +09:00
Yukihiro "Matz" Matsumoto 5069fb15e4 Cause error explicitly from MRB_TRY() with cxx_exception; ref #5088
`MRB_TRY()` does not work when compiled by C compiler with `cxx_exception`
configuration. We should explicitly warn.
2020-10-12 18:20:29 +09:00
David Siaw b5299b1c58 fix up documentation for values 2019-08-18 20:12:44 +09:00
Yukihiro "Matz" Matsumoto 91bf55bbe5 Remove do { ... } while(0) hacks from MRB_TRY macros.
Because it can swallow `break` etc. if they are used in loops.
2018-11-25 06:05:07 +09:00
Yukihiro "Matz" Matsumoto 0bcf9e28fc Reorganize C++ exceptions; ref #3470
There are 3 levels of C++ exception handling:
* default - no C++ exception (use setjmp/longjmp)
* enable_cxx_exception (use C++ exceptions with C ABI)
* enable_cxx_abi (use C++ ABI including exceptions)
2017-03-02 10:58:26 +09:00
Tomasz Dąbrowski 00e6121260 Safeguard against trying to use C++ exception handling in C code 2016-11-24 09:28:00 +09:00
Junichi Kajiwara f67631afb4 C doesn't have try-catch 2016-07-08 06:30:45 +09:00
Kazuho Oku 121c6e30aa use _setjmp/_longjmp on other BSD flavors 2016-01-01 06:48:53 +09:00
Kazuho Oku f4bb329c74 use _setjmp/_longjmp on OS X 2016-01-01 06:24:49 +09:00
take_cheeze 6498d90f1b Move "src/mrb_throw.h" to "include/mruby/throw.h".
Related to #2760.
2015-05-25 21:19:24 +09:00