2
0

270-uapi-libc-compat-add-fallback-for-unsupported-libcs.patch 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. From c6bdd0d302119819de72439972d0462c26ef9eda Mon Sep 17 00:00:00 2001
  2. From: Felix Janda <[email protected]>
  3. Date: Sun, 12 Nov 2017 13:30:17 -0500
  4. Subject: uapi libc compat: add fallback for unsupported libcs
  5. libc-compat.h aims to prevent symbol collisions between uapi and libc
  6. headers for each supported libc. This requires continuous coordination
  7. between them.
  8. The goal of this commit is to improve the situation for libcs (such as
  9. musl) which are not yet supported and/or do not wish to be explicitly
  10. supported, while not affecting supported libcs. More precisely, with
  11. this commit, unsupported libcs can request the suppression of any
  12. specific uapi definition by defining the correspondings _UAPI_DEF_*
  13. macro as 0. This can fix symbol collisions for them, as long as the
  14. libc headers are included before the uapi headers. Inclusion in the
  15. other order is outside the scope of this commit.
  16. All infrastructure in order to enable this fallback for unsupported
  17. libcs is already in place, except that libc-compat.h unconditionally
  18. defines all _UAPI_DEF_* macros to 1 for all unsupported libcs so that
  19. any previous definitions are ignored. In order to fix this, this commit
  20. merely makes these definitions conditional.
  21. This commit together with the musl libc commit
  22. http://git.musl-libc.org/cgit/musl/commit/?id=04983f2272382af92eb8f8838964ff944fbb8258
  23. fixes for example the following compiler errors when <linux/in6.h> is
  24. included after musl's <netinet/in.h>:
  25. ./linux/in6.h:32:8: error: redefinition of 'struct in6_addr'
  26. ./linux/in6.h:49:8: error: redefinition of 'struct sockaddr_in6'
  27. ./linux/in6.h:59:8: error: redefinition of 'struct ipv6_mreq'
  28. The comments referencing glibc are still correct, but this file is not
  29. only used for glibc any more.
  30. Signed-off-by: Felix Janda <[email protected]>
  31. Reviewed-by: Hauke Mehrtens <[email protected]>
  32. ---
  33. include/uapi/linux/libc-compat.h | 55 +++++++++++++++++++++++++++++++++++++++-
  34. 1 file changed, 54 insertions(+), 1 deletion(-)
  35. --- a/include/uapi/linux/libc-compat.h
  36. +++ b/include/uapi/linux/libc-compat.h
  37. @@ -168,46 +168,99 @@
  38. /* If we did not see any headers from any supported C libraries,
  39. * or we are being included in the kernel, then define everything
  40. - * that we need. */
  41. + * that we need. Check for previous __UAPI_* definitions to give
  42. + * unsupported C libraries a way to opt out of any kernel definition. */
  43. #else /* !defined(__GLIBC__) */
  44. /* Definitions for if.h */
  45. +#ifndef __UAPI_DEF_IF_IFCONF
  46. #define __UAPI_DEF_IF_IFCONF 1
  47. +#endif
  48. +#ifndef __UAPI_DEF_IF_IFMAP
  49. #define __UAPI_DEF_IF_IFMAP 1
  50. +#endif
  51. +#ifndef __UAPI_DEF_IF_IFNAMSIZ
  52. #define __UAPI_DEF_IF_IFNAMSIZ 1
  53. +#endif
  54. +#ifndef __UAPI_DEF_IF_IFREQ
  55. #define __UAPI_DEF_IF_IFREQ 1
  56. +#endif
  57. /* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */
  58. +#ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS
  59. #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1
  60. +#endif
  61. /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
  62. +#ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
  63. #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
  64. +#endif
  65. /* Definitions for in.h */
  66. +#ifndef __UAPI_DEF_IN_ADDR
  67. #define __UAPI_DEF_IN_ADDR 1
  68. +#endif
  69. +#ifndef __UAPI_DEF_IN_IPPROTO
  70. #define __UAPI_DEF_IN_IPPROTO 1
  71. +#endif
  72. +#ifndef __UAPI_DEF_IN_PKTINFO
  73. #define __UAPI_DEF_IN_PKTINFO 1
  74. +#endif
  75. +#ifndef __UAPI_DEF_IP_MREQ
  76. #define __UAPI_DEF_IP_MREQ 1
  77. +#endif
  78. +#ifndef __UAPI_DEF_SOCKADDR_IN
  79. #define __UAPI_DEF_SOCKADDR_IN 1
  80. +#endif
  81. +#ifndef __UAPI_DEF_IN_CLASS
  82. #define __UAPI_DEF_IN_CLASS 1
  83. +#endif
  84. /* Definitions for in6.h */
  85. +#ifndef __UAPI_DEF_IN6_ADDR
  86. #define __UAPI_DEF_IN6_ADDR 1
  87. +#endif
  88. +#ifndef __UAPI_DEF_IN6_ADDR_ALT
  89. #define __UAPI_DEF_IN6_ADDR_ALT 1
  90. +#endif
  91. +#ifndef __UAPI_DEF_SOCKADDR_IN6
  92. #define __UAPI_DEF_SOCKADDR_IN6 1
  93. +#endif
  94. +#ifndef __UAPI_DEF_IPV6_MREQ
  95. #define __UAPI_DEF_IPV6_MREQ 1
  96. +#endif
  97. +#ifndef __UAPI_DEF_IPPROTO_V6
  98. #define __UAPI_DEF_IPPROTO_V6 1
  99. +#endif
  100. +#ifndef __UAPI_DEF_IPV6_OPTIONS
  101. #define __UAPI_DEF_IPV6_OPTIONS 1
  102. +#endif
  103. +#ifndef __UAPI_DEF_IN6_PKTINFO
  104. #define __UAPI_DEF_IN6_PKTINFO 1
  105. +#endif
  106. +#ifndef __UAPI_DEF_IP6_MTUINFO
  107. #define __UAPI_DEF_IP6_MTUINFO 1
  108. +#endif
  109. /* Definitions for ipx.h */
  110. +#ifndef __UAPI_DEF_SOCKADDR_IPX
  111. #define __UAPI_DEF_SOCKADDR_IPX 1
  112. +#endif
  113. +#ifndef __UAPI_DEF_IPX_ROUTE_DEFINITION
  114. #define __UAPI_DEF_IPX_ROUTE_DEFINITION 1
  115. +#endif
  116. +#ifndef __UAPI_DEF_IPX_INTERFACE_DEFINITION
  117. #define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1
  118. +#endif
  119. +#ifndef __UAPI_DEF_IPX_CONFIG_DATA
  120. #define __UAPI_DEF_IPX_CONFIG_DATA 1
  121. +#endif
  122. +#ifndef __UAPI_DEF_IPX_ROUTE_DEF
  123. #define __UAPI_DEF_IPX_ROUTE_DEF 1
  124. +#endif
  125. /* Definitions for xattr.h */
  126. +#ifndef __UAPI_DEF_XATTR
  127. #define __UAPI_DEF_XATTR 1
  128. +#endif
  129. #endif /* __GLIBC__ */