X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fmacro.h;h=5619c32e457ba792172fa29badabeb50dbda6f8c;hb=58d617429dcfb6fb1ea0f7b6cbce82266ccbb1aa;hp=53bd578d7e03d49ebae396b183fdf10140b3434d;hpb=625e870b4fb7ff4caf4d8a4614e9bda7c174b291;p=elogind.git diff --git a/src/shared/macro.h b/src/shared/macro.h index 53bd578d7..5619c32e4 100644 --- a/src/shared/macro.h +++ b/src/shared/macro.h @@ -63,6 +63,10 @@ _Pragma("GCC diagnostic push"); \ _Pragma("GCC diagnostic ignored \"-Wnonnull\"") +#define DISABLE_WARNING_SHADOW \ + _Pragma("GCC diagnostic push"); \ + _Pragma("GCC diagnostic ignored \"-Wshadow\"") + #define REENABLE_WARNING \ _Pragma("GCC diagnostic pop") @@ -150,6 +154,12 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) { _a < _b ? _a : _b; \ }) +#define MIN3(x,y,z) \ + __extension__ ({ \ + typeof(x) _c = MIN(x,y); \ + MIN(_c, z); \ + }) + #define LESS_BY(A,B) \ __extension__ ({ \ typeof(A) _A = (A); \ @@ -231,6 +241,9 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) { #define PTR_TO_UINT64(p) ((uint64_t) ((uintptr_t) (p))) #define UINT64_TO_PTR(u) ((void *) ((uintptr_t) (u))) +#define PTR_TO_SIZE(p) ((size_t) ((uintptr_t) (p))) +#define SIZE_TO_PTR(u) ((void *) ((uintptr_t) (u))) + #define memzero(x,l) (memset((x), 0, (l))) #define zero(x) (memzero(&(x), sizeof(x)))