1
0

101-add-musl-workaround-to-the-libc-compat.h-copy.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. --- a/include/linux-private/linux/if_ether.h
  2. +++ b/include/linux-private/linux/if_ether.h
  3. @@ -22,6 +22,7 @@
  4. #define _LINUX_IF_ETHER_H
  5. #include <linux/types.h>
  6. +#include <linux/libc-compat.h>
  7. /*
  8. * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
  9. @@ -117,10 +118,12 @@
  10. * This is an Ethernet frame header.
  11. */
  12. +#if __UAPI_DEF_ETHHDR
  13. struct ethhdr {
  14. unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
  15. unsigned char h_source[ETH_ALEN]; /* source ether addr */
  16. __be16 h_proto; /* packet type ID field */
  17. } __attribute__((packed));
  18. +#endif
  19. #endif /* _LINUX_IF_ETHER_H */
  20. --- a/include/linux-private/linux/libc-compat.h
  21. +++ b/include/linux-private/linux/libc-compat.h
  22. @@ -48,10 +48,18 @@
  23. #ifndef _LIBC_COMPAT_H
  24. #define _LIBC_COMPAT_H
  25. -/* We have included glibc headers... */
  26. -#if defined(__GLIBC__)
  27. +/* We're used from userspace... */
  28. +#if !defined(__KERNEL__)
  29. -/* Coordinate with glibc netinet/in.h header. */
  30. +/* Coordinate with libc netinet/if_ether.h */
  31. +#ifdef _NETINET_IF_ETHER_H /* musl */
  32. +#define __UAPI_DEF_ETHHDR 0
  33. +#else
  34. +/* glibc uses __NETINET_IF_ETHER_H, and uses the uapi header. */
  35. +#define __UAPI_DEF_ETHHDR 1
  36. +#endif
  37. +
  38. +/* Coordinate with libc netinet/in.h header. */
  39. #if defined(_NETINET_IN_H)
  40. /* GLIBC headers included first so don't define anything
  41. @@ -64,15 +72,7 @@
  42. #define __UAPI_DEF_IN_CLASS 0
  43. #define __UAPI_DEF_IN6_ADDR 0
  44. -/* The exception is the in6_addr macros which must be defined
  45. - * if the glibc code didn't define them. This guard matches
  46. - * the guard in glibc/inet/netinet/in.h which defines the
  47. - * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
  48. -#if defined(__USE_MISC) || defined (__USE_GNU)
  49. #define __UAPI_DEF_IN6_ADDR_ALT 0
  50. -#else
  51. -#define __UAPI_DEF_IN6_ADDR_ALT 1
  52. -#endif
  53. #define __UAPI_DEF_SOCKADDR_IN6 0
  54. #define __UAPI_DEF_IPV6_MREQ 0
  55. #define __UAPI_DEF_IPPROTO_V6 0
  56. @@ -83,7 +83,7 @@
  57. #else
  58. /* Linux headers included first, and we must define everything
  59. - * we need. The expectation is that glibc will check the
  60. + * we need. The expectation is that libc will check the
  61. * __UAPI_DEF_* defines and adjust appropriately. */
  62. #define __UAPI_DEF_IN_ADDR 1
  63. #define __UAPI_DEF_IN_IPPROTO 1
  64. @@ -93,7 +93,7 @@
  65. #define __UAPI_DEF_IN_CLASS 1
  66. #define __UAPI_DEF_IN6_ADDR 1
  67. -/* We unconditionally define the in6_addr macros and glibc must
  68. +/* We unconditionally define the in6_addr macros and libc must
  69. * coordinate. */
  70. #define __UAPI_DEF_IN6_ADDR_ALT 1
  71. #define __UAPI_DEF_SOCKADDR_IN6 1
  72. @@ -115,7 +115,10 @@
  73. /* If we did not see any headers from any supported C libraries,
  74. * or we are being included in the kernel, then define everything
  75. * that we need. */
  76. -#else /* !defined(__GLIBC__) */
  77. +#else /* defined(__KERNEL__) */
  78. +
  79. +/* Definitions for if/ether.h */
  80. +#define __UAPI_DEF_ETHHDR 1
  81. /* Definitions for in.h */
  82. #define __UAPI_DEF_IN_ADDR 1
  83. @@ -138,6 +141,6 @@
  84. /* Definitions for xattr.h */
  85. #define __UAPI_DEF_XATTR 1
  86. -#endif /* __GLIBC__ */
  87. +#endif /* defined(__KERNEL__) */
  88. #endif /* _LIBC_COMPAT_H */