From: "Óscar Fuentes" <ofv@wanadoo.es>
To: emacs-devel@gnu.org
Subject: [RFC] Correctly handling MinGW-w64
Date: Mon, 17 Nov 2014 04:24:18 +0100 [thread overview]
Message-ID: <87r3x2qyjg.fsf@wanadoo.es> (raw)
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
{
next reply other threads:[~2014-11-17 3:24 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-17 3:24 Óscar Fuentes [this message]
2014-11-17 4:04 ` [RFC] Correctly handling MinGW-w64 Paul Eggert
2014-11-17 4:13 ` Óscar Fuentes
2014-11-17 4:32 ` Paul Eggert
2014-11-17 14:59 ` Óscar Fuentes
2014-11-17 15:18 ` Paul Eggert
2014-11-17 15:42 ` Óscar Fuentes
2014-11-17 15:59 ` Eli Zaretskii
2014-11-17 18:23 ` Óscar Fuentes
2014-11-17 18:48 ` Eli Zaretskii
2014-11-17 19:04 ` Óscar Fuentes
2014-11-17 19:31 ` Eli Zaretskii
2014-11-17 22:19 ` Óscar Fuentes
2014-11-18 3:31 ` Glenn Morris
2014-11-18 3:50 ` Óscar Fuentes
2014-11-18 14:50 ` Stefan Monnier
2014-11-18 3:35 ` Eli Zaretskii
2014-11-17 15:57 ` Eli Zaretskii
2014-11-17 16:03 ` Paul Eggert
2014-11-17 16:34 ` Eli Zaretskii
2014-11-17 15:55 ` Eli Zaretskii
2014-11-17 16:02 ` Paul Eggert
2014-11-17 16:33 ` Eli Zaretskii
2014-11-17 4:05 ` Óscar Fuentes
2014-11-17 15:52 ` Eli Zaretskii
2014-11-17 15:51 ` Eli Zaretskii
2014-11-17 16:04 ` Óscar Fuentes
2014-11-17 16:35 ` Eli Zaretskii
2014-11-17 17:34 ` Óscar Fuentes
2014-11-18 8:24 ` Stephen Leake
2014-11-18 15:50 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r3x2qyjg.fsf@wanadoo.es \
--to=ofv@wanadoo.es \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.