X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fmacro.h;h=6caecab29538c3983e655b4f806efc6a88bbd466;hb=df41aaf9a2b195c9a8bb6fca6672cbf25bc147fb;hp=c22de91705fb51b26a74b3075f04d9710969bf75;hpb=d3cfcae9db39b0cd01bd8c3db1dc57d6a04554a4;p=elogind.git diff --git a/src/shared/macro.h b/src/shared/macro.h index c22de9170..6caecab29 100644 --- a/src/shared/macro.h +++ b/src/shared/macro.h @@ -53,6 +53,11 @@ #define XSTRINGIFY(x) #x #define STRINGIFY(x) XSTRINGIFY(x) +#define XCONCATENATE(x, y) x ## y +#define CONCATENATE(x, y) XCONCATENATE(x, y) + +#define UNIQUE(prefix) CONCATENATE(prefix, __LINE__) + /* Rounds up */ #define ALIGN4(l) (((l) + 3) & ~3) @@ -145,7 +150,7 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { #if defined(static_assert) #define assert_cc(expr) static_assert(expr, #expr) #else -#define assert_cc(expr) struct _assert_struct_ ## __LINE__ { char x[(expr) ? 0 : -1]; } +#define assert_cc(expr) struct UNIQUE(_assert_struct_) { char x[(expr) ? 0 : -1]; }; #endif #define assert_return(expr, r) \ @@ -272,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)])))