Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-11-14 04:48:19 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2013-11-20 03:26:30 +0400
commit3ac69469991eab4a4176f3cd851f351119c7efcd (patch)
tree0ed018d86253a957baa19da88b146ce1a05afc67 /src/util.h
parentd29fe0f2c667085ec403c4856efca8686c52ceef (diff)
src: add ASSERT/CHECK/UNREACHABLE macros
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
index 63962a62598..84ca8b876e8 100644
--- a/src/util.h
+++ b/src/util.h
@@ -23,7 +23,9 @@
#define SRC_UTIL_H_
#include "v8.h"
+#include <assert.h>
#include <stddef.h>
+#include <stdlib.h>
namespace node {
@@ -41,6 +43,19 @@ namespace node {
void operator=(const TypeName&); \
TypeName(const TypeName&)
+#if defined(NDEBUG)
+#define ASSERT(expression)
+#define CHECK(expression) \
+ do { \
+ if (!(expression)) abort(); \
+ } while (0)
+#else
+#define ASSERT(expression) assert(expression)
+#define CHECK(expression) assert(expression)
+#endif
+
+#define UNREACHABLE() abort()
+
// If persistent.IsWeak() == false, then do not call persistent.Dispose()
// while the returned Local<T> is still in scope, it will destroy the
// reference to the object.