2
1

0003-btrfs-progs-kerncompat-add-local-definition-for-alignment-macros.patch 1.7 KB

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