chiark / gitweb /
systemd: treat reload failure as failure
[elogind.git] / src / shared / macro.h
index d64e3c3d44bcc14a3dd99fe8daac7f8ddec31c40..54b641be2361593e9d2b57625e5450aea626817f 100644 (file)
@@ -267,7 +267,7 @@ do {                                                                    \
         }                                                               \
 } while(false)
 
- /* Because statfs.t_type can be int on some architecures, we have to cast
+ /* Because statfs.t_type can be int on some architectures, we have to cast
   * the const magic to the type, otherwise the compiler warns about
   * signed/unsigned comparison, because the magic can be 32 bit unsigned.
  */
@@ -277,7 +277,7 @@ do {                                                                    \
  * specified type as a decimal string. Adds in extra space for a
  * negative '-' prefix. */
 #define DECIMAL_STR_MAX(type)                                           \
-        (1+(sizeof(type) <= 1 ? 3 :                                     \
+        (2+(sizeof(type) <= 1 ? 3 :                                     \
             sizeof(type) <= 2 ? 5 :                                     \
             sizeof(type) <= 4 ? 10 :                                    \
             sizeof(type) <= 8 ? 20 : sizeof(int[-2*(sizeof(type) > 8)])))
@@ -285,4 +285,17 @@ do {                                                                    \
 #define SET_FLAG(v, flag, b) \
         (v) = (b) ? ((v) | (flag)) : ((v) & ~(flag))
 
+#define IN_SET(x, ...) ({                                               \
+        typeof(x) _x = (x);                                             \
+        unsigned _i;                                                    \
+        bool _found = false;                                            \
+        for (_i = 0; _i < sizeof((typeof(_x)[]) { __VA_ARGS__ })/sizeof(typeof(_x)); _i++) \
+                if (((typeof(_x)[]) { __VA_ARGS__ })[_i] == _x) {       \
+                        _found = true;                                  \
+                        break;                                          \
+                }                                                       \
+        _found;                                                         \
+        })
+
+
 #include "log.h"