blob: b0fe67922da3aa126ecd188ed39cd9894b73e105 [file] [log] [blame]
Andrew Geissler595f6302022-01-24 19:11:47 +00001From b0cfe12c4d4b8b4ef335cdf4ddefcbdcd1b70d58 Mon Sep 17 00:00:00 2001
2From: David Sterba <dsterba@suse.com>
3Date: Thu, 13 Jan 2022 14:47:08 +0100
4Subject: [PATCH] btrfs-progs: kerncompat: add local definition for alignment
5 macros
6
7There's still problem left with compilation on musl and kernel < 5.11,
8because __ALIGN_KERNEL is not defined anymore:
9
10../bin/ld: kernel-shared/volumes.o: in function `create_chunk':
11volumes.c:(.text+0x17f8): undefined reference to `__ALIGN_KERNEL'
12
13Due to the entangled includes and unconditional definition of
14__ALIGN_KERNEL, we can't use #ifdef in kerncompat.h to define it
15eventually (as kerncompat.h is the first include). Instead add local
16definitions of the macros and rename them to avoid name clashes.
17
18Pull-request: #433
19
20Upstream-Status: Backport [https://github.com/kdave/btrfs-progs/commit/b0cfe12c4d4b8b4ef335cdf4ddefcbdcd1b70d58]
21
22Signed-off-by: Wang Mingyu <wangmy@fujitsu.com>
23---
24 kerncompat.h | 9 ++++++++-
25 1 file changed, 8 insertions(+), 1 deletion(-)
26
27diff --git a/kerncompat.h b/kerncompat.h
28index 6ca1526e2..f0a6e196e 100644
29--- a/kerncompat.h
30+++ b/kerncompat.h
31@@ -359,7 +359,14 @@ do { \
32
33 /* Alignment check */
34 #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
35-#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
36+
37+/*
38+ * Alignment, copied and renamed from /usr/include/linux/const.h to work around
39+ * issues caused by moving the definition in 5.12
40+ */
41+#define __ALIGN_KERNEL__(x, a) __ALIGN_KERNEL_MASK__(x, (typeof(x))(a) - 1)
42+#define __ALIGN_KERNEL_MASK__(x, mask) (((x) + (mask)) & ~(mask))
43+#define ALIGN(x, a) __ALIGN_KERNEL__((x), (a))
44
45 static inline int is_power_of_2(unsigned long n)
46 {