chiark / gitweb /
smack: minimize ifdef use, and move all labeling to smack-util.c
[elogind.git] / src / shared / macro.h
index 969329d152368127cd38e133dc4db6b50ae4334d..06e16cd4536de2dbc37f940253ad46616acfbd1d 100644 (file)
@@ -159,6 +159,12 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
         } while (false)
 #endif
 
+#define assert_return(expr, r)                    \
+        do {                                      \
+                if (!(expr))                      \
+                        return (r);               \
+        } while (false)
+
 #define PTR_TO_INT(p) ((int) ((intptr_t) (p)))
 #define INT_TO_PTR(u) ((void *) ((intptr_t) (u)))
 #define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
@@ -186,8 +192,6 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
 
 #define char_array_0(x) x[sizeof(x)-1] = 0;
 
-#define hasprefix(s, prefix) (memcmp(s, prefix, strlen(prefix)) == 0)
-
 #define IOVEC_SET_STRING(i, s)                  \
         do {                                    \
                 struct iovec *_i = &(i);        \
@@ -273,7 +277,7 @@ do {                                                                    \
   * the const magic to the type, otherwise the compiler warns about
   * signed/unsigned comparison, because the magic can be 32 bit unsigned.
  */
-#define F_TYPE_CMP(a, b) (a == (typeof(a)) b)
+#define F_TYPE_EQUAL(a, b) (a == (typeof(a)) b)
 
 
 /* Returns the number of chars needed to format variables of the