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