From: Chris Renshaw <osm0sis@outlook.com>
Date: Fri, 12 Apr 2019 00:16:34 -0300
Subject: [PATCH] include: compiler: fix tools-only compiles on Cygwin and
 with the Android NDK on Linux

---
 Makefile                    |  2 +-
 include/compiler.h          |  7 +++++++
 include/linux/posix_types.h | 13 +++++++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index aedc2ea4d93..700aef52ef9 100644
--- a/Makefile
+++ b/Makefile
@@ -269,7 +269,7 @@ HOSTCFLAGS += $(CSTD_FLAG)
 endif
 
 ifeq ($(HOSTOS),cygwin)
-HOSTCFLAGS	+= -ansi
+HOSTCFLAGS += $(CSTD_FLAG)
 endif
 
 # Mac OS X / Darwin's C preprocessor is Apple specific.  It
diff --git a/include/compiler.h b/include/compiler.h
index 29507f9840e..9fd7258d88c 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -44,10 +44,17 @@
 #ifdef __linux__
 # include <endian.h>
 # include <byteswap.h>
+#elif defined(__CYGWIN__)
+# include <linux/types.h>
+# include <linux/byteorder/swab.h>
 #elif defined(__MACH__) || defined(__FreeBSD__)
 # include <machine/endian.h>
 typedef unsigned long ulong;
 #endif
+#ifdef __ANDROID__
+# include <linux/byteorder/swab.h>
+typedef unsigned long ulong;
+#endif
 #ifdef __FreeBSD__
 # include <sys/endian.h> /* htole32 and friends */
 # define __BYTE_ORDER BYTE_ORDER
diff --git a/include/linux/posix_types.h b/include/linux/posix_types.h
index bd37e1faf45..236e74c03d2 100644
--- a/include/linux/posix_types.h
+++ b/include/linux/posix_types.h
@@ -45,4 +45,17 @@ typedef int __kernel_key_t;
 
 #include <asm/posix_types.h>
 
+#ifndef __kernel_ulong_t
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
+#endif
+
+#ifndef __kernel_daddr_t
+typedef int __kernel_daddr_t;
+#endif
+
+#ifndef __kernel_ino_t
+typedef __kernel_ulong_t __kernel_ino_t;
+#endif
+
 #endif /* _LINUX_POSIX_TYPES_H */
-- 
2.17.0

