From bad866a29b0ec560c9bed31e2fe3610b6cf50ae3 Mon Sep 17 00:00:00 2001 From: Karsten Blees Date: Wed, 11 Sep 2013 01:21:53 +0200 Subject: MSVC: fix compile errors due to missing libintl.h Set NO_GETTEXT in config.mak.uname to get rid of libintl.h dependency. Signed-off-by: Karsten Blees Acked-by: Sebastian Schuberth Signed-off-by: Junio C Hamano --- config.mak.uname | 1 + 1 file changed, 1 insertion(+) diff --git a/config.mak.uname b/config.mak.uname index 7d615314f4..781dee4db7 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -339,6 +339,7 @@ ifeq ($(uname_S),Windows) OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo NO_REGEX = YesPlease NO_CURL = YesPlease + NO_GETTEXT = YesPlease NO_PYTHON = YesPlease BLK_SHA1 = YesPlease ETAGS_TARGET = ETAGS -- cgit v1.2.1 From 61542f7735a71ec0e28744a79828a8cc93aea9c6 Mon Sep 17 00:00:00 2001 From: Karsten Blees Date: Wed, 11 Sep 2013 01:22:34 +0200 Subject: MSVC: fix compile errors due to macro redefinitions Skip errno.h definitions if they are already defined. Signed-off-by: Karsten Blees Acked-by: Sebastian Schuberth Signed-off-by: Junio C Hamano --- compat/mingw.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compat/mingw.h b/compat/mingw.h index bd0a88bc1d..6b531e4013 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -32,7 +32,9 @@ typedef int socklen_t; #define WEXITSTATUS(x) ((x) & 0xff) #define WTERMSIG(x) SIGTERM +#ifndef EWOULDBLOCK #define EWOULDBLOCK EAGAIN +#endif #define SHUT_WR SD_SEND #define SIGHUP 1 @@ -46,8 +48,12 @@ typedef int socklen_t; #define F_SETFD 2 #define FD_CLOEXEC 0x1 +#ifndef EAFNOSUPPORT #define EAFNOSUPPORT WSAEAFNOSUPPORT +#endif +#ifndef ECONNABORTED #define ECONNABORTED WSAECONNABORTED +#endif struct passwd { char *pw_name; -- cgit v1.2.1 From a2374f58e86777258c11ed2d7855a28cd4219648 Mon Sep 17 00:00:00 2001 From: Karsten Blees Date: Wed, 11 Sep 2013 01:23:13 +0200 Subject: MSVC: fix stat definition hell In msvc.h, there's a couple of stat related functions defined diffently from mingw.h. When we remove these definitions, the only problem we get is "warning C4005: '_stati64' : macro redefinition" for this line in mingw.h: #define _stati64(x,y) mingw_stat(x,y) The reason is that as of MSVCR80.dll (distributed with MSVC 2005), the original _stati64 family of functions was renamed to _stat32i64, and the former function names became macros (pointing to the appropriate function based on the definition of _USE_32BIT_TIME_T). Defining _stati64 works on MinGW because MinGW by default compiles against the MSVCRT.DLL that is part of Windows (i.e. _stati64 is a function rather than a macro). Note: MinGW *can* compile for newer MSVC runtime versions, and MSVC apparently can also compile for the Windows MSVCRT.DLL via the DDK (see http://www.syndicateofideas.com/posts/fighting-the-msvcrt-dll-hell ). Remove the stat definitions from msvc.h, as they are not compiler related. In mingw.h, determine the runtime version in use from the definitions of _stati64 and _USE_32BIT_TIME_T, and define stat() accordingly. This also fixes that stat() in MSVC builds still resolves to mingw_lstat() instead of mingw_stat(). Signed-off-by: Karsten Blees Acked-by: Sebastian Schuberth Signed-off-by: Junio C Hamano --- compat/mingw.h | 15 +++++++++++---- compat/msvc.h | 15 --------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/compat/mingw.h b/compat/mingw.h index 6b531e4013..3c3a9d925e 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -264,19 +264,26 @@ static inline int getrlimit(int resource, struct rlimit *rlp) return 0; } -/* Use mingw_lstat() instead of lstat()/stat() and - * mingw_fstat() instead of fstat() on Windows. +/* + * Use mingw specific stat()/lstat()/fstat() implementations on Windows. */ #define off_t off64_t #define lseek _lseeki64 -#ifndef ALREADY_DECLARED_STAT_FUNCS + +/* use struct stat with 64 bit st_size */ #define stat _stati64 int mingw_lstat(const char *file_name, struct stat *buf); int mingw_stat(const char *file_name, struct stat *buf); int mingw_fstat(int fd, struct stat *buf); #define fstat mingw_fstat #define lstat mingw_lstat -#define _stati64(x,y) mingw_stat(x,y) + +#ifndef _stati64 +# define _stati64(x,y) mingw_stat(x,y) +#elif defined (_USE_32BIT_TIME_T) +# define _stat32i64(x,y) mingw_stat(x,y) +#else +# define _stat64(x,y) mingw_stat(x,y) #endif int mingw_utime(const char *file_name, const struct utimbuf *times); diff --git a/compat/msvc.h b/compat/msvc.h index 96b6d605da..580bb55bf4 100644 --- a/compat/msvc.h +++ b/compat/msvc.h @@ -24,21 +24,6 @@ static __inline int strcasecmp (const char *s1, const char *s2) #undef ERROR -/* Use mingw_lstat() instead of lstat()/stat() and mingw_fstat() instead - * of fstat(). We add the declaration of these functions here, suppressing - * the corresponding declarations in mingw.h, so that we can use the - * appropriate structure type (and function) names from the msvc headers. - */ -#define stat _stat64 -int mingw_lstat(const char *file_name, struct stat *buf); -int mingw_fstat(int fd, struct stat *buf); -#define fstat mingw_fstat -#define lstat mingw_lstat -#define _stat64(x,y) mingw_lstat(x,y) -#define ALREADY_DECLARED_STAT_FUNCS - #include "compat/mingw.h" -#undef ALREADY_DECLARED_STAT_FUNCS - #endif -- cgit v1.2.1 From fa93bb20d72edf9f7635c63d46101edb206d3d6f Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Wed, 11 Sep 2013 18:02:09 +0200 Subject: MinGW: Fix stat definitions to work with MinGW runtime version 4.0 For an overview of changes in mingwrt-4.0 see: http://sourceforge.net/p/mingw/mingw-org-wsl/ci/4.0.0/tree/NEWS Signed-off-by: Sebastian Schuberth Signed-off-by: Junio C Hamano --- compat/mingw.c | 1 - compat/mingw.h | 9 +++++++++ config.mak.uname | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index 22ee9ef1cf..fecb98bcff 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -491,7 +491,6 @@ int mingw_stat(const char *file_name, struct stat *buf) return do_stat_internal(1, file_name, buf); } -#undef fstat int mingw_fstat(int fd, struct stat *buf) { HANDLE fh = (HANDLE)_get_osfhandle(fd); diff --git a/compat/mingw.h b/compat/mingw.h index 3c3a9d925e..19d82de41a 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -271,11 +271,20 @@ static inline int getrlimit(int resource, struct rlimit *rlp) #define lseek _lseeki64 /* use struct stat with 64 bit st_size */ +#ifdef stat +#undef stat +#endif #define stat _stati64 int mingw_lstat(const char *file_name, struct stat *buf); int mingw_stat(const char *file_name, struct stat *buf); int mingw_fstat(int fd, struct stat *buf); +#ifdef fstat +#undef fstat +#endif #define fstat mingw_fstat +#ifdef lstat +#undef lstat +#endif #define lstat mingw_lstat #ifndef _stati64 diff --git a/config.mak.uname b/config.mak.uname index 781dee4db7..82d549e48b 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -500,7 +500,7 @@ ifneq (,$(findstring MINGW,$(uname_S))) NO_INET_NTOP = YesPlease NO_POSIX_GOODIES = UnfortunatelyYes DEFAULT_HELP_FORMAT = html - COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/win32 + COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32 COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\" COMPAT_OBJS += compat/mingw.o compat/winansi.o \ compat/win32/pthread.o compat/win32/syslog.o \ -- cgit v1.2.1 From 8453c1259a3b6fe89d67b6e783cc535b60f298c1 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Wed, 11 Sep 2013 18:06:31 +0200 Subject: Windows: do not redefine _WIN32_WINNT With MinGW runtime version 4.0 this interferes with the previous definition from sdkddkver.h. Signed-off-by: Sebastian Schuberth Signed-off-by: Junio C Hamano --- compat/nedmalloc/malloc.c.h | 2 ++ compat/poll/poll.c | 2 +- git-compat-util.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compat/nedmalloc/malloc.c.h b/compat/nedmalloc/malloc.c.h index ed4f1fa5af..f216a2a7d3 100644 --- a/compat/nedmalloc/malloc.c.h +++ b/compat/nedmalloc/malloc.c.h @@ -499,7 +499,9 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP #endif /* WIN32 */ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN +#ifndef _WIN32_WINNT #define _WIN32_WINNT 0x403 +#endif #include #define HAVE_MMAP 1 #define HAVE_MORECORE 0 diff --git a/compat/poll/poll.c b/compat/poll/poll.c index 44103103a4..31163f2ae7 100644 --- a/compat/poll/poll.c +++ b/compat/poll/poll.c @@ -39,7 +39,7 @@ #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # define WIN32_NATIVE -# if defined (_MSC_VER) +# if defined (_MSC_VER) && !defined(_WIN32_WINNT) # define _WIN32_WINNT 0x0502 # endif # include diff --git a/git-compat-util.h b/git-compat-util.h index 9549de6318..7776f126d3 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -86,7 +86,7 @@ #define _SGI_SOURCE 1 #if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */ -# if defined (_MSC_VER) +# if defined (_MSC_VER) && !defined(_WIN32_WINNT) # define _WIN32_WINNT 0x0502 # endif #define WIN32_LEAN_AND_MEAN /* stops windows.h including winsock.h */ -- cgit v1.2.1