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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. From f972afc2509eebcb00d370256c55b112a3b5ffca Mon Sep 17 00:00:00 2001
  2. From: David Heidelberger <david.heidelberger@ixit.cz>
  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 <maillist-linux@barfooze.de>
  10. Tested-by: David Heidelberger <david.heidelberger@ixit.cz>
  11. Signed-off-by: Jonas Gorski <jogo@openwrt.org>
  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. +/* Coordinate with libc net/if.h header. */
  26. #if defined(_NET_IF_H) && defined(__USE_MISC)
  27. -/* GLIBC headers included first so don't define anything
  28. +/* LIBC headers included first so don't define anything
  29. * that would already be defined. */
  30. #define __UAPI_DEF_IF_IFCONF 0
  31. @@ -85,10 +85,10 @@
  32. #endif /* _NET_IF_H */
  33. -/* Coordinate with glibc netinet/in.h header. */
  34. +/* Coordinate with libc netinet/in.h header. */
  35. #if defined(_NETINET_IN_H)
  36. -/* GLIBC headers included first so don't define anything
  37. +/* LIBC headers included first so don't define anything
  38. * that would already be defined. */
  39. #define __UAPI_DEF_IN_ADDR 0
  40. #define __UAPI_DEF_IN_IPPROTO 0
  41. @@ -102,7 +102,7 @@
  42. * if the glibc code didn't define them. This guard matches
  43. * the guard in glibc/inet/netinet/in.h which defines the
  44. * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
  45. -#if defined(__USE_MISC) || defined (__USE_GNU)
  46. +#if !defined(__GLIBC__) || defined(__USE_MISC) || defined (__USE_GNU)
  47. #define __UAPI_DEF_IN6_ADDR_ALT 0
  48. #else
  49. #define __UAPI_DEF_IN6_ADDR_ALT 1
  50. @@ -117,7 +117,7 @@
  51. #else
  52. /* Linux headers included first, and we must define everything
  53. - * we need. The expectation is that glibc will check the
  54. + * we need. The expectation is that the libc will check the
  55. * __UAPI_DEF_* defines and adjust appropriately. */
  56. #define __UAPI_DEF_IN_ADDR 1
  57. #define __UAPI_DEF_IN_IPPROTO 1
  58. @@ -127,7 +127,7 @@
  59. #define __UAPI_DEF_IN_CLASS 1
  60. #define __UAPI_DEF_IN6_ADDR 1
  61. -/* We unconditionally define the in6_addr macros and glibc must
  62. +/* We unconditionally define the in6_addr macros and the libc must
  63. * coordinate. */
  64. #define __UAPI_DEF_IN6_ADDR_ALT 1
  65. #define __UAPI_DEF_SOCKADDR_IN6 1
  66. @@ -149,7 +149,7 @@
  67. /* If we did not see any headers from any supported C libraries,
  68. * or we are being included in the kernel, then define everything
  69. * that we need. */
  70. -#else /* !defined(__GLIBC__) */
  71. +#else /* defined(__KERNEL__) */
  72. /* Definitions for if.h */
  73. #define __UAPI_DEF_IF_IFCONF 1
  74. @@ -182,6 +182,6 @@
  75. /* Definitions for xattr.h */
  76. #define __UAPI_DEF_XATTR 1
  77. -#endif /* __GLIBC__ */
  78. +#endif /* __KERNEL__ */
  79. #endif /* _UAPI_LIBC_COMPAT_H */