diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-08-05 13:19:23 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-08-05 13:37:29 +0200 |
commit | 983ce0b5173951ad947e8ea089df2e277a45f863 (patch) | |
tree | d5fe17e6cc98c3e4b782649c30898db491b1cda2 /src/fundamental | |
parent | c51e4c796d53f370750b27768fc979f6aa0cb263 (diff) | |
download | systemd-983ce0b5173951ad947e8ea089df2e277a45f863.tar.gz |
macro: use ISPOWEROF2() at various places
Diffstat (limited to 'src/fundamental')
-rw-r--r-- | src/fundamental/macro-fundamental.h | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index 5c67d3e2f7..8b483f0b50 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -327,16 +327,7 @@ }) static inline size_t ALIGN_TO(size_t l, size_t ali) { - /* Check that alignment is exponent of 2 */ -#if SIZE_MAX == UINT_MAX - assert(__builtin_popcount(ali) == 1); -#elif SIZE_MAX == ULONG_MAX - assert(__builtin_popcountl(ali) == 1); -#elif SIZE_MAX == ULLONG_MAX - assert(__builtin_popcountll(ali) == 1); -#else - #error "Unexpected size_t" -#endif + assert(ISPOWEROF2(ali)); if (l > SIZE_MAX - (ali - 1)) return SIZE_MAX; /* indicate overflow */ @@ -357,7 +348,7 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { __builtin_choose_expr( \ __builtin_constant_p(l) && \ __builtin_constant_p(ali) && \ - __builtin_popcountll(ali) == 1 && /* is power of 2? */ \ + CONST_ISPOWEROF2(ali) && \ (l <= SIZE_MAX - (ali - 1)), /* overflow? */ \ ((l) + (ali) - 1) & ~((ali) - 1), \ VOID_0) |