diff --git a/common.mk b/common.mk old mode 100755 new mode 100644 index 8f123e54c6..b94be35d47 --- a/common.mk +++ b/common.mk @@ -1533,6 +1533,7 @@ addr2line.$(OBJEXT): {$(VPATH)}missing.h array.$(OBJEXT): $(hdrdir)/ruby.h array.$(OBJEXT): $(hdrdir)/ruby/ruby.h array.$(OBJEXT): {$(VPATH)}array.c +array.$(OBJEXT): {$(VPATH)}assert.h array.$(OBJEXT): {$(VPATH)}config.h array.$(OBJEXT): {$(VPATH)}debug_counter.h array.$(OBJEXT): {$(VPATH)}defines.h @@ -1558,6 +1559,7 @@ ast.$(OBJEXT): $(CCAN_DIR)/list/list.h ast.$(OBJEXT): $(CCAN_DIR)/str/str.h ast.$(OBJEXT): $(hdrdir)/ruby.h ast.$(OBJEXT): $(hdrdir)/ruby/ruby.h +ast.$(OBJEXT): {$(VPATH)}assert.h ast.$(OBJEXT): {$(VPATH)}ast.c ast.$(OBJEXT): {$(VPATH)}config.h ast.$(OBJEXT): {$(VPATH)}defines.h @@ -1582,6 +1584,7 @@ ast.$(OBJEXT): {$(VPATH)}vm_core.h ast.$(OBJEXT): {$(VPATH)}vm_opts.h bignum.$(OBJEXT): $(hdrdir)/ruby.h bignum.$(OBJEXT): $(hdrdir)/ruby/ruby.h +bignum.$(OBJEXT): {$(VPATH)}assert.h bignum.$(OBJEXT): {$(VPATH)}bignum.c bignum.$(OBJEXT): {$(VPATH)}config.h bignum.$(OBJEXT): {$(VPATH)}defines.h @@ -1604,6 +1607,7 @@ class.$(OBJEXT): $(CCAN_DIR)/list/list.h class.$(OBJEXT): $(CCAN_DIR)/str/str.h class.$(OBJEXT): $(hdrdir)/ruby.h class.$(OBJEXT): $(hdrdir)/ruby/ruby.h +class.$(OBJEXT): {$(VPATH)}assert.h class.$(OBJEXT): {$(VPATH)}class.c class.$(OBJEXT): {$(VPATH)}config.h class.$(OBJEXT): {$(VPATH)}constant.h @@ -1643,6 +1647,7 @@ compile.$(OBJEXT): $(CCAN_DIR)/list/list.h compile.$(OBJEXT): $(CCAN_DIR)/str/str.h compile.$(OBJEXT): $(hdrdir)/ruby.h compile.$(OBJEXT): $(hdrdir)/ruby/ruby.h +compile.$(OBJEXT): {$(VPATH)}assert.h compile.$(OBJEXT): {$(VPATH)}compile.c compile.$(OBJEXT): {$(VPATH)}config.h compile.$(OBJEXT): {$(VPATH)}defines.h @@ -1680,6 +1685,7 @@ compile.$(OBJEXT): {$(VPATH)}vm_debug.h compile.$(OBJEXT): {$(VPATH)}vm_opts.h complex.$(OBJEXT): $(hdrdir)/ruby.h complex.$(OBJEXT): $(hdrdir)/ruby/ruby.h +complex.$(OBJEXT): {$(VPATH)}assert.h complex.$(OBJEXT): {$(VPATH)}complex.c complex.$(OBJEXT): {$(VPATH)}config.h complex.$(OBJEXT): {$(VPATH)}defines.h @@ -1701,6 +1707,7 @@ cont.$(OBJEXT): $(CCAN_DIR)/str/str.h cont.$(OBJEXT): $(hdrdir)/ruby.h cont.$(OBJEXT): $(hdrdir)/ruby/ruby.h cont.$(OBJEXT): {$(VPATH)}$(COROUTINE_H) +cont.$(OBJEXT): {$(VPATH)}assert.h cont.$(OBJEXT): {$(VPATH)}config.h cont.$(OBJEXT): {$(VPATH)}cont.c cont.$(OBJEXT): {$(VPATH)}debug_counter.h @@ -1733,6 +1740,7 @@ debug.$(OBJEXT): $(CCAN_DIR)/list/list.h debug.$(OBJEXT): $(CCAN_DIR)/str/str.h debug.$(OBJEXT): $(hdrdir)/ruby.h debug.$(OBJEXT): $(hdrdir)/ruby/ruby.h +debug.$(OBJEXT): {$(VPATH)}assert.h debug.$(OBJEXT): {$(VPATH)}config.h debug.$(OBJEXT): {$(VPATH)}debug.c debug.$(OBJEXT): {$(VPATH)}defines.h @@ -1867,6 +1875,7 @@ enc/utf_8.$(OBJEXT): {$(VPATH)}oniguruma.h enc/utf_8.$(OBJEXT): {$(VPATH)}regenc.h encoding.$(OBJEXT): $(hdrdir)/ruby.h encoding.$(OBJEXT): $(hdrdir)/ruby/ruby.h +encoding.$(OBJEXT): {$(VPATH)}assert.h encoding.$(OBJEXT): {$(VPATH)}config.h encoding.$(OBJEXT): {$(VPATH)}defines.h encoding.$(OBJEXT): {$(VPATH)}encindex.h @@ -1922,6 +1931,7 @@ error.$(OBJEXT): $(CCAN_DIR)/list/list.h error.$(OBJEXT): $(CCAN_DIR)/str/str.h error.$(OBJEXT): $(hdrdir)/ruby.h error.$(OBJEXT): $(hdrdir)/ruby/ruby.h +error.$(OBJEXT): {$(VPATH)}assert.h error.$(OBJEXT): {$(VPATH)}config.h error.$(OBJEXT): {$(VPATH)}defines.h error.$(OBJEXT): {$(VPATH)}encoding.h @@ -1951,6 +1961,7 @@ eval.$(OBJEXT): $(CCAN_DIR)/list/list.h eval.$(OBJEXT): $(CCAN_DIR)/str/str.h eval.$(OBJEXT): $(hdrdir)/ruby.h eval.$(OBJEXT): $(hdrdir)/ruby/ruby.h +eval.$(OBJEXT): {$(VPATH)}assert.h eval.$(OBJEXT): {$(VPATH)}config.h eval.$(OBJEXT): {$(VPATH)}debug_counter.h eval.$(OBJEXT): {$(VPATH)}defines.h @@ -2012,6 +2023,7 @@ gc.$(OBJEXT): $(CCAN_DIR)/list/list.h gc.$(OBJEXT): $(CCAN_DIR)/str/str.h gc.$(OBJEXT): $(hdrdir)/ruby.h gc.$(OBJEXT): $(hdrdir)/ruby/ruby.h +gc.$(OBJEXT): {$(VPATH)}assert.h gc.$(OBJEXT): {$(VPATH)}config.h gc.$(OBJEXT): {$(VPATH)}constant.h gc.$(OBJEXT): {$(VPATH)}debug.h @@ -2057,6 +2069,7 @@ golf_prelude.$(OBJEXT): $(CCAN_DIR)/list/list.h golf_prelude.$(OBJEXT): $(CCAN_DIR)/str/str.h golf_prelude.$(OBJEXT): $(hdrdir)/ruby.h golf_prelude.$(OBJEXT): $(hdrdir)/ruby/ruby.h +golf_prelude.$(OBJEXT): {$(VPATH)}assert.h golf_prelude.$(OBJEXT): {$(VPATH)}config.h golf_prelude.$(OBJEXT): {$(VPATH)}defines.h golf_prelude.$(OBJEXT): {$(VPATH)}encoding.h @@ -2096,6 +2109,7 @@ goruby.$(OBJEXT): {$(VPATH)}subst.h goruby.$(OBJEXT): {$(VPATH)}vm_debug.h hash.$(OBJEXT): $(hdrdir)/ruby.h hash.$(OBJEXT): $(hdrdir)/ruby/ruby.h +hash.$(OBJEXT): {$(VPATH)}assert.h hash.$(OBJEXT): {$(VPATH)}config.h hash.$(OBJEXT): {$(VPATH)}debug_counter.h hash.$(OBJEXT): {$(VPATH)}defines.h @@ -2137,6 +2151,7 @@ io.$(OBJEXT): $(CCAN_DIR)/list/list.h io.$(OBJEXT): $(CCAN_DIR)/str/str.h io.$(OBJEXT): $(hdrdir)/ruby.h io.$(OBJEXT): $(hdrdir)/ruby/ruby.h +io.$(OBJEXT): {$(VPATH)}assert.h io.$(OBJEXT): {$(VPATH)}config.h io.$(OBJEXT): {$(VPATH)}defines.h io.$(OBJEXT): {$(VPATH)}dln.h @@ -2168,6 +2183,7 @@ iseq.$(OBJEXT): $(CCAN_DIR)/list/list.h iseq.$(OBJEXT): $(CCAN_DIR)/str/str.h iseq.$(OBJEXT): $(hdrdir)/ruby.h iseq.$(OBJEXT): $(hdrdir)/ruby/ruby.h +iseq.$(OBJEXT): {$(VPATH)}assert.h iseq.$(OBJEXT): {$(VPATH)}config.h iseq.$(OBJEXT): {$(VPATH)}debug_counter.h iseq.$(OBJEXT): {$(VPATH)}defines.h @@ -2207,6 +2223,7 @@ load.$(OBJEXT): $(CCAN_DIR)/list/list.h load.$(OBJEXT): $(CCAN_DIR)/str/str.h load.$(OBJEXT): $(hdrdir)/ruby.h load.$(OBJEXT): $(hdrdir)/ruby/ruby.h +load.$(OBJEXT): {$(VPATH)}assert.h load.$(OBJEXT): {$(VPATH)}config.h load.$(OBJEXT): {$(VPATH)}defines.h load.$(OBJEXT): {$(VPATH)}dln.h @@ -2323,6 +2340,7 @@ mjit.$(OBJEXT): $(CCAN_DIR)/list/list.h mjit.$(OBJEXT): $(CCAN_DIR)/str/str.h mjit.$(OBJEXT): $(hdrdir)/ruby.h mjit.$(OBJEXT): $(hdrdir)/ruby/ruby.h +mjit.$(OBJEXT): {$(VPATH)}assert.h mjit.$(OBJEXT): {$(VPATH)}config.h mjit.$(OBJEXT): {$(VPATH)}constant.h mjit.$(OBJEXT): {$(VPATH)}debug.h @@ -2357,6 +2375,7 @@ mjit_compile.$(OBJEXT): $(CCAN_DIR)/list/list.h mjit_compile.$(OBJEXT): $(CCAN_DIR)/str/str.h mjit_compile.$(OBJEXT): $(hdrdir)/ruby.h mjit_compile.$(OBJEXT): $(hdrdir)/ruby/ruby.h +mjit_compile.$(OBJEXT): {$(VPATH)}assert.h mjit_compile.$(OBJEXT): {$(VPATH)}config.h mjit_compile.$(OBJEXT): {$(VPATH)}debug_counter.h mjit_compile.$(OBJEXT): {$(VPATH)}defines.h @@ -2389,6 +2408,7 @@ node.$(OBJEXT): $(CCAN_DIR)/list/list.h node.$(OBJEXT): $(CCAN_DIR)/str/str.h node.$(OBJEXT): $(hdrdir)/ruby.h node.$(OBJEXT): $(hdrdir)/ruby/ruby.h +node.$(OBJEXT): {$(VPATH)}assert.h node.$(OBJEXT): {$(VPATH)}config.h node.$(OBJEXT): {$(VPATH)}defines.h node.$(OBJEXT): {$(VPATH)}encoding.h @@ -2492,6 +2512,7 @@ prelude.$(OBJEXT): $(CCAN_DIR)/list/list.h prelude.$(OBJEXT): $(CCAN_DIR)/str/str.h prelude.$(OBJEXT): $(hdrdir)/ruby.h prelude.$(OBJEXT): $(hdrdir)/ruby/ruby.h +prelude.$(OBJEXT): {$(VPATH)}assert.h prelude.$(OBJEXT): {$(VPATH)}config.h prelude.$(OBJEXT): {$(VPATH)}defines.h prelude.$(OBJEXT): {$(VPATH)}encoding.h @@ -2523,6 +2544,7 @@ proc.$(OBJEXT): $(CCAN_DIR)/list/list.h proc.$(OBJEXT): $(CCAN_DIR)/str/str.h proc.$(OBJEXT): $(hdrdir)/ruby.h proc.$(OBJEXT): $(hdrdir)/ruby/ruby.h +proc.$(OBJEXT): {$(VPATH)}assert.h proc.$(OBJEXT): {$(VPATH)}config.h proc.$(OBJEXT): {$(VPATH)}defines.h proc.$(OBJEXT): {$(VPATH)}encoding.h @@ -2554,6 +2576,7 @@ process.$(OBJEXT): $(CCAN_DIR)/list/list.h process.$(OBJEXT): $(CCAN_DIR)/str/str.h process.$(OBJEXT): $(hdrdir)/ruby.h process.$(OBJEXT): $(hdrdir)/ruby/ruby.h +process.$(OBJEXT): {$(VPATH)}assert.h process.$(OBJEXT): {$(VPATH)}config.h process.$(OBJEXT): {$(VPATH)}defines.h process.$(OBJEXT): {$(VPATH)}dln.h @@ -2615,6 +2638,7 @@ range.$(OBJEXT): {$(VPATH)}st.h range.$(OBJEXT): {$(VPATH)}subst.h rational.$(OBJEXT): $(hdrdir)/ruby.h rational.$(OBJEXT): $(hdrdir)/ruby/ruby.h +rational.$(OBJEXT): {$(VPATH)}assert.h rational.$(OBJEXT): {$(VPATH)}config.h rational.$(OBJEXT): {$(VPATH)}defines.h rational.$(OBJEXT): {$(VPATH)}encoding.h @@ -2733,6 +2757,7 @@ ruby.$(OBJEXT): $(CCAN_DIR)/str/str.h ruby.$(OBJEXT): $(hdrdir)/ruby.h ruby.$(OBJEXT): $(hdrdir)/ruby/ruby.h ruby.$(OBJEXT): $(hdrdir)/ruby/version.h +ruby.$(OBJEXT): {$(VPATH)}assert.h ruby.$(OBJEXT): {$(VPATH)}config.h ruby.$(OBJEXT): {$(VPATH)}debug_counter.h ruby.$(OBJEXT): {$(VPATH)}defines.h @@ -2767,6 +2792,7 @@ safe.$(OBJEXT): $(CCAN_DIR)/list/list.h safe.$(OBJEXT): $(CCAN_DIR)/str/str.h safe.$(OBJEXT): $(hdrdir)/ruby.h safe.$(OBJEXT): $(hdrdir)/ruby/ruby.h +safe.$(OBJEXT): {$(VPATH)}assert.h safe.$(OBJEXT): {$(VPATH)}config.h safe.$(OBJEXT): {$(VPATH)}defines.h safe.$(OBJEXT): {$(VPATH)}encoding.h @@ -2805,6 +2831,7 @@ signal.$(OBJEXT): $(CCAN_DIR)/list/list.h signal.$(OBJEXT): $(CCAN_DIR)/str/str.h signal.$(OBJEXT): $(hdrdir)/ruby.h signal.$(OBJEXT): $(hdrdir)/ruby/ruby.h +signal.$(OBJEXT): {$(VPATH)}assert.h signal.$(OBJEXT): {$(VPATH)}config.h signal.$(OBJEXT): {$(VPATH)}debug_counter.h signal.$(OBJEXT): {$(VPATH)}defines.h @@ -2882,6 +2909,7 @@ strftime.$(OBJEXT): {$(VPATH)}subst.h strftime.$(OBJEXT): {$(VPATH)}timev.h string.$(OBJEXT): $(hdrdir)/ruby.h string.$(OBJEXT): $(hdrdir)/ruby/ruby.h +string.$(OBJEXT): {$(VPATH)}assert.h string.$(OBJEXT): {$(VPATH)}config.h string.$(OBJEXT): {$(VPATH)}crypt.h string.$(OBJEXT): {$(VPATH)}debug_counter.h @@ -2917,6 +2945,7 @@ struct.$(OBJEXT): $(CCAN_DIR)/list/list.h struct.$(OBJEXT): $(CCAN_DIR)/str/str.h struct.$(OBJEXT): $(hdrdir)/ruby.h struct.$(OBJEXT): $(hdrdir)/ruby/ruby.h +struct.$(OBJEXT): {$(VPATH)}assert.h struct.$(OBJEXT): {$(VPATH)}config.h struct.$(OBJEXT): {$(VPATH)}defines.h struct.$(OBJEXT): {$(VPATH)}encoding.h @@ -2942,6 +2971,7 @@ struct.$(OBJEXT): {$(VPATH)}vm_debug.h struct.$(OBJEXT): {$(VPATH)}vm_opts.h symbol.$(OBJEXT): $(hdrdir)/ruby.h symbol.$(OBJEXT): $(hdrdir)/ruby/ruby.h +symbol.$(OBJEXT): {$(VPATH)}assert.h symbol.$(OBJEXT): {$(VPATH)}config.h symbol.$(OBJEXT): {$(VPATH)}defines.h symbol.$(OBJEXT): {$(VPATH)}encoding.h @@ -2969,6 +2999,7 @@ thread.$(OBJEXT): $(CCAN_DIR)/list/list.h thread.$(OBJEXT): $(CCAN_DIR)/str/str.h thread.$(OBJEXT): $(hdrdir)/ruby.h thread.$(OBJEXT): $(hdrdir)/ruby/ruby.h +thread.$(OBJEXT): {$(VPATH)}assert.h thread.$(OBJEXT): {$(VPATH)}config.h thread.$(OBJEXT): {$(VPATH)}debug.h thread.$(OBJEXT): {$(VPATH)}debug_counter.h @@ -3035,6 +3066,7 @@ transcode.$(OBJEXT): {$(VPATH)}transcode.c transcode.$(OBJEXT): {$(VPATH)}transcode_data.h transient_heap.$(OBJEXT): $(hdrdir)/ruby.h transient_heap.$(OBJEXT): $(hdrdir)/ruby/ruby.h +transient_heap.$(OBJEXT): {$(VPATH)}assert.h transient_heap.$(OBJEXT): {$(VPATH)}config.h transient_heap.$(OBJEXT): {$(VPATH)}debug.h transient_heap.$(OBJEXT): {$(VPATH)}debug_counter.h @@ -3072,6 +3104,7 @@ variable.$(OBJEXT): $(CCAN_DIR)/list/list.h variable.$(OBJEXT): $(CCAN_DIR)/str/str.h variable.$(OBJEXT): $(hdrdir)/ruby.h variable.$(OBJEXT): $(hdrdir)/ruby/ruby.h +variable.$(OBJEXT): {$(VPATH)}assert.h variable.$(OBJEXT): {$(VPATH)}config.h variable.$(OBJEXT): {$(VPATH)}constant.h variable.$(OBJEXT): {$(VPATH)}debug_counter.h @@ -3107,6 +3140,7 @@ version.$(OBJEXT): $(hdrdir)/ruby/ruby.h version.$(OBJEXT): $(hdrdir)/ruby/version.h version.$(OBJEXT): $(top_srcdir)/revision.h version.$(OBJEXT): $(top_srcdir)/version.h +version.$(OBJEXT): {$(VPATH)}assert.h version.$(OBJEXT): {$(VPATH)}config.h version.$(OBJEXT): {$(VPATH)}debug_counter.h version.$(OBJEXT): {$(VPATH)}defines.h @@ -3132,6 +3166,7 @@ vm.$(OBJEXT): $(CCAN_DIR)/list/list.h vm.$(OBJEXT): $(CCAN_DIR)/str/str.h vm.$(OBJEXT): $(hdrdir)/ruby.h vm.$(OBJEXT): $(hdrdir)/ruby/ruby.h +vm.$(OBJEXT): {$(VPATH)}assert.h vm.$(OBJEXT): {$(VPATH)}config.h vm.$(OBJEXT): {$(VPATH)}constant.h vm.$(OBJEXT): {$(VPATH)}debug_counter.h @@ -3185,6 +3220,7 @@ vm_backtrace.$(OBJEXT): $(CCAN_DIR)/list/list.h vm_backtrace.$(OBJEXT): $(CCAN_DIR)/str/str.h vm_backtrace.$(OBJEXT): $(hdrdir)/ruby.h vm_backtrace.$(OBJEXT): $(hdrdir)/ruby/ruby.h +vm_backtrace.$(OBJEXT): {$(VPATH)}assert.h vm_backtrace.$(OBJEXT): {$(VPATH)}config.h vm_backtrace.$(OBJEXT): {$(VPATH)}debug.h vm_backtrace.$(OBJEXT): {$(VPATH)}defines.h @@ -3217,6 +3253,7 @@ vm_dump.$(OBJEXT): $(CCAN_DIR)/str/str.h vm_dump.$(OBJEXT): $(hdrdir)/ruby.h vm_dump.$(OBJEXT): $(hdrdir)/ruby/ruby.h vm_dump.$(OBJEXT): {$(VPATH)}addr2line.h +vm_dump.$(OBJEXT): {$(VPATH)}assert.h vm_dump.$(OBJEXT): {$(VPATH)}config.h vm_dump.$(OBJEXT): {$(VPATH)}defines.h vm_dump.$(OBJEXT): {$(VPATH)}encoding.h @@ -3247,6 +3284,7 @@ vm_trace.$(OBJEXT): $(CCAN_DIR)/list/list.h vm_trace.$(OBJEXT): $(CCAN_DIR)/str/str.h vm_trace.$(OBJEXT): $(hdrdir)/ruby.h vm_trace.$(OBJEXT): $(hdrdir)/ruby/ruby.h +vm_trace.$(OBJEXT): {$(VPATH)}assert.h vm_trace.$(OBJEXT): {$(VPATH)}config.h vm_trace.$(OBJEXT): {$(VPATH)}debug.h vm_trace.$(OBJEXT): {$(VPATH)}debug_counter.h diff --git a/ext/coverage/depend b/ext/coverage/depend index 6ae027aec8..ad8c071fbe 100644 --- a/ext/coverage/depend +++ b/ext/coverage/depend @@ -14,6 +14,7 @@ $(OBJS): $(HDRS) $(ruby_headers) \ coverage.o: $(RUBY_EXTCONF_H) coverage.o: $(arch_hdrdir)/ruby/config.h coverage.o: $(hdrdir)/ruby.h +coverage.o: $(hdrdir)/ruby/assert.h coverage.o: $(hdrdir)/ruby/backward.h coverage.o: $(hdrdir)/ruby/defines.h coverage.o: $(hdrdir)/ruby/encoding.h diff --git a/ext/objspace/depend b/ext/objspace/depend index 060b863d04..32157bee2f 100644 --- a/ext/objspace/depend +++ b/ext/objspace/depend @@ -42,6 +42,7 @@ objspace.o: {$(VPATH)}id.h objspace_dump.o: $(RUBY_EXTCONF_H) objspace_dump.o: $(arch_hdrdir)/ruby/config.h objspace_dump.o: $(hdrdir)/ruby.h +objspace_dump.o: $(hdrdir)/ruby/assert.h objspace_dump.o: $(hdrdir)/ruby/backward.h objspace_dump.o: $(hdrdir)/ruby/debug.h objspace_dump.o: $(hdrdir)/ruby/defines.h diff --git a/include/ruby/assert.h b/include/ruby/assert.h new file mode 100644 index 0000000000..5ef866ac9e --- /dev/null +++ b/include/ruby/assert.h @@ -0,0 +1,49 @@ +#ifndef RUBY_ASSERT_H +#define RUBY_ASSERT_H + +#if defined(__cplusplus) +extern "C" { +#if 0 +} /* satisfy cc-mode */ +#endif +#endif + +NORETURN(void rb_assert_failure(const char *, int, const char *, const char *)); +#ifdef RUBY_FUNCTION_NAME_STRING +# define RUBY_ASSERT_FAIL(expr) \ + rb_assert_failure(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, expr) +#else +# define RUBY_ASSERT_FAIL(expr) \ + rb_assert_failure(__FILE__, __LINE__, NULL, expr) +#endif +#define RUBY_ASSERT_MESG(expr, mesg) \ + ((expr) ? (void)0 : RUBY_ASSERT_FAIL(mesg)) +#ifdef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P +# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \ + __builtin_choose_expr( \ + __builtin_constant_p(cond), \ + __builtin_choose_expr(cond, RUBY_ASSERT_MESG(expr, mesg), (void)0), \ + RUBY_ASSERT_MESG(!(cond) || (expr), mesg)) +#else +# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \ + RUBY_ASSERT_MESG(!(cond) || (expr), mesg) +#endif +#define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(!RUBY_NDEBUG+0, expr, #expr) +#define RUBY_ASSERT_WHEN(cond, expr) RUBY_ASSERT_MESG_WHEN(cond, expr, #expr) + +#ifndef RUBY_NDEBUG +# ifdef NDEBUG +# define RUBY_NDEBUG 1 +# else +# define RUBY_NDEBUG 0 +# endif +#endif + +#if defined(__cplusplus) +#if 0 +{ /* satisfy cc-mode */ +#endif +} /* extern "C" { */ +#endif + +#endif diff --git a/ruby_assert.h b/ruby_assert.h index 185d2e5f5f..139256fed8 100644 --- a/ruby_assert.h +++ b/ruby_assert.h @@ -1,37 +1,4 @@ -#ifndef RUBY_ASSERT_H -#define RUBY_ASSERT_H - -#include "ruby/ruby.h" - -#if defined(__cplusplus) -extern "C" { -#if 0 -} /* satisfy cc-mode */ -#endif -#endif - -NORETURN(void rb_assert_failure(const char *, int, const char *, const char *)); -#ifdef RUBY_FUNCTION_NAME_STRING -# define RUBY_ASSERT_FAIL(expr) \ - rb_assert_failure(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, expr) -#else -# define RUBY_ASSERT_FAIL(expr) \ - rb_assert_failure(__FILE__, __LINE__, NULL, expr) -#endif -#define RUBY_ASSERT_MESG(expr, mesg) \ - ((expr) ? (void)0 : RUBY_ASSERT_FAIL(mesg)) -#ifdef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P -# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \ - __builtin_choose_expr( \ - __builtin_constant_p(cond), \ - __builtin_choose_expr(cond, RUBY_ASSERT_MESG(expr, mesg), (void)0), \ - RUBY_ASSERT_MESG(!(cond) || (expr), mesg)) -#else -# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \ - RUBY_ASSERT_MESG(!(cond) || (expr), mesg) -#endif -#define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(!RUBY_NDEBUG+0, expr, #expr) -#define RUBY_ASSERT_WHEN(cond, expr) RUBY_ASSERT_MESG_WHEN(cond, expr, #expr) +#include "ruby/assert.h" #if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) /* C89 compilers are required to support strings of only 509 chars. */ @@ -41,20 +8,3 @@ NORETURN(void rb_assert_failure(const char *, int, const char *, const char *)); #undef assert #define assert RUBY_ASSERT #endif - -#ifndef RUBY_NDEBUG -# ifdef NDEBUG -# define RUBY_NDEBUG 1 -# else -# define RUBY_NDEBUG 0 -# endif -#endif - -#if defined(__cplusplus) -#if 0 -{ /* satisfy cc-mode */ -#endif -} /* extern "C" { */ -#endif - -#endif