add PRCHECK and PRDie

Change-Id: I1b1e8f54d24d0ba956f0884c3fcf6db367bf137f
diff --git a/aos/common/logging/logging.h b/aos/common/logging/logging.h
index a149d39..66b88c7 100644
--- a/aos/common/logging/logging.h
+++ b/aos/common/logging/logging.h
@@ -233,11 +233,27 @@
   return value;
 }
 
+inline void CheckSyscallReturn(const char *syscall_string, int value) {
+  if (__builtin_expect(value != 0, false)) {
+    PELOG(FATAL, value, "%s failed", syscall_string);
+  }
+}
+
 // Check that syscall does not return -1. If it does, PLOG(FATAL)s. This is
 // useful for quickly checking syscalls where it's not very useful to print out
-// the values of any of the arguments.
+// the values of any of the arguments. Returns the result otherwise.
+//
+// Example: const int fd = PCHECK(open("/tmp/whatever", O_WRONLY))
 #define PCHECK(syscall) ::aos::CheckSyscall(STRINGIFY(syscall), syscall)
 
+// PELOG(FATAL)s with the result of syscall if it returns anything other than 0.
+// This is useful for quickly checking things like many of the pthreads
+// functions where it's not very useful to print out the values of any of the
+// arguments.
+//
+// Example: PRCHECK(munmap(address, length))
+#define PRCHECK(syscall) ::aos::CheckSyscallReturn(STRINGIFY(syscall), syscall)
+
 }  // namespace aos
 
 #endif  // __cplusplus