kernel: add linux 4.4 support
[openwrt.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 netinet/in.h header. */
30 +/* Coordinate with libc netinet/in.h header. */
31  #if defined(_NETINET_IN_H)
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  #define __UAPI_DEF_IN_ADDR             0
37  #define __UAPI_DEF_IN_IPPROTO          0
38 @@ -68,7 +68,7 @@
39   * if the glibc code didn't define them. This guard matches
40   * the guard in glibc/inet/netinet/in.h which defines the
41   * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
42 -#if defined(__USE_MISC) || defined (__USE_GNU)
43 +#if !defined(__GLIBC__) || defined(__USE_MISC) || defined (__USE_GNU)
44  #define __UAPI_DEF_IN6_ADDR_ALT                0
45  #else
46  #define __UAPI_DEF_IN6_ADDR_ALT                1
47 @@ -83,7 +83,7 @@
48  #else
49  
50  /* Linux headers included first, and we must define everything
51 - * we need. The expectation is that glibc will check the
52 + * we need. The expectation is that the libc will check the
53   * __UAPI_DEF_* defines and adjust appropriately. */
54  #define __UAPI_DEF_IN_ADDR             1
55  #define __UAPI_DEF_IN_IPPROTO          1
56 @@ -93,7 +93,7 @@
57  #define __UAPI_DEF_IN_CLASS            1
58  
59  #define __UAPI_DEF_IN6_ADDR            1
60 -/* We unconditionally define the in6_addr macros and glibc must
61 +/* We unconditionally define the in6_addr macros and the libc must
62   * coordinate. */
63  #define __UAPI_DEF_IN6_ADDR_ALT                1
64  #define __UAPI_DEF_SOCKADDR_IN6                1
65 @@ -115,7 +115,7 @@
66  /* If we did not see any headers from any supported C libraries,
67   * or we are being included in the kernel, then define everything
68   * that we need. */
69 -#else /* !defined(__GLIBC__) */
70 +#else /* defined(__KERNEL__) */
71  
72  /* Definitions for in.h */
73  #define __UAPI_DEF_IN_ADDR             1
74 @@ -138,6 +138,6 @@
75  /* Definitions for xattr.h */
76  #define __UAPI_DEF_XATTR               1
77  
78 -#endif /* __GLIBC__ */
79 +#endif /* __KERNEL__ */
80  
81  #endif /* _UAPI_LIBC_COMPAT_H */