ncsid: Import from gBMC

This is the initial code drop from gBMC.

Google-Bug-Id: 179618516
Upstream: 1e71af914bc8c54d8b91d0a1cf377e2696713c2f
Change-Id: Ic653e8271dacd205e04f2bc713071ef2ec5936a4
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/ncsid/src/common_defs.h b/ncsid/src/common_defs.h
new file mode 100644
index 0000000..70f51b8
--- /dev/null
+++ b/ncsid/src/common_defs.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#define RETURN_IF_ERROR(expr, msg)                                             \
+    do                                                                         \
+    {                                                                          \
+        int _ret = (expr);                                                     \
+        if (_ret < 0)                                                          \
+        {                                                                      \
+            std::perror(msg);                                                  \
+            return _ret;                                                       \
+        }                                                                      \
+    } while (0)