Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby31/include/ruby
File: assert.h
#ifndef RUBY_ASSERT_H /*-*-C++-*-vi:se ft=cpp:*/
[0] Fix | Delete
#define RUBY_ASSERT_H
[1] Fix | Delete
/**
[2] Fix | Delete
* @file
[3] Fix | Delete
* @author Ruby developers <ruby-core@ruby-lang.org>
[4] Fix | Delete
* @date Wed May 18 00:21:44 JST 1994
[5] Fix | Delete
* @copyright This file is a part of the programming language Ruby.
[6] Fix | Delete
* Permission is hereby granted, to either redistribute and/or
[7] Fix | Delete
* modify this file, provided that the conditions mentioned in the
[8] Fix | Delete
* file COPYING are met. Consult the file for details.
[9] Fix | Delete
* @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
[10] Fix | Delete
* implementation details. Don't take them as canon. They could
[11] Fix | Delete
* rapidly appear then vanish. The name (path) of this header file
[12] Fix | Delete
* is also an implementation detail. Do not expect it to persist
[13] Fix | Delete
* at the place it is now. Developers are free to move it anywhere
[14] Fix | Delete
* anytime at will.
[15] Fix | Delete
* @note To ruby-core: remember that this header can be possibly
[16] Fix | Delete
* recursively included from extension libraries written in C++.
[17] Fix | Delete
* Do not expect for instance `__VA_ARGS__` is always available.
[18] Fix | Delete
* We assume C99 for ruby itself but we don't assume languages of
[19] Fix | Delete
* extension libraries. They could be written in C++98.
[20] Fix | Delete
*/
[21] Fix | Delete
#include "ruby/internal/assume.h"
[22] Fix | Delete
#include "ruby/internal/attr/cold.h"
[23] Fix | Delete
#include "ruby/internal/attr/noreturn.h"
[24] Fix | Delete
#include "ruby/internal/cast.h"
[25] Fix | Delete
#include "ruby/internal/dllexport.h"
[26] Fix | Delete
#include "ruby/backward/2/assume.h"
[27] Fix | Delete
[28] Fix | Delete
/* RUBY_NDEBUG is very simple: after everything described below are done,
[29] Fix | Delete
* define it with either NDEBUG is undefined (=0) or defined (=1). It is truly
[30] Fix | Delete
* subordinate.
[31] Fix | Delete
*
[32] Fix | Delete
* RUBY_DEBUG versus NDEBUG is complicated. Assertions shall be:
[33] Fix | Delete
*
[34] Fix | Delete
* | -UNDEBUG | -DNDEBUG
[35] Fix | Delete
* ---------------+----------+---------
[36] Fix | Delete
* -URUBY_DEBUG | (*1) | disabled
[37] Fix | Delete
* -DRUBY_DEBUG=0 | disabled | disabled
[38] Fix | Delete
* -DRUBY_DEBUG=1 | enabled | (*2)
[39] Fix | Delete
* -DRUBY_DEBUG | enabled | (*2)
[40] Fix | Delete
*
[41] Fix | Delete
* where:
[42] Fix | Delete
*
[43] Fix | Delete
* - (*1): Assertions shall be silently disabled, no warnings, in favour of
[44] Fix | Delete
* commit 21991e6ca59274e41a472b5256bd3245f6596c90.
[45] Fix | Delete
*
[46] Fix | Delete
* - (*2): Compile-time warnings shall be issued.
[47] Fix | Delete
*/
[48] Fix | Delete
[49] Fix | Delete
/** @cond INTERNAL_MACRO */
[50] Fix | Delete
[51] Fix | Delete
/*
[52] Fix | Delete
* Pro tip: `!!RUBY_DEBUG-1` expands to...
[53] Fix | Delete
*
[54] Fix | Delete
* - `!!(-1)` (== `!0` == `1`) when RUBY_DEBUG is defined to be empty,
[55] Fix | Delete
* - `(!!0)-1` (== `0-1` == `-1`) when RUBY_DEBUG is defined as 0, and
[56] Fix | Delete
* - `(!!n)-1` (== `1-1` == `0`) when RUBY_DEBUG is defined as something else.
[57] Fix | Delete
*/
[58] Fix | Delete
#if ! defined(RUBY_DEBUG)
[59] Fix | Delete
# define RBIMPL_RUBY_DEBUG 0
[60] Fix | Delete
#elif !!RUBY_DEBUG-1 < 0
[61] Fix | Delete
# define RBIMPL_RUBY_DEBUG 0
[62] Fix | Delete
#else
[63] Fix | Delete
# define RBIMPL_RUBY_DEBUG 1
[64] Fix | Delete
#endif
[65] Fix | Delete
[66] Fix | Delete
/*
[67] Fix | Delete
* ISO/IEC 9899 (all past versions) says that "If NDEBUG is defined as a macro
[68] Fix | Delete
* name at the point in the source file where <assert.h> is included, ..."
[69] Fix | Delete
* which means we must not take its defined value into account.
[70] Fix | Delete
*/
[71] Fix | Delete
#if defined(NDEBUG)
[72] Fix | Delete
# define RBIMPL_NDEBUG 1
[73] Fix | Delete
#else
[74] Fix | Delete
# define RBIMPL_NDEBUG 0
[75] Fix | Delete
#endif
[76] Fix | Delete
[77] Fix | Delete
/** @endcond */
[78] Fix | Delete
[79] Fix | Delete
/* Here we go... */
[80] Fix | Delete
#undef RUBY_DEBUG
[81] Fix | Delete
#undef RUBY_NDEBUG
[82] Fix | Delete
#undef NDEBUG
[83] Fix | Delete
#if defined(__DOXYGEN__)
[84] Fix | Delete
# /** Define this macro when you want assertions. */
[85] Fix | Delete
# define RUBY_DEBUG 0
[86] Fix | Delete
# /** Define this macro when you don't want assertions. */
[87] Fix | Delete
# define NDEBUG
[88] Fix | Delete
# /** This macro is basically the same as #NDEBUG */
[89] Fix | Delete
# define RUBY_NDEBUG 1
[90] Fix | Delete
[91] Fix | Delete
#elif (RBIMPL_NDEBUG == 1) && (RBIMPL_RUBY_DEBUG == 0)
[92] Fix | Delete
# /* Assertions disabled as per request, no conflicts. */
[93] Fix | Delete
# define RUBY_DEBUG 0
[94] Fix | Delete
# define RUBY_NDEBUG 1
[95] Fix | Delete
# define NDEBUG
[96] Fix | Delete
[97] Fix | Delete
#elif (RBIMPL_NDEBUG == 0) && (RBIMPL_RUBY_DEBUG == 1)
[98] Fix | Delete
# /* Assertions enabled as per request, no conflicts. */
[99] Fix | Delete
# define RUBY_DEBUG 1
[100] Fix | Delete
# define RUBY_NDEBUG 0
[101] Fix | Delete
# /* keep NDEBUG undefined */
[102] Fix | Delete
[103] Fix | Delete
#elif (RBIMPL_NDEBUG == 0) && (RBIMPL_RUBY_DEBUG == 0)
[104] Fix | Delete
# /* The (*1) situation in avobe diagram. */
[105] Fix | Delete
# define RUBY_DEBUG 0
[106] Fix | Delete
# define RUBY_NDEBUG 1
[107] Fix | Delete
# define NDEBUG
[108] Fix | Delete
[109] Fix | Delete
#elif (RBIMPL_NDEBUG == 1) && (RBIMPL_RUBY_DEBUG == 1)
[110] Fix | Delete
# /* The (*2) situation in above diagram. */
[111] Fix | Delete
# define RUBY_DEBUG 1
[112] Fix | Delete
# define RUBY_NDEBUG 0
[113] Fix | Delete
# /* keep NDEBUG undefined */
[114] Fix | Delete
[115] Fix | Delete
# if defined(_MSC_VER)
[116] Fix | Delete
# pragma message("NDEBUG is ignored because RUBY_DEBUG>0.")
[117] Fix | Delete
# elif defined(__GNUC__)
[118] Fix | Delete
# pragma GCC warning "NDEBUG is ignored because RUBY_DEBUG>0."
[119] Fix | Delete
# else
[120] Fix | Delete
# error NDEBUG is ignored because RUBY_DEBUG>0.
[121] Fix | Delete
# endif
[122] Fix | Delete
#endif
[123] Fix | Delete
#undef RBIMPL_NDEBUG
[124] Fix | Delete
#undef RBIMPL_RUBY_DEBUG
[125] Fix | Delete
[126] Fix | Delete
/** @cond INTERNAL_MACRO */
[127] Fix | Delete
#define RBIMPL_ASSERT_NOTHING RBIMPL_CAST((void)0)
[128] Fix | Delete
[129] Fix | Delete
RBIMPL_SYMBOL_EXPORT_BEGIN()
[130] Fix | Delete
RBIMPL_ATTR_NORETURN()
[131] Fix | Delete
RBIMPL_ATTR_COLD()
[132] Fix | Delete
void rb_assert_failure(const char *file, int line, const char *name, const char *expr);
[133] Fix | Delete
RBIMPL_SYMBOL_EXPORT_END()
[134] Fix | Delete
[135] Fix | Delete
#ifdef RUBY_FUNCTION_NAME_STRING
[136] Fix | Delete
# define RBIMPL_ASSERT_FUNC RUBY_FUNCTION_NAME_STRING
[137] Fix | Delete
#else
[138] Fix | Delete
# define RBIMPL_ASSERT_FUNC RBIMPL_CAST((const char *)0)
[139] Fix | Delete
#endif
[140] Fix | Delete
[141] Fix | Delete
/** @endcond */
[142] Fix | Delete
[143] Fix | Delete
/**
[144] Fix | Delete
* Prints the given message, and terminates the entire process abnormally.
[145] Fix | Delete
*
[146] Fix | Delete
* @param mesg The message to display.
[147] Fix | Delete
*/
[148] Fix | Delete
#define RUBY_ASSERT_FAIL(mesg) \
[149] Fix | Delete
rb_assert_failure(__FILE__, __LINE__, RBIMPL_ASSERT_FUNC, mesg)
[150] Fix | Delete
[151] Fix | Delete
/**
[152] Fix | Delete
* Asserts that the expression is truthy. If not aborts with the message.
[153] Fix | Delete
*
[154] Fix | Delete
* @param expr What supposedly evaluates to true.
[155] Fix | Delete
* @param mesg The message to display on failure.
[156] Fix | Delete
*/
[157] Fix | Delete
#define RUBY_ASSERT_MESG(expr, mesg) \
[158] Fix | Delete
(RB_LIKELY(expr) ? RBIMPL_ASSERT_NOTHING : RUBY_ASSERT_FAIL(mesg))
[159] Fix | Delete
[160] Fix | Delete
/**
[161] Fix | Delete
* A variant of #RUBY_ASSERT that does not interface with #RUBY_DEBUG.
[162] Fix | Delete
*
[163] Fix | Delete
* @copydetails #RUBY_ASSERT
[164] Fix | Delete
*/
[165] Fix | Delete
#define RUBY_ASSERT_ALWAYS(expr) RUBY_ASSERT_MESG((expr), #expr)
[166] Fix | Delete
[167] Fix | Delete
/**
[168] Fix | Delete
* Asserts that the given expression is truthy if and only if #RUBY_DEBUG is truthy.
[169] Fix | Delete
*
[170] Fix | Delete
* @param expr What supposedly evaluates to true.
[171] Fix | Delete
*/
[172] Fix | Delete
#if RUBY_DEBUG
[173] Fix | Delete
# define RUBY_ASSERT(expr) RUBY_ASSERT_MESG((expr), #expr)
[174] Fix | Delete
#else
[175] Fix | Delete
# define RUBY_ASSERT(expr) RBIMPL_ASSERT_NOTHING
[176] Fix | Delete
#endif
[177] Fix | Delete
[178] Fix | Delete
/**
[179] Fix | Delete
* A variant of #RUBY_ASSERT that interfaces with #NDEBUG instead of
[180] Fix | Delete
* #RUBY_DEBUG. This almost resembles `assert` C standard macro, except minor
[181] Fix | Delete
* implementation details.
[182] Fix | Delete
*
[183] Fix | Delete
* @copydetails #RUBY_ASSERT
[184] Fix | Delete
*/
[185] Fix | Delete
/* Currently `RUBY_DEBUG == ! defined(NDEBUG)` is always true. There is no
[186] Fix | Delete
* difference any longer between this one and `RUBY_ASSERT`. */
[187] Fix | Delete
#if defined(NDEBUG)
[188] Fix | Delete
# define RUBY_ASSERT_NDEBUG(expr) RBIMPL_ASSERT_NOTHING
[189] Fix | Delete
#else
[190] Fix | Delete
# define RUBY_ASSERT_NDEBUG(expr) RUBY_ASSERT_MESG((expr), #expr)
[191] Fix | Delete
#endif
[192] Fix | Delete
[193] Fix | Delete
/**
[194] Fix | Delete
* @copydoc #RUBY_ASSERT_WHEN
[195] Fix | Delete
* @param mesg The message to display on failure.
[196] Fix | Delete
*/
[197] Fix | Delete
#if RUBY_DEBUG
[198] Fix | Delete
# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) RUBY_ASSERT_MESG((expr), (mesg))
[199] Fix | Delete
#else
[200] Fix | Delete
# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \
[201] Fix | Delete
((cond) ? RUBY_ASSERT_MESG((expr), (mesg)) : RBIMPL_ASSERT_NOTHING)
[202] Fix | Delete
#endif
[203] Fix | Delete
[204] Fix | Delete
/**
[205] Fix | Delete
* A variant of #RUBY_ASSERT that asserts when either #RUBY_DEBUG or `cond`
[206] Fix | Delete
* parameter is truthy.
[207] Fix | Delete
*
[208] Fix | Delete
* @param cond Extra condition that shall hold for assertion to take effect.
[209] Fix | Delete
* @param expr What supposedly evaluates to true.
[210] Fix | Delete
*/
[211] Fix | Delete
#define RUBY_ASSERT_WHEN(cond, expr) RUBY_ASSERT_MESG_WHEN((cond), (expr), #expr)
[212] Fix | Delete
[213] Fix | Delete
/**
[214] Fix | Delete
* This is either #RUBY_ASSERT or #RBIMPL_ASSUME, depending on #RUBY_DEBUG.
[215] Fix | Delete
*
[216] Fix | Delete
* @copydetails #RUBY_ASSERT
[217] Fix | Delete
*/
[218] Fix | Delete
#if RUBY_DEBUG
[219] Fix | Delete
# define RBIMPL_ASSERT_OR_ASSUME(expr) RUBY_ASSERT_ALWAYS(expr)
[220] Fix | Delete
#elif RBIMPL_COMPILER_BEFORE(Clang, 7, 0, 0)
[221] Fix | Delete
# /* See commit 67d259c5dccd31fe49d417fec169977712ffdf10 */
[222] Fix | Delete
# define RBIMPL_ASSERT_OR_ASSUME(expr) RBIMPL_ASSERT_NOTHING
[223] Fix | Delete
#elif defined(RUBY_ASSERT_NOASSUME)
[224] Fix | Delete
# /* See commit d300a734414ef6de7e8eb563b7cc4389c455ed08 */
[225] Fix | Delete
# define RBIMPL_ASSERT_OR_ASSUME(expr) RBIMPL_ASSERT_NOTHING
[226] Fix | Delete
#elif ! defined(RBIMPL_HAVE___ASSUME)
[227] Fix | Delete
# define RBIMPL_ASSERT_OR_ASSUME(expr) RBIMPL_ASSERT_NOTHING
[228] Fix | Delete
#else
[229] Fix | Delete
# define RBIMPL_ASSERT_OR_ASSUME(expr) RBIMPL_ASSUME(expr)
[230] Fix | Delete
#endif
[231] Fix | Delete
[232] Fix | Delete
#endif /* RUBY_ASSERT_H */
[233] Fix | Delete
[234] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function