CONST_ISPOWEROF2(_x); \
}))
+/* Returns the largest power of two that divides x (i.e. x's natural alignment in bytes), or 0 if x is 0. */
+#define NATURAL_ALIGNMENT(x) \
+ ({ \
+ const uint64_t _x = (x); \
+ _x == 0 ? UINT64_C(0) : UINT64_C(1) << __builtin_ctzll(_x); \
+ })
+
#define ADD_SAFE(ret, a, b) (!__builtin_add_overflow(a, b, ret))
#define INC_SAFE(a, b) __INC_SAFE(UNIQ, a, b)
#define __INC_SAFE(q, a, b) \
* keep them alive if we succeed, and the rescan will remove them if possible if
* there is an error before writing the partition table.
*/
+ log_debug("Adding partition '%s' (nr=%i, offset=%" PRIu64 " [align=%" PRIu64 "], size=%" PRIu64 " [align=%" PRIu64 "])",
+ part_node, nr,
+ p->offset, NATURAL_ALIGNMENT(p->offset),
+ size, NATURAL_ALIGNMENT(size));
r = block_device_add_partition(whole_fd, part_node, nr, p->offset, size);
if (r < 0)
return log_error_errno(r, "Failed to create new partition '%s': %m", part_node);