ramips: fix cd-poll sd card remove randomly
[openwrt/staging/chunkeey.git] / target / linux / generic / patches-4.4 / 271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch
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
6 Musl provides the same structs as glibc, but does not provide a define to
7 allow its detection. Since the absence of __GLIBC__ also can mean that it
8 is included from the kernel, change the __GLIBC__ detection to
9 !__KERNEL__, which should always be true when included from userspace.
10
11 Signed-off-by: John Spencer <maillist-linux@barfooze.de>
12 Tested-by: David Heidelberger <david.heidelberger@ixit.cz>
13 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
14 ---
15 include/uapi/linux/libc-compat.h | 18 +++++++++---------
16 1 file changed, 9 insertions(+), 9 deletions(-)
17
18 --- a/include/uapi/linux/libc-compat.h
19 +++ b/include/uapi/linux/libc-compat.h
20 @@ -48,13 +48,13 @@
21 #ifndef _UAPI_LIBC_COMPAT_H
22 #define _UAPI_LIBC_COMPAT_H
23
24 -/* We have included glibc headers... */
25 -#if defined(__GLIBC__)
26 +/* We have included libc headers... */
27 +#if !defined(__KERNEL__)
28
29 -/* Coordinate with glibc net/if.h header. */
30 +/* Coordinate with libc net/if.h header. */
31 #if defined(_NET_IF_H) && defined(__USE_MISC)
32
33 -/* GLIBC headers included first so don't define anything
34 +/* LIBC headers included first so don't define anything
35 * that would already be defined. */
36
37 #define __UAPI_DEF_IF_IFCONF 0
38 @@ -85,10 +85,10 @@
39
40 #endif /* _NET_IF_H */
41
42 -/* Coordinate with glibc netinet/in.h header. */
43 +/* Coordinate with libc netinet/in.h header. */
44 #if defined(_NETINET_IN_H)
45
46 -/* GLIBC headers included first so don't define anything
47 +/* LIBC headers included first so don't define anything
48 * that would already be defined. */
49 #define __UAPI_DEF_IN_ADDR 0
50 #define __UAPI_DEF_IN_IPPROTO 0
51 @@ -102,7 +102,7 @@
52 * if the glibc code didn't define them. This guard matches
53 * the guard in glibc/inet/netinet/in.h which defines the
54 * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
55 -#if defined(__USE_MISC) || defined (__USE_GNU)
56 +#if !defined(__GLIBC__) || defined(__USE_MISC) || defined (__USE_GNU)
57 #define __UAPI_DEF_IN6_ADDR_ALT 0
58 #else
59 #define __UAPI_DEF_IN6_ADDR_ALT 1
60 @@ -117,7 +117,7 @@
61 #else
62
63 /* Linux headers included first, and we must define everything
64 - * we need. The expectation is that glibc will check the
65 + * we need. The expectation is that the libc will check the
66 * __UAPI_DEF_* defines and adjust appropriately. */
67 #define __UAPI_DEF_IN_ADDR 1
68 #define __UAPI_DEF_IN_IPPROTO 1
69 @@ -127,7 +127,7 @@
70 #define __UAPI_DEF_IN_CLASS 1
71
72 #define __UAPI_DEF_IN6_ADDR 1
73 -/* We unconditionally define the in6_addr macros and glibc must
74 +/* We unconditionally define the in6_addr macros and the libc must
75 * coordinate. */
76 #define __UAPI_DEF_IN6_ADDR_ALT 1
77 #define __UAPI_DEF_SOCKADDR_IN6 1
78 @@ -149,7 +149,7 @@
79 /* If we did not see any headers from any supported C libraries,
80 * or we are being included in the kernel, then define everything
81 * that we need. */
82 -#else /* !defined(__GLIBC__) */
83 +#else /* defined(__KERNEL__) */
84
85 /* Definitions for if.h */
86 #define __UAPI_DEF_IF_IFCONF 1
87 @@ -182,6 +182,6 @@
88 /* Definitions for xattr.h */
89 #define __UAPI_DEF_XATTR 1
90
91 -#endif /* __GLIBC__ */
92 +#endif /* __KERNEL__ */
93
94 #endif /* _UAPI_LIBC_COMPAT_H */