summaryrefslogtreecommitdiff
path: root/vm_core.h
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-10 23:25:30 (GMT)
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-10 23:25:30 (GMT)
commit85647d9f2b4b2da17827cc1d613f425748a39b3f (patch)
tree5533f43c9957655f62e7be4cc2c5f1bb4c6ed75e /vm_core.h
parent62a81ad98c2421077acd637c11e06022e19a4977 (diff)
* vm_core.h: define VM_ASSERT() for assertion
enabled only when (VM_CHECK_MODE > 0). * vm_insnhelper.c: move definition VM_CHECK_MODE from vm_insnhelper.c to vm_core.h. * vm.c: remove <assert.h> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_core.h')
-rw-r--r--vm_core.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/vm_core.h b/vm_core.h
index c18611e..e1e3fb1 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -12,6 +12,22 @@
#ifndef RUBY_VM_CORE_H
#define RUBY_VM_CORE_H
+/*
+ * Enable check mode.
+ * 1: enable local assertions.
+ */
+#ifndef VM_CHECK_MODE
+#define VM_CHECK_MODE 0
+#endif
+
+#if VM_CHECK_MODE > 0
+#define VM_ASSERT(expr) do { \
+ if(!(expr)) rb_bug("%s:%d assertion violation - %s", __FILE__, __LINE__, #expr); \
+} while (0)
+#else
+#define VM_ASSERT(expr)
+#endif
+
#define RUBY_VM_THREAD_MODEL 2
#include "ruby/ruby.h"