X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fmacro.h;h=055919048c90d8c203baf1ae1d8913d2c002714a;hb=961e4526925b7b1e1d3582f2fc9fb38035e2b5fb;hp=dbdf5b3fb00f2d83362ab9bd5f97f9cc699b64b4;hpb=cecd32f648cdf315ee19c0cf7c8c7cb9fb5d6ee6;p=elogind.git diff --git a/src/shared/macro.h b/src/shared/macro.h index dbdf5b3fb..055919048 100644 --- a/src/shared/macro.h +++ b/src/shared/macro.h @@ -119,14 +119,21 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { log_assert_failed_unreachable(t, __FILE__, __LINE__, __PRETTY_FUNCTION__); \ } while (false) -#define assert_cc(expr) \ - do { \ - switch (0) { \ - case 0: \ - case !!(expr): \ - ; \ - } \ +#if defined(static_assert) +#define assert_cc(expr) \ + do { \ + static_assert(expr, #expr); \ } while (false) +#else +#define assert_cc(expr) \ + do { \ + switch (0) { \ + case 0: \ + case !!(expr): \ + ; \ + } \ + } while (false) +#endif #define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p))) #define UINT_TO_PTR(u) ((void*) ((uintptr_t) (u))) @@ -189,9 +196,13 @@ static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) { #define _cleanup_free_ __attribute__((cleanup(freep))) #define _cleanup_fclose_ __attribute__((cleanup(fclosep))) +#define _cleanup_pclose_ __attribute__((cleanup(pclosep))) #define _cleanup_close_ __attribute__((cleanup(closep))) #define _cleanup_closedir_ __attribute__((cleanup(closedirp))) #define _cleanup_umask_ __attribute__((cleanup(umaskp))) +#define _cleanup_set_free_ __attribute__((cleanup(set_freep))) +#define _cleanup_set_free_free_ __attribute__((cleanup(set_free_freep))) +#define _cleanup_strv_free_ __attribute__((cleanup(strv_freep))) #define VA_FORMAT_ADVANCE(format, ap) \ do { \