Back out Bug 1127201 (part 3) for various problems.
authorAndrew McCreight <amccreight@mozilla.com>
Fri, 06 Feb 2015 15:04:00 -0800
changeset 245431 b84dc805c33275cf51138d194ce8cd9cbb7caff7
parent 245430 2e998e2012dd08c063de13639eb781a554b214f5
child 245432 e46260e7857ad6c690295552864c0c2c24828080
push id7677
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 18:11:24 +0000
treeherdermozilla-aurora@f531d838c055 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1127201
milestone38.0a1
Back out Bug 1127201 (part 3) for various problems.
xpcom/glue/nsDebug.h
--- a/xpcom/glue/nsDebug.h
+++ b/xpcom/glue/nsDebug.h
@@ -45,16 +45,43 @@ inline bool NS_warn_if_impl(bool aCondit
 #define NS_WARN_IF(condition) \
   NS_warn_if_impl(condition, #condition, __FILE__, __LINE__)
 #else
 #define NS_WARN_IF(condition) (bool)(condition)
 #endif
 #endif
 
 /**
+ * Abort the execution of the program if the expression evaluates to
+ * false.
+ *
+ * There is no status value returned from the macro.
+ *
+ * Note that the non-debug version of this macro does <b>not</b>
+ * evaluate the expression argument. Hence side effect statements
+ * as arguments to the macro will yield improper execution in a
+ * non-debug build. For example:
+ *
+ *      NS_ABORT_IF_FALSE(0 == foo++, "yikes foo should be zero");
+ *
+ * Note also that the non-debug version of this macro does <b>not</b>
+ * evaluate the message argument.
+ */
+#ifdef DEBUG
+#define NS_ABORT_IF_FALSE(_expr, _msg)                        \
+  do {                                                        \
+    if (!(_expr)) {                                           \
+      NS_DebugBreak(NS_DEBUG_ABORT, _msg, #_expr, __FILE__, __LINE__); \
+    }                                                         \
+  } while(0)
+#else
+#define NS_ABORT_IF_FALSE(_expr, _msg) do { /* nothing */ } while(0)
+#endif
+
+/**
  * Warn if a given condition is false.
  *
  * Program execution continues past the usage of this macro.
  *
  * Note also that the non-debug version of this macro does <b>not</b>
  * evaluate the message argument.
  */
 #ifdef DEBUG