Skip to content

Commit d0c7890

Browse files
committed
Merge branch 'kb/msvc-compile'
* kb/msvc-compile: Windows: do not redefine _WIN32_WINNT MinGW: Fix stat definitions to work with MinGW runtime version 4.0 MSVC: fix stat definition hell MSVC: fix compile errors due to macro redefinitions MSVC: fix compile errors due to missing libintl.h
2 parents 87bcf14 + 8453c12 commit d0c7890

File tree

7 files changed

+32
-23
lines changed

7 files changed

+32
-23
lines changed

compat/mingw.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,6 @@ int mingw_stat(const char *file_name, struct stat *buf)
491491
return do_stat_internal(1, file_name, buf);
492492
}
493493

494-
#undef fstat
495494
int mingw_fstat(int fd, struct stat *buf)
496495
{
497496
HANDLE fh = (HANDLE)_get_osfhandle(fd);

compat/mingw.h

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ typedef int socklen_t;
3232
#define WEXITSTATUS(x) ((x) & 0xff)
3333
#define WTERMSIG(x) SIGTERM
3434

35+
#ifndef EWOULDBLOCK
3536
#define EWOULDBLOCK EAGAIN
37+
#endif
3638
#define SHUT_WR SD_SEND
3739

3840
#define SIGHUP 1
@@ -46,8 +48,12 @@ typedef int socklen_t;
4648
#define F_SETFD 2
4749
#define FD_CLOEXEC 0x1
4850

51+
#ifndef EAFNOSUPPORT
4952
#define EAFNOSUPPORT WSAEAFNOSUPPORT
53+
#endif
54+
#ifndef ECONNABORTED
5055
#define ECONNABORTED WSAECONNABORTED
56+
#endif
5157

5258
struct passwd {
5359
char *pw_name;
@@ -258,19 +264,35 @@ static inline int getrlimit(int resource, struct rlimit *rlp)
258264
return 0;
259265
}
260266

261-
/* Use mingw_lstat() instead of lstat()/stat() and
262-
* mingw_fstat() instead of fstat() on Windows.
267+
/*
268+
* Use mingw specific stat()/lstat()/fstat() implementations on Windows.
263269
*/
264270
#define off_t off64_t
265271
#define lseek _lseeki64
266-
#ifndef ALREADY_DECLARED_STAT_FUNCS
272+
273+
/* use struct stat with 64 bit st_size */
274+
#ifdef stat
275+
#undef stat
276+
#endif
267277
#define stat _stati64
268278
int mingw_lstat(const char *file_name, struct stat *buf);
269279
int mingw_stat(const char *file_name, struct stat *buf);
270280
int mingw_fstat(int fd, struct stat *buf);
281+
#ifdef fstat
282+
#undef fstat
283+
#endif
271284
#define fstat mingw_fstat
285+
#ifdef lstat
286+
#undef lstat
287+
#endif
272288
#define lstat mingw_lstat
273-
#define _stati64(x,y) mingw_stat(x,y)
289+
290+
#ifndef _stati64
291+
# define _stati64(x,y) mingw_stat(x,y)
292+
#elif defined (_USE_32BIT_TIME_T)
293+
# define _stat32i64(x,y) mingw_stat(x,y)
294+
#else
295+
# define _stat64(x,y) mingw_stat(x,y)
274296
#endif
275297

276298
int mingw_utime(const char *file_name, const struct utimbuf *times);

compat/msvc.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,6 @@ static __inline int strcasecmp (const char *s1, const char *s2)
2424

2525
#undef ERROR
2626

27-
/* Use mingw_lstat() instead of lstat()/stat() and mingw_fstat() instead
28-
* of fstat(). We add the declaration of these functions here, suppressing
29-
* the corresponding declarations in mingw.h, so that we can use the
30-
* appropriate structure type (and function) names from the msvc headers.
31-
*/
32-
#define stat _stat64
33-
int mingw_lstat(const char *file_name, struct stat *buf);
34-
int mingw_fstat(int fd, struct stat *buf);
35-
#define fstat mingw_fstat
36-
#define lstat mingw_lstat
37-
#define _stat64(x,y) mingw_lstat(x,y)
38-
#define ALREADY_DECLARED_STAT_FUNCS
39-
4027
#include "compat/mingw.h"
4128

42-
#undef ALREADY_DECLARED_STAT_FUNCS
43-
4429
#endif

compat/nedmalloc/malloc.c.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,9 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP
499499
#endif /* WIN32 */
500500
#ifdef WIN32
501501
#define WIN32_LEAN_AND_MEAN
502+
#ifndef _WIN32_WINNT
502503
#define _WIN32_WINNT 0x403
504+
#endif
503505
#include <windows.h>
504506
#define HAVE_MMAP 1
505507
#define HAVE_MORECORE 0

compat/poll/poll.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
4141
# define WIN32_NATIVE
42-
# if defined (_MSC_VER)
42+
# if defined (_MSC_VER) && !defined(_WIN32_WINNT)
4343
# define _WIN32_WINNT 0x0502
4444
# endif
4545
# include <winsock2.h>

config.mak.uname

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ ifeq ($(uname_S),Windows)
339339
OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
340340
NO_REGEX = YesPlease
341341
NO_CURL = YesPlease
342+
NO_GETTEXT = YesPlease
342343
NO_PYTHON = YesPlease
343344
BLK_SHA1 = YesPlease
344345
ETAGS_TARGET = ETAGS
@@ -499,7 +500,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
499500
NO_INET_NTOP = YesPlease
500501
NO_POSIX_GOODIES = UnfortunatelyYes
501502
DEFAULT_HELP_FORMAT = html
502-
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/win32
503+
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
503504
COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
504505
COMPAT_OBJS += compat/mingw.o compat/winansi.o \
505506
compat/win32/pthread.o compat/win32/syslog.o \

git-compat-util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
#define _SGI_SOURCE 1
8787

8888
#if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */
89-
# if defined (_MSC_VER)
89+
# if defined (_MSC_VER) && !defined(_WIN32_WINNT)
9090
# define _WIN32_WINNT 0x0502
9191
# endif
9292
#define WIN32_LEAN_AND_MEAN /* stops windows.h including winsock.h */

0 commit comments

Comments
 (0)