summaryrefslogtreecommitdiff
path: root/include/ruby/assert.h
AgeCommit message (Collapse)Author
2021-01-19Replace "iff" with "if and only if"Gannon McGibbon
iff means if and only if, but readers without that knowledge might assume this to be a spelling mistake. To me, this seems like exclusionary language that is unnecessary. Simply using "if and only if" instead should suffice. Notes: Merged: https://github.com/ruby/ruby/pull/4035
2020-08-07sync NDEBUG, RUBY_DEBUG, and RUBY_NDEBUG (#3327)卜部昌平
- When NDEBUG is defined that shall be honoured. - When RUBY_DEBUG is defined that shall be honoured. - When both are defined and they conflict, warnings shall be rendered. - When nothing is specified, nothing shall happen. Notes: Merged-By: shyouhei <shyouhei@ruby-lang.org>
2020-05-29RUBY_ASSERT_NOASSUMEKoichi Sasada
If __builtin_assume() is enables and RUBY_DEBUG=0, RUBY_ASSERT(expr) will be compiled to __builtin_assume(expr) and compiler can assume expr is true and apply aggressive optimizations. However we observed doubtful behavior because of compiler optimizations, we introduce new macro RUBY_ASSERT_NOASSUME to disable __builtin_assume(). With this macro, we can try without __builtin_assume().
2020-05-27Removed a trailing space [ci skip]Nobuyoshi Nakada
2020-05-26Update include/ruby/assert.hKoichi Sasada
Co-authored-by: 卜部昌平 <shyouhei@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/3124
2020-05-26Use RUBY_DEBUG instead of NDEBUGKoichi Sasada
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: Merged: https://github.com/ruby/ruby/pull/3124
2020-05-20Use __bultin_assume() from clang-7Koichi Sasada
We observed combination of multiple __builtin_assume() can cause strange compile results on clang-6 (-DNDEBUG exposed this issue). To avoid this problem, __builtin_assume() is from clang-7. https://github.com/ruby/ruby/pull/3120#issuecomment-630821333 Notes: Merged: https://github.com/ruby/ruby/pull/3122
2020-05-12Removed extra stringizationNobuyoshi Nakada
Argument of RUBY_ASSERT_FAIL is already stringized message, so no more extra stringization should be applied.
2020-05-11sed -i 's|ruby/impl|ruby/internal|'卜部昌平
To fix build failures. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-11sed -i s/ruby3/rbimpl/g卜部昌平
Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-11sed -i s/RUBY3/RBIMPL/g卜部昌平
Devs do not love "3". The only exception is RUBY3_KEYWORDS in parse.y, which seems unrelated to our interests. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-11sed -i s|ruby/3|ruby/impl|g卜部昌平
This shall fix compile errors. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-04-13add #include guard hack卜部昌平
According to MSVC manual (*1), cl.exe can skip including a header file when that: - contains #pragma once, or - starts with #ifndef, or - starts with #if ! defined. GCC has a similar trick (*2), but it acts more stricter (e. g. there must be _no tokens_ outside of #ifndef...#endif). Sun C lacked #pragma once for a looong time. Oracle Developer Studio 12.5 finally implemented it, but we cannot assume such recent version. This changeset modifies header files so that each of them include strictly one #ifndef...#endif. I believe this is the most portable way to trigger compiler optimizations. [Bug #16770] *1: https://docs.microsoft.com/en-us/cpp/preprocessor/once *2: https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html Notes: Merged: https://github.com/ruby/ruby/pull/3023
2020-04-08Merge pull request #2991 from shyouhei/ruby.h卜部昌平
Split ruby.h Notes: Merged-By: shyouhei <shyouhei@ruby-lang.org>
2019-08-05Revert "Always evaluate the expression RUBY_ASSERT_MESG_WHEN just once"Nobuyoshi Nakada
It caused a significant benchmark fall. Some assertions seem to use expressions with side-effects which cannot be inlined. This reverts commit b452c03a14f943ae25338547bd680fce67399d85.
2019-07-15Always evaluate the expression RUBY_ASSERT_MESG_WHEN just onceNobuyoshi Nakada
2019-07-15Enable RUBY_ASSERT_MESG_WHEN when RUBY_DEBUG is turned onNobuyoshi Nakada
2019-07-15introduce RUBY_ASSERT_ALWAYS(expr).Koichi Sasada
RUBY_ASSERT_ALWAYS(expr) ignores NDEBUG (we cannot remove this assertion).
2019-07-14Introduce RUBY_DEBUG flag macroNobuyoshi Nakada
When RUBY_DEBUG is turned on, all RUBY_ASSERT() macros will be enabled regardless RUBY_NDEBUG.
2019-07-14* expand tabs.git
2019-07-14Split RUBY_ASSERT and so on under include/rubyNobuyoshi Nakada