]> git.eshelyaron.com Git - emacs.git/commitdiff
Make the MinGW32 build compatible with MinGW runtime 4.x.
authorEli Zaretskii <eliz@gnu.org>
Sat, 12 Oct 2013 13:11:14 +0000 (16:11 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 12 Oct 2013 13:11:14 +0000 (16:11 +0300)
 nt/inc/dirent.h (struct dirent) [__MINGW_MAJOR_VERSION >= 4]: Make
 the layout of 'struct dirent' be compatible with MinGW32 runtime
 versions 4.0 and later.
 nt/inc/ms-w32.h (__MINGW_MAJOR_VERSION, __MINGW_MINOR_VERSION)
 (__MINGW_PATCHLEVEL) [!__MINGW64_VERSION_MAJOR]: Define, if not
 defined, but not for MinGW64.
 (_USE_32BIT_TIME_T) [__MINGW64_VERSION_MAJOR]: Define, to force
 use of 32-bit time_t type.

nt/ChangeLog
nt/inc/dirent.h
nt/inc/ms-w32.h

index 390a8eb02276ed58a60fa591304f9e332d47c005..cdd9ec60b11d3ceca1f6874238a8876464587217 100644 (file)
@@ -1,3 +1,15 @@
+2013-10-12  Eli Zaretskii  <eliz@gnu.org>
+
+       * inc/dirent.h (struct dirent) [__MINGW_MAJOR_VERSION >= 4]: Make
+       the layout of 'struct dirent' be compatible with MinGW32 runtime
+       versions 4.0 and later.
+
+       * inc/ms-w32.h (__MINGW_MAJOR_VERSION, __MINGW_MINOR_VERSION)
+       (__MINGW_PATCHLEVEL) [!__MINGW64_VERSION_MAJOR]: Define, if not
+       defined, but not for MinGW64.
+       (_USE_32BIT_TIME_T) [__MINGW64_VERSION_MAJOR]: Define, to force
+       use of 32-bit time_t type.
+
 2013-10-07  Paul Eggert  <eggert@cs.ucla.edu>
 
        Improve support for popcount and counting trailing zeros (Bug#15550).
index 676b82d207b6d595512b4de1f075a3323c264fe6..328635c4853b92158dea683bb6bf2902c5699c96 100644 (file)
@@ -19,6 +19,27 @@ struct dirent                                /* data from readdir() */
        long            d_ino;          /* inode number of entry */
        unsigned short  d_reclen;       /* length of this record */
        unsigned short  d_namlen;       /* length of string in d_name */
+#if __MINGW_MAJOR_VERSION >= 4
+       /* MinGW.org runtime 4.x introduces a modified layout of
+          'struct dirent', which makes it binary incompatible with
+          previous versions.  To add insult to injury, the MinGW
+          startup code calls 'readdir', which is implemented in
+          w32.c.  So we need to define the same layout of this struct
+          as the MinGW runtime does, or else command-line globbing
+          will be broken.  (Versions of MinGW runtime after 4.0 are
+          supposed not to call 'readdir' from startup code, but we
+          had better be safe than sorry.)  */
+       unsigned        d_type;         /* File attributes */
+       /* The next 3 fields are declared 'time_t' in the MinGW 4.0
+          headers, but 'time_t' is by default a 64-bit type in 4.x,
+          and presumably the libmingwex library was compiled using
+          that default definition.  So we must use 64-bit types here,
+          even though our time_t is a 32-bit type.  What a mess!  */
+       __int64         d_time_create;
+       __int64         d_time_access;  /* always midnight local time */
+       __int64         d_time_write;
+       _fsize_t        d_size;
+#endif
        char            d_name[MAXNAMLEN+1];    /* name of file */
        };
 
index e670079eb355be449ffac2e03570eb14c086c785..d5257d9a9378573ba978a59c000e9540c448a585 100644 (file)
@@ -24,6 +24,32 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #define WINDOWSNT
 #endif
 
+/* The @#$%^&! MinGW developers stopped updating the values of
+   __MINGW32_VERSION, __MINGW32_MAJOR_VERSION, and
+   __MINGW32_MINOR_VERSION values in v4.x of the runtime, to
+   "discourage its uses".  So the values of those macros can no longer
+   be trusted, and we need the workaround below, to have a single set
+   of macros we can trust.  (The .17 minor version is arbitrary.)  */
+#ifdef __MINGW32__
+#include <_mingw.h>
+#endif
+/* MinGW64 doesn't have this problem, and does not define
+   __MINGW_VERSION.  */
+#ifndef __MINGW64_VERSION_MAJOR
+# ifndef __MINGW_VERSION
+#  define __MINGW_VERSION 3.17
+#  undef __MINGW_MAJOR_VERSION
+#  define __MINGW_MAJOR_VERSION 3
+#  undef __MINGW_MINOR_VERSION
+#  define __MINGW_MINOR_VERSION 17
+#  undef __MINGW_PATCHLEVEL
+#  define __MINGW_PATCHLEVEL 0
+# endif
+#endif
+#if __MINGW_MAJOR_VERSION >= 4
+# define _USE_32BIT_TIME_T
+#endif
+
 /* #undef const */
 
 /* Number of chars of output in the buffer of a stdio stream. */