* configure.ac (BASEHEAD_LIST): Add _cygwin.h.
	* configure: Regenerate.

	* _cygwin.h: New file.
	* _mingw.h.in: Include _cygwin.h when building a Cygwin application.
	Allow building Cygwin applications even though _WIN32 isn't defined.
	* vadefs.h: Drop test for _WIN32 since it's done in _mingw.h.


git-svn-id: svn+ssh://svn.code.sf.net/p/mingw-w64/code/trunk@5133 4407c894-4637-0410-b4f5-ada5f102cad1
diff --git a/mingw-w64-headers/ChangeLog b/mingw-w64-headers/ChangeLog
index 52518d7..d5a3d2b 100644
--- a/mingw-w64-headers/ChangeLog
+++ b/mingw-w64-headers/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-26  Corinna Vinschen  <vinschen@redhat.com>
+
+	* configure.ac (BASEHEAD_LIST): Add _cygwin.h.
+	* configure: Regenerate.
+
 2012-06-25  Kai Tietz  <ktietz@redhat.com>
 
 	* configure.ac (BASEHEAD_LIST): Add additional required basic-
diff --git a/mingw-w64-headers/configure b/mingw-w64-headers/configure
index b062ed9..bedec3f 100755
--- a/mingw-w64-headers/configure
+++ b/mingw-w64-headers/configure
@@ -2514,7 +2514,7 @@
 
 # Checks for header files.
 
-BASEHEAD_LIST="crt/_mingw.h crt/_mingw_mac.h crt/_mingw_print_push.h crt/_mingw_print_pop.h crt/_mingw_secapi.h crt/_mingw_unicode.h crt/vadefs.h "$srcdir/include/*.h
+BASEHEAD_LIST="crt/_cygwin.h crt/_mingw.h crt/_mingw_mac.h crt/_mingw_print_push.h crt/_mingw_print_pop.h crt/_mingw_secapi.h crt/_mingw_unicode.h crt/vadefs.h "$srcdir/include/*.h
 for i in dlg h16 hxx rh ver; do
   BASEHEAD_LIST="$BASEHEAD_LIST "$srcdir/include/*.$i
 done
diff --git a/mingw-w64-headers/configure.ac b/mingw-w64-headers/configure.ac
index e1afbe8..b481ace 100644
--- a/mingw-w64-headers/configure.ac
+++ b/mingw-w64-headers/configure.ac
@@ -41,7 +41,7 @@
 
 # Checks for header files.
 
-BASEHEAD_LIST="crt/_mingw.h crt/_mingw_mac.h crt/_mingw_print_push.h crt/_mingw_print_pop.h crt/_mingw_secapi.h crt/_mingw_unicode.h crt/vadefs.h "$srcdir/include/*.h
+BASEHEAD_LIST="crt/_cygwin.h crt/_mingw.h crt/_mingw_mac.h crt/_mingw_print_push.h crt/_mingw_print_pop.h crt/_mingw_secapi.h crt/_mingw_unicode.h crt/vadefs.h "$srcdir/include/*.h
 for i in dlg h16 hxx rh ver; do
   BASEHEAD_LIST="$BASEHEAD_LIST "$srcdir/include/*.$i
 done
diff --git a/mingw-w64-headers/crt/ChangeLog b/mingw-w64-headers/crt/ChangeLog
index 8abe668..93edfa5 100644
--- a/mingw-w64-headers/crt/ChangeLog
+++ b/mingw-w64-headers/crt/ChangeLog
@@ -1,3 +1,10 @@
+2012-06-26  Corinna Vinschen  <vinschen@redhat.com>
+
+	* _cygwin.h: New file.
+	* _mingw.h.in: Include _cygwin.h when building a Cygwin application.
+	Allow building Cygwin applications even though _WIN32 isn't defined.
+	* vadefs.h: Drop test for _WIN32 since it's done in _mingw.h.
+
 2012-06-19  Kai Tietz  <ktietz@redhat.com>
 
 	* math.h (logb, logbf): Special-case x64 inline.
diff --git a/mingw-w64-headers/crt/_cygwin.h b/mingw-w64-headers/crt/_cygwin.h
new file mode 100644
index 0000000..2be4143
--- /dev/null
+++ b/mingw-w64-headers/crt/_cygwin.h
@@ -0,0 +1,26 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+#ifndef _INC_CYGWIN
+#define _INC_CYGWIN
+
+#ifndef __CYGWIN__
+#error Only Cygwin target is supported!
+#endif
+
+/* Make sure that POSIX types are not defined by _mingw.h if we're building
+   for a Cygwin target.  In this case we have to make sure to use the types
+   defined by the Cygwin/newlib headers. */
+#define _SIZE_T_DEFINED
+#define _SSIZE_T_DEFINED
+#define _INTPTR_T_DEFINED
+#define _UINTPTR_T_DEFINED
+#define _PTRDIFF_T_DEFINED
+#define _WCHAR_T_DEFINED
+#define _WCTYPE_T_DEFINED
+#define _ERRCODE_DEFINED	/* FIXME?  errno_t is no POSIX type. */
+#define _TIME_T_DEFINED
+
+#endif /* _INC_CYGWIN */
diff --git a/mingw-w64-headers/crt/_mingw.h.in b/mingw-w64-headers/crt/_mingw.h.in
index ed7c3b6..73f5041 100644
--- a/mingw-w64-headers/crt/_mingw.h.in
+++ b/mingw-w64-headers/crt/_mingw.h.in
@@ -12,6 +12,11 @@
 #include "_mingw_mac.h"
 #include "_mingw_secapi.h"
 
+/* Include _cygwin.h if we're building a Cygwin application. */
+#ifdef __CYGWIN__
+#include "_cygwin.h"
+#endif
+
 /* C/C++ specific language defines.  */
 #ifdef _WIN64
 #ifdef __stdcall
@@ -242,7 +247,7 @@
 #endif /* __cplusplus */
 #endif /* __GNUC__ */
 
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(__CYGWIN__)
 #error Only Win32 target is supported!
 #endif
 
diff --git a/mingw-w64-headers/crt/vadefs.h b/mingw-w64-headers/crt/vadefs.h
index fdbc6a4..ae70b96 100644
--- a/mingw-w64-headers/crt/vadefs.h
+++ b/mingw-w64-headers/crt/vadefs.h
@@ -6,10 +6,6 @@
 #ifndef _INC_VADEFS
 #define _INC_VADEFS
 
-#ifndef _WIN32
-#error Only Win32 target is supported!
-#endif
-
 #include <_mingw.h>
 
 #ifndef __WIDL__