summaryrefslogtreecommitdiffstats
path: root/src/fundamental/macro-fundamental.h
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-05-27 03:51:47 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-05-31 20:40:20 +0200
commit4c8d7caf1a6fbc9abac627ddf974ed219258f9a8 (patch)
tree397dbb52cb9a6a068379a81531022721eda35853 /src/fundamental/macro-fundamental.h
parenttree-wide: use ALIGN_PTR() (diff)
downloadsystemd-4c8d7caf1a6fbc9abac627ddf974ed219258f9a8.tar.xz
systemd-4c8d7caf1a6fbc9abac627ddf974ed219258f9a8.zip
macro: make ALIGN4() and ALIGN8() also return SIZE_MAX on overflow
This also drops unused ALIGN4_PTR(), ALIGN8_PTR(), and ALIGN_TO_PTR().
Diffstat (limited to '')
-rw-r--r--src/fundamental/macro-fundamental.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h
index 59d63e8e5d..3e4d4f0111 100644
--- a/src/fundamental/macro-fundamental.h
+++ b/src/fundamental/macro-fundamental.h
@@ -321,6 +321,14 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
return ((l + ali - 1) & ~(ali - 1));
}
+#define ALIGN4(l) ALIGN_TO(l, 4)
+#define ALIGN8(l) ALIGN_TO(l, 8)
+#ifndef SD_BOOT
+/* libefi also provides ALIGN, and we do not use them in sd-boot explicitly. */
+#define ALIGN(l) ALIGN_TO(l, sizeof(void*))
+#define ALIGN_PTR(p) ((void*) ALIGN((uintptr_t) (p)))
+#endif
+
/* Same as ALIGN_TO but callable in constant contexts. */
#define CONST_ALIGN_TO(l, ali) \
__builtin_choose_expr( \