emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC] Correctly handling MinGW-w64


From: Óscar Fuentes
Subject: [RFC] Correctly handling MinGW-w64
Date: Mon, 17 Nov 2014 04:24:18 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

What follows are the required changes for detecting MinGW-w64 with the
sanctioned method, as discussed on

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18699#25

Please pay special attention to the configure.ac changes. This is the
first time (and hopefully the last) that I touch autoconf stuff.

Right now I can't test the change because the build fails with

./temacs: cannot execute binary file: Exec format error
Makefile:833: recipe for target 'bootstrap-emacs.exe' failed

This happens with the unpatched upstream Emacs sources.


Changes from master to working tree
8 files changed, 29 insertions(+), 14 deletions(-)
 admin/CPP-DEFINES |  3 ++-
 configure.ac      | 15 +++++++++++++++
 nt/addpm.c        |  5 ++---
 nt/inc/ms-w32.h   |  6 +++---
 nt/preprep.c      |  2 +-
 src/w32.c         |  4 ++--
 src/w32heap.c     |  4 ++--
 src/w32term.c     |  4 ++--

        Modified   admin/CPP-DEFINES
diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES
index a98d1b9..18423c2 100644
--- a/admin/CPP-DEFINES
+++ b/admin/CPP-DEFINES
@@ -19,8 +19,9 @@ __MSDOS__     Ditto.
 __DJGPP_MINOR__ Minor version number of the DJGPP library; used only in 
msdos.c and dosfns.c.
 DOS_NT         Compiling for either the MS-DOS or native MS-Windows port.
 WINDOWSNT      Compiling the native MS-Windows (W32) port.
-__MINGW32__    Compiling the W32 port with the MinGW port of GCC.
+__MINGW32__    Compiling the W32 port with the MinGW or MinGW-w64 ports of GCC.
 _MSC_VER       Compiling the W32 port with the Microsoft C compiler.
+MINGW_W64      Compiling the W32 port with the MinGW-w64 port of GCC.
 DARWIN_OS      Compiling on Mac OS X or pure Darwin (and using s/darwin.h).
 SOLARIS2
 USG
        Modified   configure.ac
diff --git a/configure.ac b/configure.ac
index 5d71c2f..ed329f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1297,6 +1297,21 @@ case "$opsys" in
 esac
 
 
