History

uapi libc compat: add fallback for unsupported libcs

libc-compat.h aims to prevent symbol collisions between uapi and libc headers for each supported libc. This requires continuous coordination between them. The goal of this commit is to improve the situation for libcs (such as musl) which are not yet supported and/or do not wish to be explicitly supported, while not affecting supported libcs. More precisely, with this commit, unsupported libcs can request the suppression of any specific uapi definition by defining the correspondings _UAPI_DEF_* macro as 0. This can fix symbol collisions for them, as long as the libc headers are included before the uapi headers. Inclusion in the other order is outside the scope of this commit. All infrastructure in order to enable this fallback for unsupported libcs is already in place, except that libc-compat.h unconditionally defines all _UAPI_DEF_* macros to 1 for all unsupported libcs so that any previous definitions are ignored. In order to fix this, this commit merely makes these definitions conditional. This commit together with the musl libc commit http://git.musl-libc.org/cgit/musl/commit/?id=04983f2272382af92eb8f8838964ff944fbb8258 fixes for example the following compiler errors when <linux/in6.h> is included after musl's <netinet/in.h>: ./linux/in6.h:32:8: error: redefinition of 'struct in6_addr' ./linux/in6.h:49:8: error: redefinition of 'struct sockaddr_in6' ./linux/in6.h:59:8: error: redefinition of 'struct ipv6_mreq' The comments referencing glibc are still correct, but this file is not only used for glibc any more.

Felix Janda committed 8 years ago

Commit c0bace71 parent f9c935d1 file · +54 −1Browse files

Showing the changes to include/uapi/linux (1 of 1 file). Show all

Unified · Split

include/uapi/linux/libc-compat.h+54−1
@@ -168,46 +168,99 @@ · 167 unmodified lines
168168
169169 /* If we did not see any headers from any supported C libraries,
170170 * or we are being included in the kernel, then define everything
171− * that we need. */
171+ * that we need. Check for previous __UAPI_* definitions to give
172+ * unsupported C libraries a way to opt out of any kernel definition. */
172173 #else /* !defined(__GLIBC__) */
173174
174175 /* Definitions for if.h */
176+#ifndef __UAPI_DEF_IF_IFCONF
175177 #define __UAPI_DEF_IF_IFCONF 1
178+#endif
179+#ifndef __UAPI_DEF_IF_IFMAP
176180 #define __UAPI_DEF_IF_IFMAP 1
181+#endif
182+#ifndef __UAPI_DEF_IF_IFNAMSIZ
177183 #define __UAPI_DEF_IF_IFNAMSIZ 1
184+#endif
185+#ifndef __UAPI_DEF_IF_IFREQ
178186 #define __UAPI_DEF_IF_IFREQ 1
187+#endif
179188 /* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */
189+#ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS
180190 #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1
191+#endif
181192 /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
193+#ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
182194 #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
195+#endif
183196
184197 /* Definitions for in.h */
198+#ifndef __UAPI_DEF_IN_ADDR
185199 #define __UAPI_DEF_IN_ADDR 1
200+#endif
201+#ifndef __UAPI_DEF_IN_IPPROTO
186202 #define __UAPI_DEF_IN_IPPROTO 1
203+#endif
204+#ifndef __UAPI_DEF_IN_PKTINFO
187205 #define __UAPI_DEF_IN_PKTINFO 1
206+#endif
207+#ifndef __UAPI_DEF_IP_MREQ
188208 #define __UAPI_DEF_IP_MREQ 1
209+#endif
210+#ifndef __UAPI_DEF_SOCKADDR_IN
189211 #define __UAPI_DEF_SOCKADDR_IN 1
212+#endif
213+#ifndef __UAPI_DEF_IN_CLASS
190214 #define __UAPI_DEF_IN_CLASS 1
215+#endif
191216
192217 /* Definitions for in6.h */
218+#ifndef __UAPI_DEF_IN6_ADDR
193219 #define __UAPI_DEF_IN6_ADDR 1
220+#endif
221+#ifndef __UAPI_DEF_IN6_ADDR_ALT
194222 #define __UAPI_DEF_IN6_ADDR_ALT 1
223+#endif
224+#ifndef __UAPI_DEF_SOCKADDR_IN6
195225 #define __UAPI_DEF_SOCKADDR_IN6 1
226+#endif
227+#ifndef __UAPI_DEF_IPV6_MREQ
196228 #define __UAPI_DEF_IPV6_MREQ 1
229+#endif
230+#ifndef __UAPI_DEF_IPPROTO_V6
197231 #define __UAPI_DEF_IPPROTO_V6 1
232+#endif
233+#ifndef __UAPI_DEF_IPV6_OPTIONS
198234 #define __UAPI_DEF_IPV6_OPTIONS 1
235+#endif
236+#ifndef __UAPI_DEF_IN6_PKTINFO
199237 #define __UAPI_DEF_IN6_PKTINFO 1
238+#endif
239+#ifndef __UAPI_DEF_IP6_MTUINFO
200240 #define __UAPI_DEF_IP6_MTUINFO 1
241+#endif
201242
202243 /* Definitions for ipx.h */
244+#ifndef __UAPI_DEF_SOCKADDR_IPX
203245 #define __UAPI_DEF_SOCKADDR_IPX 1
246+#endif
247+#ifndef __UAPI_DEF_IPX_ROUTE_DEFINITION
204248 #define __UAPI_DEF_IPX_ROUTE_DEFINITION 1
249+#endif
250+#ifndef __UAPI_DEF_IPX_INTERFACE_DEFINITION
205251 #define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1
252+#endif
253+#ifndef __UAPI_DEF_IPX_CONFIG_DATA
206254 #define __UAPI_DEF_IPX_CONFIG_DATA 1
255+#endif
256+#ifndef __UAPI_DEF_IPX_ROUTE_DEF
207257 #define __UAPI_DEF_IPX_ROUTE_DEF 1
258+#endif
208259
209260 /* Definitions for xattr.h */
261+#ifndef __UAPI_DEF_XATTR
210262 #define __UAPI_DEF_XATTR 1
263+#endif
211264
212265 #endif /* __GLIBC__ */
213266

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t