Browse Source

util: introduce CHECK_EQ/CHECK_NE

v0.11.10-release
Fedor Indutny 11 years ago
committed by Timothy J Fontaine
parent
commit
82098bb97b
  1. 8
      src/node_watchdog.cc
  2. 12
      src/util.h

8
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);
}

12
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()

Loading…
Cancel
Save