add PRCHECK and PRDie
Change-Id: I1b1e8f54d24d0ba956f0884c3fcf6db367bf137f
diff --git a/aos/common/die.h b/aos/common/die.h
index 80e8450..f9ff457 100644
--- a/aos/common/die.h
+++ b/aos/common/die.h
@@ -26,7 +26,20 @@
const int error = errno; \
::aos::Die(format " because of %d (%s)", ##args, error, \
aos_strerror(error)); \
- } while (false);
+ } while (false)
+
+// The same as Die except appends " because of %d (%s)" (formatted with error
+// and aos_strerror(error)) to the message.
+// PCHECK is to PDie as PRCHECK is to PRDie
+//
+// Example:
+// const int ret = pthread_mutex_lock(whatever);
+// if (ret != 0) PRDie(ret, "pthread_mutex_lock(%p) failed", whatever);
+#define PRDie(error, format, args...) \
+ do { \
+ ::aos::Die(format " because of %d (%s)", ##args, error, \
+ aos_strerror(error)); \
+ } while (false)
// Turns on (or off) "test mode", where (V)Die doesn't write out files and
// doesn't print to stdout.