1 From: David Heidelberger <david.heidelberger@ixit.cz>
2 Subject: uapi/libc-compat.h: do not rely on __GLIBC__
4 Musl provides the same structs as glibc, but does not provide a define to
5 allow its detection. Since the absence of __GLIBC__ also can mean that it
6 is included from the kernel, change the __GLIBC__ detection to
7 !__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>
13 include/uapi/linux/libc-compat.h | 18 +++++++++---------
14 1 file changed, 9 insertions(+), 9 deletions(-)
16 --- a/include/uapi/linux/libc-compat.h
17 +++ b/include/uapi/linux/libc-compat.h
19 #ifndef _UAPI_LIBC_COMPAT_H
20 #define _UAPI_LIBC_COMPAT_H
22 -/* We have included glibc headers... */
23 -#if defined(__GLIBC__)
24 +/* We have included libc headers... */
25 +#if !defined(__KERNEL__)
27 -/* Coordinate with glibc net/if.h header. */
28 -#if defined(_NET_IF_H) && defined(__USE_MISC)
29 +/* Coordinate with libc net/if.h header. */
30 +#if defined(_NET_IF_H) && (!defined(__GLIBC__) || defined(__USE_MISC))
32 -/* GLIBC headers included first so don't define anything
33 +/* LIBC headers included first so don't define anything
34 * that would already be defined. */
36 #define __UAPI_DEF_IF_IFCONF 0
38 #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0
39 /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
40 #ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
42 #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
44 +#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 0
46 #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
51 #endif /* _NET_IF_H */
53 -/* Coordinate with glibc netinet/in.h header. */
54 +/* Coordinate with libc netinet/in.h header. */
55 #if defined(_NETINET_IN_H)
57 -/* GLIBC headers included first so don't define anything
58 +/* LIBC headers included first so don't define anything
59 * that would already be defined. */
60 #define __UAPI_DEF_IN_ADDR 0
61 #define __UAPI_DEF_IN_IPPROTO 0
63 * if the glibc code didn't define them. This guard matches
64 * the guard in glibc/inet/netinet/in.h which defines the
65 * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
66 -#if defined(__USE_MISC) || defined (__USE_GNU)
67 +#if !defined(__GLIBC__) || defined(__USE_MISC) || defined (__USE_GNU)
68 #define __UAPI_DEF_IN6_ADDR_ALT 0
70 #define __UAPI_DEF_IN6_ADDR_ALT 1
74 /* Linux headers included first, and we must define everything
75 - * we need. The expectation is that glibc will check the
76 + * we need. The expectation is that the libc will check the
77 * __UAPI_DEF_* defines and adjust appropriately. */
78 #define __UAPI_DEF_IN_ADDR 1
79 #define __UAPI_DEF_IN_IPPROTO 1
81 #define __UAPI_DEF_IN_CLASS 1
83 #define __UAPI_DEF_IN6_ADDR 1
84 -/* We unconditionally define the in6_addr macros and glibc must
85 +/* We unconditionally define the in6_addr macros and the libc must
87 #define __UAPI_DEF_IN6_ADDR_ALT 1
88 #define __UAPI_DEF_SOCKADDR_IN6 1
90 /* If we did not see any headers from any supported C libraries,
91 * or we are being included in the kernel, then define everything
93 -#else /* !defined(__GLIBC__) */
94 +#else /* defined(__KERNEL__) */
96 /* Definitions for if.h */
97 #define __UAPI_DEF_IF_IFCONF 1
99 /* Definitions for xattr.h */
100 #define __UAPI_DEF_XATTR 1
102 -#endif /* __GLIBC__ */
103 +#endif /* __KERNEL__ */
105 #endif /* _UAPI_LIBC_COMPAT_H */