diff options
author | Koichi Sasada <ko1@atdot.net> | 2020-05-20 11:38:44 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2020-05-26 03:21:14 +0900 |
commit | 21991e6ca59274e41a472b5256bd3245f6596c90 (patch) | |
tree | b4cf1b0f059dc2a5b49abd44f4487224d38d0cb7 /include/ruby/internal/arithmetic | |
parent | b10b37924aef33426ea6e2fda5ce17804796ecc4 (diff) |
Use RUBY_DEBUG instead of NDEBUG
Assertions in header files slows down an interpreter, so they should be
turned off by default (simple `make`). To enable them, define a macro
`RUBY_DEBUG=1` (e.g. `make cppflags=-DRUBY_DEBUG` or use `#define` at
the very beggining of the file. Note that even if `NDEBUG=1` is defined,
`RUBY_DEBUG=1` enables all assertions.
[Feature #16837]
related: https://github.com/ruby/ruby/pull/3120
`assert()` lines in MRI *.c is not disabled even if `RUBY_DEBUG=0` and
it can be disabled with `NDEBUG=1`. So please consider to use
`RUBY_ASSERT()` if you want to disable them when `RUBY_DEBUG=0`.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3124
Diffstat (limited to 'include/ruby/internal/arithmetic')
-rw-r--r-- | include/ruby/internal/arithmetic/char.h | 4 | ||||
-rw-r--r-- | include/ruby/internal/arithmetic/long.h | 20 | ||||
-rw-r--r-- | include/ruby/internal/arithmetic/st_data_t.h | 4 |
3 files changed, 14 insertions, 14 deletions
diff --git a/include/ruby/internal/arithmetic/char.h b/include/ruby/internal/arithmetic/char.h index 485bbd545c..3033639a43 100644 --- a/include/ruby/internal/arithmetic/char.h +++ b/include/ruby/internal/arithmetic/char.h @@ -37,8 +37,8 @@ #define RB_CHR2FIX RB_CHR2FIX /** @endcond */ -RBIMPL_ATTR_CONST_ON_NDEBUG() -RBIMPL_ATTR_CONSTEXPR_ON_NDEBUG(CXX14) +RBIMPL_ATTR_CONST_UNLESS_DEBUG() +RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(CXX14) RBIMPL_ATTR_ARTIFICIAL() static inline VALUE RB_CHR2FIX(unsigned char c) diff --git a/include/ruby/internal/arithmetic/long.h b/include/ruby/internal/arithmetic/long.h index c0235b9a64..aff7d68478 100644 --- a/include/ruby/internal/arithmetic/long.h +++ b/include/ruby/internal/arithmetic/long.h @@ -75,8 +75,8 @@ long rb_num2long(VALUE num); unsigned long rb_num2ulong(VALUE num); RBIMPL_SYMBOL_EXPORT_END() -RBIMPL_ATTR_CONST_ON_NDEBUG() -RBIMPL_ATTR_CONSTEXPR_ON_NDEBUG(CXX14) +RBIMPL_ATTR_CONST_UNLESS_DEBUG() +RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(CXX14) RBIMPL_ATTR_ARTIFICIAL() static inline VALUE RB_INT2FIX(long i) @@ -110,8 +110,8 @@ rb_long2int_inline(long n) return i; } -RBIMPL_ATTR_CONST_ON_NDEBUG() -RBIMPL_ATTR_CONSTEXPR_ON_NDEBUG(CXX14) +RBIMPL_ATTR_CONST_UNLESS_DEBUG() +RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(CXX14) static inline long rbimpl_fix2long_by_idiv(VALUE x) { @@ -128,8 +128,8 @@ rbimpl_fix2long_by_idiv(VALUE x) return w; } -RBIMPL_ATTR_CONST_ON_NDEBUG() -RBIMPL_ATTR_CONSTEXPR_ON_NDEBUG(CXX14) +RBIMPL_ATTR_CONST_UNLESS_DEBUG() +RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(CXX14) static inline long rbimpl_fix2long_by_shift(VALUE x) { @@ -153,8 +153,8 @@ rbimpl_right_shift_is_arithmetic_p(void) return (-1 >> 1) == -1; } -RBIMPL_ATTR_CONST_ON_NDEBUG() -RBIMPL_ATTR_CONSTEXPR_ON_NDEBUG(CXX14) +RBIMPL_ATTR_CONST_UNLESS_DEBUG() +RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(CXX14) static inline long rb_fix2long(VALUE x) { @@ -166,8 +166,8 @@ rb_fix2long(VALUE x) } } -RBIMPL_ATTR_CONST_ON_NDEBUG() -RBIMPL_ATTR_CONSTEXPR_ON_NDEBUG(CXX14) +RBIMPL_ATTR_CONST_UNLESS_DEBUG() +RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(CXX14) static inline unsigned long rb_fix2ulong(VALUE x) { diff --git a/include/ruby/internal/arithmetic/st_data_t.h b/include/ruby/internal/arithmetic/st_data_t.h index 01917ab3c0..93a5ccb7a1 100644 --- a/include/ruby/internal/arithmetic/st_data_t.h +++ b/include/ruby/internal/arithmetic/st_data_t.h @@ -35,8 +35,8 @@ #define RB_ST2FIX RB_ST2FIX /** @endcond */ -RBIMPL_ATTR_CONST_ON_NDEBUG() -RBIMPL_ATTR_CONSTEXPR_ON_NDEBUG(CXX14) +RBIMPL_ATTR_CONST_UNLESS_DEBUG() +RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(CXX14) RBIMPL_ATTR_ARTIFICIAL() /* See also [ruby-core:84395] [Bug #14218] [ruby-core:82687] [Bug #13877] */ static inline VALUE |