X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fmacro.h;h=0d3ff1cda578808ec2cb225ee4d97ce5ba213099;hb=c51cf05646a11c65daf65c1123c77efb068f4f7b;hp=2f151bcc8cb143f5c80d7d33c7de81a2d4c3236f;hpb=a3dc35472f3a48ea8445ad7a943e2ff253170417;p=elogind.git diff --git a/src/shared/macro.h b/src/shared/macro.h index 2f151bcc8..0d3ff1cda 100644 --- a/src/shared/macro.h +++ b/src/shared/macro.h @@ -186,6 +186,8 @@ 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); \ @@ -271,7 +273,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 @@ -284,4 +286,7 @@ do { \ sizeof(type) <= 4 ? 10 : \ sizeof(type) <= 8 ? 20 : sizeof(int[-2*(sizeof(type) > 8)]))) +#define SET_FLAG(v, flag, b) \ + (v) = (b) ? ((v) | (flag)) : ((v) & ~(flag)) + #include "log.h"