Hi,

for a start in supporting Cygwin, I created this patch.  It doesn't
error out just because _WIN32 is not defined and the new _cygwin.h file
(which will probably get a lot more to do later on) just makes sure that
_mingw.h does not define POSIX types.

Additionally, I changed vadefs.h so that it doesn't test for _WIN32
at all.  After all, it includes _mingw.h which runs this test anyway.


Hope that's ok,
Corinna


mingw-w64-headers/ChangeLog:

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

mingw-w64-headers/crt/ChangeLog:

        * _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.


Index: mingw-w64-headers/configure.ac
===================================================================
--- mingw-w64-headers/configure.ac      (revision 5132)
+++ mingw-w64-headers/configure.ac      (working copy)
@@ -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
Index: mingw-w64-headers/configure
===================================================================
--- mingw-w64-headers/configure (revision 5132)
+++ mingw-w64-headers/configure (working copy)
@@ -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
Index: mingw-w64-headers/crt/_cygwin.h
===================================================================
--- mingw-w64-headers/crt/_cygwin.h     (revision 0)
+++ mingw-w64-headers/crt/_cygwin.h     (working copy)
@@ -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 */
Index: mingw-w64-headers/crt/vadefs.h
===================================================================
--- mingw-w64-headers/crt/vadefs.h      (revision 5132)
+++ mingw-w64-headers/crt/vadefs.h      (working copy)
@@ -6,10 +6,6 @@
 #ifndef _INC_VADEFS
 #define _INC_VADEFS
 
-#ifndef _WIN32
-#error Only Win32 target is supported!
-#endif
-
 #include <_mingw.h>
 
 #ifndef __WIDL__
Index: mingw-w64-headers/crt/_mingw.h.in
===================================================================
--- mingw-w64-headers/crt/_mingw.h.in   (revision 5132)
+++ mingw-w64-headers/crt/_mingw.h.in   (working copy)
@@ -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
 

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to