271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. From f972afc2509eebcb00d370256c55b112a3b5ffca Mon Sep 17 00:00:00 2001
  2. From: David Heidelberger <[email protected]>
  3. Date: Mon, 29 Jun 2015 16:50:40 +0200
  4. Subject: [PATCH 2/3] uapi/libc-compat.h: do not rely on __GLIBC__
  5. Musl provides the same structs as glibc, but does not provide a define to
  6. allow its detection. Since the absence of __GLIBC__ also can mean that it
  7. is included from the kernel, change the __GLIBC__ detection to
  8. !__KERNEL__, which should always be true when included from userspace.
  9. Signed-off-by: John Spencer <[email protected]>
  10. Tested-by: David Heidelberger <[email protected]>
  11. Signed-off-by: Jonas Gorski <[email protected]>
  12. ---
  13. include/uapi/linux/libc-compat.h | 18 +++++++++---------
  14. 1 file changed, 9 insertions(+), 9 deletions(-)
  15. --- a/include/uapi/linux/libc-compat.h
  16. +++ b/include/uapi/linux/libc-compat.h
  17. @@ -48,13 +48,13 @@
  18. #ifndef _UAPI_LIBC_COMPAT_H
  19. #define _UAPI_LIBC_COMPAT_H
  20. -/* We have included glibc headers... */
  21. -#if defined(__GLIBC__)
  22. +/* We have included libc headers... */
  23. +#if !defined(__KERNEL__)
  24. -/* Coordinate with glibc net/if.h header. */
  25. -#if defined(_NET_IF_H) && defined(__USE_MISC)
  26. +/* Coordinate with libc net/if.h header. */
  27. +#if defined(_NET_IF_H) && (!defined(__GLIBC__) || defined(__USE_MISC))
  28. -/* GLIBC headers included first so don't define anything
  29. +/* LIBC headers included first so don't define anything
  30. * that would already be defined. */
  31. #define __UAPI_DEF_IF_IFCONF 0
  32. @@ -65,7 +65,11 @@
  33. #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0
  34. /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
  35. #ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
  36. +#ifdef __GLIBC__
  37. #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
  38. +#else
  39. +#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 0
  40. +#endif
  41. #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
  42. #else /* _NET_IF_H */
  43. @@ -85,10 +89,10 @@
  44. #endif /* _NET_IF_H */
  45. -/* Coordinate with glibc netinet/in.h header. */
  46. +/* Coordinate with libc netinet/in.h header. */
  47. #if defined(_NETINET_IN_H)
  48. -/* GLIBC headers included first so don't define anything
  49. +/* LIBC headers included first so don't define anything
  50. * that would already be defined. */
  51. #define __UAPI_DEF_IN_ADDR 0
  52. #define __UAPI_DEF_IN_IPPROTO 0
  53. @@ -102,7 +106,7 @@
  54. * if the glibc code didn't define them. This guard matches
  55. * the guard in glibc/inet/netinet/in.h which defines the
  56. * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
  57. -#if defined(__USE_MISC) || defined (__USE_GNU)
  58. +#if !defined(__GLIBC__) || defined(__USE_MISC) || defined (__USE_GNU)
  59. #define __UAPI_DEF_IN6_ADDR_ALT 0
  60. #else
  61. #define __UAPI_DEF_IN6_ADDR_ALT 1
  62. @@ -117,7 +121,7 @@
  63. #else
  64. /* Linux headers included first, and we must define everything
  65. - * we need. The expectation is that glibc will check the
  66. + * we need. The expectation is that the libc will check the
  67. * __UAPI_DEF_* defines and adjust appropriately. */
  68. #define __UAPI_DEF_IN_ADDR 1
  69. #define __UAPI_DEF_IN_IPPROTO 1
  70. @@ -127,7 +131,7 @@
  71. #define __UAPI_DEF_IN_CLASS 1
  72. #define __UAPI_DEF_IN6_ADDR 1
  73. -/* We unconditionally define the in6_addr macros and glibc must
  74. +/* We unconditionally define the in6_addr macros and the libc must
  75. * coordinate. */
  76. #define __UAPI_DEF_IN6_ADDR_ALT 1
  77. #define __UAPI_DEF_SOCKADDR_IN6 1
  78. @@ -168,7 +172,7 @@
  79. /* If we did not see any headers from any supported C libraries,
  80. * or we are being included in the kernel, then define everything
  81. * that we need. */
  82. -#else /* !defined(__GLIBC__) */
  83. +#else /* defined(__KERNEL__) */
  84. /* Definitions for if.h */
  85. #define __UAPI_DEF_IF_IFCONF 1
  86. @@ -208,6 +212,6 @@
  87. /* Definitions for xattr.h */
  88. #define __UAPI_DEF_XATTR 1
  89. -#endif /* __GLIBC__ */
  90. +#endif /* __KERNEL__ */
  91. #endif /* _UAPI_LIBC_COMPAT_H */