X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fmacro.h;h=0874102ece6afa10cdebd0031120532a3828b5c8;hb=2f79c10e9aef916efbcf29315eea8c25d0a50ac4;hp=cca41a3f6ad7311877211d788a6d0d076285c909;hpb=dfb33a9737e62ab872d3937b7690b252d2892fe8;p=elogind.git diff --git a/src/shared/macro.h b/src/shared/macro.h index cca41a3f6..0874102ec 100644 --- a/src/shared/macro.h +++ b/src/shared/macro.h @@ -28,6 +28,7 @@ #include #define _printf_attr_(a,b) __attribute__ ((format (printf, a, b))) +#define _alloc_(...) __attribute__ ((alloc_size(__VA_ARGS__))) #define _sentinel_ __attribute__ ((sentinel)) #define _noreturn_ __attribute__((noreturn)) #define _unused_ __attribute__ ((unused)) @@ -66,12 +67,16 @@ #error "Wut? Pointers are neither 4 nor 8 bytes long?" #endif +#define ALIGN_PTR(p) ((void*) ALIGN((unsigned long) p)) +#define ALIGN4_PTR(p) ((void*) ALIGN4((unsigned long) p)) #define ALIGN8_PTR(p) ((void*) ALIGN8((unsigned long) p)) static inline size_t ALIGN_TO(size_t l, size_t ali) { return ((l + ali - 1) & ~(ali - 1)); } +#define ALIGN_TO_PTR(p, ali) ((void*) ALIGN_TO((unsigned long) p)) + #define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0])) /* @@ -260,6 +265,13 @@ do { \ } \ } while(false) + /* Because statfs.t_type can be int on some architecures, 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. + */ +#define F_TYPE_CMP(a, b) (a == (typeof(a)) b) + + /* Returns the number of chars needed to format variables of the * specified type as a decimal string. Adds in extra space for a * negative '-' prefix. */