+dnl We need to distinguish MinGW32 toolset from its spin-off
+dnl MinGW-w64. (This has nothing to do with word size.)
+MINGW_W64=no
+if test $opsys = mingw32; then
+    AC_CHECK_DECL(__MINGW64_VERSION_MAJOR,
+                   MINGW_W64=yes,
+                   MINGW_W64=no,
+                   [#include <_mingw.h>])
+    if test "$MINGW_W64" = "yes"; then
+       AC_DEFINE([MINGW_W64], 1,
+          [Define to 1 if you are using the MinGW-w64 toolset, regardless of 
word size.])
+    fi
+fi
+
+
 C_SWITCH_MACHINE=
 case $canonical in
  alpha*)
        Modified   nt/addpm.c
diff --git a/nt/addpm.c b/nt/addpm.c
index 18057b5..7e58ef3 100644
--- a/nt/addpm.c
+++ b/nt/addpm.c
@@ -38,9 +38,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <stdio.h>
 #include <malloc.h>
 
-/* MinGW64 defines _W64 and barfs if _WIN32_IE is defined to anything
-   below 0x500.  */
-#ifndef _W64
+/* MinGW64 barfs if _WIN32_IE is defined to anything below 0x500.  */
+#ifndef MINGW_W64
 #define _WIN32_IE 0x400
 #endif
 /* Request C Object macros for COM interfaces.  */
        Modified   nt/inc/ms-w32.h
diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h
index edb143c..ff6a186 100644
--- a/nt/inc/ms-w32.h
+++ b/nt/inc/ms-w32.h
@@ -139,7 +139,7 @@ extern char *getenv ();
    versions we still support.  MinGW64 defines this to a higher value
    in its system headers, and is not really compatible with values
    lower than 0x0500, so leave it alone.  */
-#ifndef _W64
+#ifndef MINGW_W64
 # undef _WIN32_WINNT
 # define _WIN32_WINNT 0x0400
 #endif
@@ -167,7 +167,7 @@ extern char *getenv ();
 
 #ifdef emacs
 
-#ifdef _W64
+#ifdef MINGW_W64
 /* MinGW64 specific stuff.  */
 /* Make sure 'struct timespec' and 'struct timezone' are defined.  */
 #include <sys/types.h>
@@ -370,7 +370,7 @@ typedef int sigset_t;
 typedef int ssize_t;
 #endif
 
-#ifdef _W64    /* MinGW64 */
+#ifdef MINGW_W64
 #ifndef _POSIX
 typedef _sigset_t sigset_t;
 #endif
        Modified   nt/preprep.c
diff --git a/nt/preprep.c b/nt/preprep.c
index fda937d..39a9b70 100644
--- a/nt/preprep.c
+++ b/nt/preprep.c
@@ -25,7 +25,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <fcntl.h>
 #include <time.h>
-#if defined(__GNUC__) && !defined(_W64)
+#if defined(__GNUC__) && !defined(MINGW_W64)
 #define _ANONYMOUS_UNION
 #define _ANONYMOUS_STRUCT
 #endif
        Modified   src/w32.c
diff --git a/src/w32.c b/src/w32.c
index f014cd7..8d8f536 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -72,7 +72,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <pwd.h>
 #include <grp.h>
 
-/* MinGW64 (_W64) defines these in its _mingw.h.  */
+/* MinGW64 defines these in its _mingw.h.  */
 #ifndef _ANONYMOUS_UNION
 # define _ANONYMOUS_UNION
 #endif
@@ -151,7 +151,7 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX {
 #define SDDL_REVISION_1        1
 #endif /* SDDL_REVISION_1 */
 
-#if defined(_MSC_VER) || defined(_W64)
+#if defined(_MSC_VER) || defined(MINGW_W64)
 /* MSVC and MinGW64 don't provide the definition of
    REPARSE_DATA_BUFFER and the associated macros, except on ntifs.h,
    which cannot be included because it triggers conflicts with other
        Modified   src/w32heap.c
diff --git a/src/w32heap.c b/src/w32heap.c
index c431b87..2a76641 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -214,7 +214,7 @@ dumped_data_commit (PVOID Base, PVOID *CommitAddress, 
PSIZE_T CommitSize)
 
 /* We want to turn on Low Fragmentation Heap for XP and older systems.
    MinGW32 lacks those definitions.  */
-#ifndef _W64
+#ifndef MINGW_W64
 typedef enum _HEAP_INFORMATION_CLASS {
   HeapCompatibilityInformation
 } HEAP_INFORMATION_CLASS;
@@ -244,7 +244,7 @@ init_heap (void)
       /* Create the private heap.  */
       heap = HeapCreate (0, 0, 0);
 
-#ifndef _W64
+#ifndef MINGW_W64
       /* Set the low-fragmentation heap for OS before Vista.  */
       HMODULE hm_kernel32dll = LoadLibrary ("kernel32.dll");
       HeapSetInformation_Proc s_pfn_Heap_Set_Information = 
(HeapSetInformation_Proc) GetProcAddress (hm_kernel32dll, "HeapSetInformation");
        Modified   src/w32term.c
diff --git a/src/w32term.c b/src/w32term.c
index c2a37d0..94b332b 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -101,10 +101,10 @@ extern Cursor w32_load_cursor (LPCTSTR name);
 struct w32_display_info one_w32_display_info;
 struct w32_display_info *x_display_list;
 
-#if _WIN32_WINNT < 0x0500 && !defined(_W64)
+#if _WIN32_WINNT < 0x0500 && !defined(MINGW_W64)
 /* Pre Windows 2000, this was not available, but define it here so
    that Emacs compiled on such a platform will run on newer versions.
-   MinGW64 (_W64) defines these unconditionally, so avoid redefining.  */
+   MinGW64 defines these unconditionally, so avoid redefining.  */
 
 typedef struct tagWCRANGE
 {





reply via email to

[Prev in Thread] Current Thread [Next in Thread]