From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.devel Subject: [RFC] Correctly handling MinGW-w64 Date: Mon, 17 Nov 2014 04:24:18 +0100 Message-ID: <87r3x2qyjg.fsf@wanadoo.es> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1416196038 3502 80.91.229.3 (17 Nov 2014 03:47:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 17 Nov 2014 03:47:18 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 17 04:47:13 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XqDHR-0003pp-LE for ged-emacs-devel@m.gmane.org; Mon, 17 Nov 2014 04:47:09 +0100 Original-Received: from localhost ([::1]:45961 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqDHR-0006Rd-9D for ged-emacs-devel@m.gmane.org; Sun, 16 Nov 2014 22:47:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqDHI-0006RN-Ud for emacs-devel@gnu.org; Sun, 16 Nov 2014 22:47:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XqDHD-00012L-2q for emacs-devel@gnu.org; Sun, 16 Nov 2014 22:47:00 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:57905) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqDHC-00012B-Pc for emacs-devel@gnu.org; Sun, 16 Nov 2014 22:46:55 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XqDHB-0003kq-HX for emacs-devel@gnu.org; Mon, 17 Nov 2014 04:46:53 +0100 Original-Received: from 132.red-79-158-48.staticip.rima-tde.net ([79.158.48.132]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 17 Nov 2014 04:46:53 +0100 Original-Received: from ofv by 132.red-79-158-48.staticip.rima-tde.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 17 Nov 2014 04:46:53 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 198 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 132.red-79-158-48.staticip.rima-tde.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:n02mioKW5Jli5uKD2nrgiq+rkhg= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:177383 Archived-At: 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 . */ #include #include -/* 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 @@ -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 . #include #include #include -#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 . */ #include #include -/* 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 {