diff mbox

[v05,66/72] uapi icmp.h: glibc netinet/ip_icmp.h header file compatibility fixes

Message ID 1471890809-4383-67-git-send-email-mikko.rapeli@iki.fi
State Changes Requested, archived
Headers show

Commit Message

Mikko Rapeli Aug. 22, 2016, 6:33 p.m. UTC
Fixes this userspace compile error when glibc netinet/ip_icmp.h is included
before linux/icmp.h:

linux/icmp.h:68:8: error: redefinition of ‘struct icmphdr’

Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
---
 include/uapi/linux/icmp.h        |  4 +++-
 include/uapi/linux/libc-compat.h | 10 ++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/include/uapi/linux/icmp.h b/include/uapi/linux/icmp.h
index fddd9d7..cd38005 100644
--- a/include/uapi/linux/icmp.h
+++ b/include/uapi/linux/icmp.h
@@ -17,6 +17,7 @@ 
 #ifndef _UAPI_LINUX_ICMP_H
 #define _UAPI_LINUX_ICMP_H
 
+#include <linux/libc-compat.h>
 #include <linux/types.h>
 
 #define ICMP_ECHOREPLY		0	/* Echo Reply			*/
@@ -64,7 +65,7 @@ 
 #define ICMP_EXC_TTL		0	/* TTL count exceeded		*/
 #define ICMP_EXC_FRAGTIME	1	/* Fragment Reass time exceeded	*/
 
-
+#if __UAPI_DEF_ICMPHDR
 struct icmphdr {
   __u8		type;
   __u8		code;
@@ -82,6 +83,7 @@  struct icmphdr {
 	__u8	reserved[4];
   } un;
 };
+#endif /* __UAPI_DEF_ICMPHDR */
 
 
 /*
diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index 40190a4..8a5a7cc 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -154,6 +154,13 @@ 
 
 #endif /* _NETINET_IN_H */
 
+/* Coordinate with glibc netinet/ip_icmp.h header. */
+#if defined(__NETINET_IP_ICMP_H)
+#define __UAPI_DEF_ICMPHDR		0
+#else /* defined(__NETINET_IP_ICMP_H) */
+#define __UAPI_DEF_ICMPHDR		1
+#endif /* defined(__NETINET_IP_ICMP_H) */
+
 /* Coordinate with glibc netipx/ipx.h header. */
 #if defined(__NETIPX_IPX_H)
 
@@ -218,6 +225,9 @@ 
 #define __UAPI_DEF_IN6_PKTINFO		1
 #define __UAPI_DEF_IP6_MTUINFO		1
 
+/* Definitions for icmp.h */
+#define __UAPI_DEF_ICMPHDR		1
+
 /* Definitions for ipx.h */
 #define __UAPI_DEF_SOCKADDR_IPX			1
 #define __UAPI_DEF_IPX_ROUTE_DEFINITION		1