Make the MinGW32 build compatible with MinGW runtime 4.x.

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.
This commit is contained in:
Eli Zaretskii 2013-10-12 16:11:14 +03:00
parent 18f19af2a7
commit 2f4586ad04
3 changed files with 59 additions and 0 deletions

View 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).

View 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 */
};

View 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. */