summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFedor Indutny <fedor.indutny@gmail.com>2013-12-19 10:02:19 +0400
committerTimothy J Fontaine <tjfontaine@gmail.com>2013-12-20 18:57:46 -0800
commit82098bb97bbed9404da1f6386490837a05318d5e (patch)
tree2c9b1768777eb7a36ee0f7b4713ed349abb1004d /src
parent87cde4428036b7ddd1c51f2c00414c02bb46b8ee (diff)
downloadnodejs-82098bb97bbed9404da1f6386490837a05318d5e.tar.gz
nodejs-82098bb97bbed9404da1f6386490837a05318d5e.tar.bz2
nodejs-82098bb97bbed9404da1f6386490837a05318d5e.zip
util: introduce CHECK_EQ/CHECK_NE
Diffstat (limited to 'src')
-rw-r--r--src/node_watchdog.cc8
-rw-r--r--src/util.h12
2 files changed, 12 insertions, 8 deletions
diff --git a/src/node_watchdog.cc b/src/node_watchdog.cc
index d5ad88f63..cec9aa52c 100644
--- a/src/node_watchdog.cc
+++ b/src/node_watchdog.cc
@@ -33,16 +33,16 @@ Watchdog::Watchdog(uint64_t ms) : destroyed_(false) {
CHECK(loop_);
int rc = uv_async_init(loop_, &async_, &Watchdog::Async);
- CHECK(0 == rc); // NOLINT(readability/check)
+ CHECK_EQ(0, rc);
rc = uv_timer_init(loop_, &timer_);
- CHECK(0 == rc); // NOLINT(readability/check)
+ CHECK_EQ(0, rc);
rc = uv_timer_start(&timer_, &Watchdog::Timer, ms, 0);
- CHECK(0 == rc); // NOLINT(readability/check)
+ CHECK_EQ(0, rc);
rc = uv_thread_create(&thread_, &Watchdog::Run, this);
- CHECK(0 == rc); // NOLINT(readability/check)
+ CHECK_EQ(0, rc);
}
diff --git a/src/util.h b/src/util.h
index 84ca8b876..9545475cc 100644
--- a/src/util.h
+++ b/src/util.h
@@ -44,14 +44,18 @@ namespace node {
TypeName(const TypeName&)
#if defined(NDEBUG)
-#define ASSERT(expression)
-#define CHECK(expression) \
+# define ASSERT(expression)
+# define CHECK(expression) \
do { \
if (!(expression)) abort(); \
} while (0)
+# define CHECK_EQ(a, b) CHECK((a) == (b))
+# define CHECK_NE(a, b) CHECK((a) != (b))
#else
-#define ASSERT(expression) assert(expression)
-#define CHECK(expression) assert(expression)
+# define ASSERT(expression) assert(expression)
+# define CHECK(expression) assert(expression)
+# define CHECK_EQ(a, b) assert((a) == (b))
+# define CHECK_NE(a, b) assert((a) != (b))
#endif
#define UNREACHABLE() abort()