Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
util: introduce CHECK_EQ/CHECK_NE
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny authored and tjfontaine committed Dec 21, 2013
1 parent 87cde44 commit 82098bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/node_watchdog.cc
Expand Up @@ -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);
}


Expand Down
12 changes: 8 additions & 4 deletions src/util.h
Expand Up @@ -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()
Expand Down

0 comments on commit 82098bb

Please sign in to comment.