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/attr | |
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/attr')
-rw-r--r-- | include/ruby/internal/attr/const.h | 8 | ||||
-rw-r--r-- | include/ruby/internal/attr/constexpr.h | 8 | ||||
-rw-r--r-- | include/ruby/internal/attr/pure.h | 8 |
3 files changed, 12 insertions, 12 deletions
diff --git a/include/ruby/internal/attr/const.h b/include/ruby/internal/attr/const.h index ca9baa78a5..f3068f9f5e 100644 --- a/include/ruby/internal/attr/const.h +++ b/include/ruby/internal/attr/const.h @@ -36,11 +36,11 @@ # define RBIMPL_ATTR_CONST() /* void */ #endif -/** Enables #RBIMPL_ATTR_CONST iff. #RUBY_NDEBUG. */ -#if RUBY_NDEBUG -# define RBIMPL_ATTR_CONST_ON_NDEBUG() RBIMPL_ATTR_CONST() +/** Enables #RBIMPL_ATTR_CONST iff. !RUBY_DEBUG. */ +#if !RUBY_DEBUG +# define RBIMPL_ATTR_CONST_UNLESS_DEBUG() RBIMPL_ATTR_CONST() #else -# define RBIMPL_ATTR_CONST_ON_NDEBUG() /* void */ +# define RBIMPL_ATTR_CONST_UNLESS_DEBUG() /* void */ #endif #endif /* RBIMPL_ATTR_CONST_H */ diff --git a/include/ruby/internal/attr/constexpr.h b/include/ruby/internal/attr/constexpr.h index 0ccd8f2b0f..6d81d342a2 100644 --- a/include/ruby/internal/attr/constexpr.h +++ b/include/ruby/internal/attr/constexpr.h @@ -75,11 +75,11 @@ # define RBIMPL_ATTR_CONSTEXPR(_) /* void */ #endif -/** Enables #RBIMPL_ATTR_CONSTEXPR iff. #RUBY_NDEBUG. */ -#if RUBY_NDEBUG -# define RBIMPL_ATTR_CONSTEXPR_ON_NDEBUG(_) RBIMPL_ATTR_CONSTEXPR(_) +/** Enables #RBIMPL_ATTR_CONSTEXPR iff. !RUBY_DEBUG. */ +#if !RUBY_DEBUG +# define RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(_) RBIMPL_ATTR_CONSTEXPR(_) #else -# define RBIMPL_ATTR_CONSTEXPR_ON_NDEBUG(_) /* void */ +# define RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(_) /* void */ #endif #endif /* RBIMPL_ATTR_CONSTEXPR_H */ diff --git a/include/ruby/internal/attr/pure.h b/include/ruby/internal/attr/pure.h index b6aca7b720..b27adaa840 100644 --- a/include/ruby/internal/attr/pure.h +++ b/include/ruby/internal/attr/pure.h @@ -33,11 +33,11 @@ # define RBIMPL_ATTR_PURE() /* void */ #endif -/** Enables #RBIMPL_ATTR_PURE iff. #RUBY_NDEBUG. */ -#if RUBY_NDEBUG -# define RBIMPL_ATTR_PURE_ON_NDEBUG() RBIMPL_ATTR_PURE() +/** Enables #RBIMPL_ATTR_PURE iff. !RUBY_DEBUG. */ +#if !RUBY_DEBUG +# define RBIMPL_ATTR_PURE_UNLESS_DEBUG() RBIMPL_ATTR_PURE() #else -# define RBIMPL_ATTR_PURE_ON_NDEBUG() /* void */ +# define RBIMPL_ATTR_PURE_UNLESS_DEBUG() /* void */ #endif #endif /* RBIMPL_ATTR_PURE_H */ |