chiark / gitweb /
po: run make update-po
[elogind.git] / src / shared / macro.h
index 7f89951d62e00ee5f68809e017c2572f1e174770..5fa17ed2085cdc2fe3a7b992468f5917d6cd96b0 100644 (file)
@@ -248,10 +248,20 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
         REENABLE_WARNING
 #endif
 
+#define assert_log(expr) ((_likely_(expr))      \
+        ? (true)                                \
+        : (log_assert_failed_return(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__), false))
+
 #define assert_return(expr, r)                                          \
         do {                                                            \
-                if (_unlikely_(!(expr))) {                              \
-                        log_assert_failed_return(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
+                if (!assert_log(expr))                                  \
+                        return (r);                                     \
+        } while (false)
+
+#define assert_return_errno(expr, r, err)                               \
+        do {                                                            \
+                if (!assert_log(expr)) {                                \
+                        errno = err;                                    \
                         return (r);                                     \
                 }                                                       \
         } while (false)
@@ -458,4 +468,7 @@ do {                                                                    \
         }                                                       \
         struct __useless_struct_to_allow_trailing_semicolon__
 
+#define CMSG_FOREACH(cmsg, mh)                                          \
+        for ((cmsg) = CMSG_FIRSTHDR(mh); (cmsg); (cmsg) = CMSG_NXTHDR((mh), (cmsg)))
+
 #include "log.h"