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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 netinet/in.h header. */
  25. +/* Coordinate with libc netinet/in.h header. */
  26. #if defined(_NETINET_IN_H)
  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_IN_ADDR 0
  31. #define __UAPI_DEF_IN_IPPROTO 0
  32. @@ -68,7 +68,7 @@
  33. * if the glibc code didn't define them. This guard matches
  34. * the guard in glibc/inet/netinet/in.h which defines the
  35. * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
  36. -#if defined(__USE_MISC) || defined (__USE_GNU)
  37. +#if !defined(__GLIBC__) || defined(__USE_MISC) || defined (__USE_GNU)
  38. #define __UAPI_DEF_IN6_ADDR_ALT 0
  39. #else
  40. #define __UAPI_DEF_IN6_ADDR_ALT 1
  41. @@ -83,7 +83,7 @@
  42. #else
  43. /* Linux headers included first, and we must define everything
  44. - * we need. The expectation is that glibc will check the
  45. + * we need. The expectation is that the libc will check the
  46. * __UAPI_DEF_* defines and adjust appropriately. */
  47. #define __UAPI_DEF_IN_ADDR 1
  48. #define __UAPI_DEF_IN_IPPROTO 1
  49. @@ -93,7 +93,7 @@
  50. #define __UAPI_DEF_IN_CLASS 1
  51. #define __UAPI_DEF_IN6_ADDR 1
  52. -/* We unconditionally define the in6_addr macros and glibc must
  53. +/* We unconditionally define the in6_addr macros and the libc must
  54. * coordinate. */
  55. #define __UAPI_DEF_IN6_ADDR_ALT 1
  56. #define __UAPI_DEF_SOCKADDR_IN6 1
  57. @@ -115,7 +115,7 @@
  58. /* If we did not see any headers from any supported C libraries,
  59. * or we are being included in the kernel, then define everything
  60. * that we need. */
  61. -#else /* !defined(__GLIBC__) */
  62. +#else /* defined(__KERNEL__) */
  63. /* Definitions for in.h */
  64. #define __UAPI_DEF_IN_ADDR 1
  65. @@ -138,6 +138,6 @@
  66. /* Definitions for xattr.h */
  67. #define __UAPI_DEF_XATTR 1
  68. -#endif /* __GLIBC__ */
  69. +#endif /* __KERNEL__ */
  70. #endif /* _UAPI_LIBC_COMPAT_H */