summaryrefslogtreecommitdiff
blob: bff548b7a0894b5b4f5d34f74f7e77aa912d31dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
pull in the libc versions of these headers so that the proper userspace
defines/typedefs are utilized.

the trouble here is that some of the linux/ headers define structs that the
libc net/ headers define (like the if.h header).  we cannot simply say
"your program should not include linux/if.h when using net/if.h" because some
of the other linux/ headers may correctly be utilized with net/if.h but they
correctly include linux/if.h.  we also cannot say "just use the linux/ headers
and not the libc net/ headers" because the libc headers include more
definitions than its kernel equivalent.

since there is no obvious (at least to me) answer here, we hack the linux/
headers to simply pull in userspace headers and ignore the linux/ ones
completely.  this seems to give a proper clean userspace experience.

--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -303,4 +303,9 @@ extern int put_cmsg(struct msghdr*, int
 
 #endif
 #endif /* not kernel and not glibc */
+
+#ifndef __KERNEL__
+# include <sys/socket.h>
+#endif
+
 #endif /* _LINUX_SOCKET_H */
--- a/include/linux/stat.h
+++ b/include/linux/stat.h
@@ -74,4 +74,8 @@ struct kstat {
 
 #endif
 
+#ifndef __KERNEL__
+# include <sys/stat.h>
+#endif
+
 #endif
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -9,8 +9,11 @@
 	unsigned long name[BITS_TO_LONGS(bits)]
 
 #define BITS_PER_BYTE 8
-#endif
 
+#else
+#include <sys/types.h>
+#include <inttypes.h>
+#endif
 #include <linux/posix_types.h>
 #include <asm/types.h>
 
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -1,3 +1,9 @@
+#ifndef _LINUX_TIME_H
+# include <time.h>
+# include <sys/time.h>
+# define _LINUX_TIME_H
+#endif
+
 #ifndef _LINUX_TIME_H
 #define _LINUX_TIME_H
 
--- a/include/linux/if.h
+++ b/include/linux/if.h
@@ -17,6 +17,11 @@
  *		2 of the License, or (at your option) any later version.
  */
 #ifndef _LINUX_IF_H
+# include <net/if.h>
+# define _LINUX_IF_H
+#endif
+
+#ifndef _LINUX_IF_H
 #define _LINUX_IF_H
 
 #include <linux/types.h>		/* for "__kernel_caddr_t" et al	*/
--- a/include/linux/ip.h
+++ b/include/linux/ip.h
@@ -15,6 +15,11 @@
  *		2 of the License, or (at your option) any later version.
  */
 #ifndef _LINUX_IP_H
+# include <netinet/ip.h>
+# define _LINUX_IP_H
+#endif
+
+#ifndef _LINUX_IP_H
 #define _LINUX_IP_H
 #include <linux/types.h>
 #include <asm/byteorder.h>