Commit 9c501935a3cdcf6b1d35aaee3aa11c7a7051a305

Authored by Ben Hutchings
Committed by David S. Miller
1 parent 9240d7154e

net: Support inclusion of <linux/socket.h> before <sys/socket.h>

The following user-space program fails to compile:

    #include <linux/socket.h>
    #include <sys/socket.h>
    int main() { return 0; }

The reason is that <linux/socket.h> tests __GLIBC__ to decide whether it
should define various structures and macros that are now defined for
user-space by <sys/socket.h>, but __GLIBC__ is not defined if no libc
headers have yet been included.

It seems safe to drop support for libc 5 now.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Bastian Blank <waldi@debian.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 3 additions and 18 deletions Side-by-side Diff

include/linux/socket.h
... ... @@ -16,7 +16,7 @@
16 16 /* _SS_MAXSIZE value minus size of ss_family */
17 17 } __attribute__ ((aligned(_K_SS_ALIGNSIZE))); /* force desired alignment */
18 18  
19   -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
  19 +#ifdef __KERNEL__
20 20  
21 21 #include <asm/socket.h> /* arch-dependent defines */
22 22 #include <linux/sockios.h> /* the SIOCxxx I/O controls */
... ... @@ -101,21 +101,6 @@
101 101 ((char *)(cmsg) - (char *)(mhdr)->msg_control)))
102 102  
103 103 /*
104   - * This mess will go away with glibc
105   - */
106   -
107   -#ifdef __KERNEL__
108   -#define __KINLINE static inline
109   -#elif defined(__GNUC__)
110   -#define __KINLINE static __inline__
111   -#elif defined(__cplusplus)
112   -#define __KINLINE static inline
113   -#else
114   -#define __KINLINE static
115   -#endif
116   -
117   -
118   -/*
119 104 * Get the next cmsg header
120 105 *
121 106 * PLEASE, do not touch this function. If you think, that it is
... ... @@ -128,7 +113,7 @@
128 113 * ancillary object DATA. --ANK (980731)
129 114 */
130 115  
131   -__KINLINE struct cmsghdr * __cmsg_nxthdr(void *__ctl, __kernel_size_t __size,
  116 +static inline struct cmsghdr * __cmsg_nxthdr(void *__ctl, __kernel_size_t __size,
132 117 struct cmsghdr *__cmsg)
133 118 {
134 119 struct cmsghdr * __ptr;
... ... @@ -140,7 +125,7 @@
140 125 return __ptr;
141 126 }
142 127  
143   -__KINLINE struct cmsghdr * cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr *__cmsg)
  128 +static inline struct cmsghdr * cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr *__cmsg)
144 129 {
145 130 return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg);
146 131 }