0001-remove-wordsize-h-inclusion-for-musl-compatibility.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From 0592f8f829c843ff5cb2d108c309e32f4f6f5379 Mon Sep 17 00:00:00 2001
  2. From: Andre Przywara <andre.przywara@arm.com>
  3. Date: Thu, 1 Aug 2024 12:10:54 +0100
  4. Subject: remove wordsize.h inclusion (for musl compatibility)
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. The wordsize.h header file and the __WORDSIZE definition do not seem
  9. to be universal, the musl libc for instance has the definition in a
  10. different header file. This breaks compilation of kvmtool against musl.
  11. The two leading underscores suggest a compiler-internal symbol anyway, so
  12. let's just remove that particular macro usage entirely, and replace it
  13. with the number we really want: the size of a "long" type.
  14. Reported-by: J. Neuschäfer <j.neuschaefer@gmx.net>
  15. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
  16. Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
  17. Link: https://lore.kernel.org/r/20240801111054.818765-1-andre.przywara@arm.com
  18. Signed-off-by: Will Deacon <will@kernel.org>
  19. Upstream: https://git.kernel.org/pub/scm/linux/kernel/git/will/kvmtool.git/commit/?id=0592f8f829c843ff5cb2d108c309e32f4f6f5379
  20. Signed-off-by: Thomas Perale <thomas.perale@mind.be>
  21. ---
  22. include/linux/bitops.h | 6 ++----
  23. 1 file changed, 2 insertions(+), 4 deletions(-)
  24. diff --git a/include/linux/bitops.h b/include/linux/bitops.h
  25. index ae33922f..ee8fd560 100644
  26. --- a/include/linux/bitops.h
  27. +++ b/include/linux/bitops.h
  28. @@ -1,15 +1,13 @@
  29. #ifndef _KVM_LINUX_BITOPS_H_
  30. #define _KVM_LINUX_BITOPS_H_
  31. -#include <bits/wordsize.h>
  32. -
  33. #include <linux/kernel.h>
  34. #include <linux/compiler.h>
  35. #include <asm/hweight.h>
  36. -#define BITS_PER_LONG __WORDSIZE
  37. #define BITS_PER_BYTE 8
  38. -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
  39. +#define BITS_PER_LONG (BITS_PER_BYTE * sizeof(long))
  40. +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG)
  41. #define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
  42. --
  43. cgit 1.2.3-korg