ar71xx: keep the RouterBOARD Power LED in On state
[oweals/openwrt.git] / target / linux / generic / patches-4.9 / 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 -#if defined(_NET_IF_H) && defined(__USE_MISC)
31 +/* Coordinate with libc net/if.h header. */
32 +#if defined(_NET_IF_H) && (!defined(__GLIBC__) || defined(__USE_MISC))
33  
34 -/* GLIBC headers included first so don't define anything
35 +/* LIBC headers included first so don't define anything
36   * that would already be defined. */
37  
38  #define __UAPI_DEF_IF_IFCONF 0
39 @@ -65,7 +65,11 @@
40  #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0
41  /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
42  #ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
43 +#ifdef __GLIBC__
44  #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
45 +#else
46 +#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 0
47 +#endif
48  #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
49  
50  #else /* _NET_IF_H */
51 @@ -85,10 +89,10 @@
52  
53  #endif /* _NET_IF_H */
54  
55 -/* Coordinate with glibc netinet/in.h header. */
56 +/* Coordinate with libc netinet/in.h header. */
57  #if defined(_NETINET_IN_H)
58  
59 -/* GLIBC headers included first so don't define anything
60 +/* LIBC headers included first so don't define anything
61   * that would already be defined. */
62  #define __UAPI_DEF_IN_ADDR             0
63  #define __UAPI_DEF_IN_IPPROTO          0
64 @@ -102,7 +106,7 @@
65   * if the glibc code didn't define them. This guard matches
66   * the guard in glibc/inet/netinet/in.h which defines the
67   * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
68 -#if defined(__USE_MISC) || defined (__USE_GNU)
69 +#if !defined(__GLIBC__) || defined(__USE_MISC) || defined (__USE_GNU)
70  #define __UAPI_DEF_IN6_ADDR_ALT                0
71  #else
72  #define __UAPI_DEF_IN6_ADDR_ALT                1
73 @@ -117,7 +121,7 @@
74  #else
75  
76  /* Linux headers included first, and we must define everything
77 - * we need. The expectation is that glibc will check the
78 + * we need. The expectation is that the libc will check the
79   * __UAPI_DEF_* defines and adjust appropriately. */
80  #define __UAPI_DEF_IN_ADDR             1
81  #define __UAPI_DEF_IN_IPPROTO          1
82 @@ -127,7 +131,7 @@
83  #define __UAPI_DEF_IN_CLASS            1
84  
85  #define __UAPI_DEF_IN6_ADDR            1
86 -/* We unconditionally define the in6_addr macros and glibc must
87 +/* We unconditionally define the in6_addr macros and the libc must
88   * coordinate. */
89  #define __UAPI_DEF_IN6_ADDR_ALT                1
90  #define __UAPI_DEF_SOCKADDR_IN6                1
91 @@ -168,7 +172,7 @@
92  /* If we did not see any headers from any supported C libraries,
93   * or we are being included in the kernel, then define everything
94   * that we need. */
95 -#else /* !defined(__GLIBC__) */
96 +#else /* defined(__KERNEL__) */
97  
98  /* Definitions for if.h */
99  #define __UAPI_DEF_IF_IFCONF 1
100 @@ -208,6 +212,6 @@
101  /* Definitions for xattr.h */
102  #define __UAPI_DEF_XATTR               1
103  
104 -#endif /* __GLIBC__ */
105 +#endif /* __KERNEL__ */
106  
107  #endif /* _UAPI_LIBC_COMPAT_H */