From 56fb3ddc89ab94c8b09d178a848cb553b4acf777 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Sat, 4 Dec 2010 18:54:28 +0000 Subject: [PATCH 1/4] msvc: Fix compilation errors in compat/win32/sys/poll.c The msvc winsock2.h header file conditionally defines or declares poll() related symbols which cause many macro redefinition errors, a struct type redefinition error and syntax errors. These symbols are defined in support of the WSAPoll() API, new in Windows Vista, when the symbol _WIN32_WINNT is defined and _WIN32_WINNT >= 0x0600. In order to avoid the compilation errors, we set _WIN32_WINNT to 0x0502 (which would target Windows Server 2003) prior to including the winsock2.h header file. Signed-off-by: Ramsay Jones Acked-by: Erik Faye-Lund Signed-off-by: Junio C Hamano --- compat/win32/sys/poll.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compat/win32/sys/poll.c b/compat/win32/sys/poll.c index 7e74ebe59a..708a6c9bec 100644 --- a/compat/win32/sys/poll.c +++ b/compat/win32/sys/poll.c @@ -34,6 +34,9 @@ #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # define WIN32_NATIVE +# if defined (_MSC_VER) +# define _WIN32_WINNT 0x0502 +# endif # include # include # include From b7037b6a1f463ffe33390f26840d6cc1600dbb18 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Sat, 4 Dec 2010 18:55:51 +0000 Subject: [PATCH 2/4] msvc: git-daemon.exe: Fix linker "unresolved externals" error The msvc linker complains about external symbols referenced by the new poll() emulation code. In particular, it complains about the DispatchMessage(), PeekMessage(), TranslateMessage() and MsgWaitForMultipleObjects() functions. In order to satisfy the external references, we link against the user32.lib library. Signed-off-by: Ramsay Jones Acked-by: Erik Faye-Lund Signed-off-by: Junio C Hamano --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 53986b1ecb..9d86ea2d3a 100644 --- a/Makefile +++ b/Makefile @@ -1087,7 +1087,7 @@ ifeq ($(uname_S),Windows) COMPAT_OBJS = compat/msvc.o compat/fnmatch/fnmatch.o compat/winansi.o compat/win32/pthread.o compat/win32/syslog.o compat/win32/sys/poll.o COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/fnmatch -Icompat/regex -Icompat/fnmatch -Icompat/win32 -DSTRIP_EXTENSION=\".exe\" BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE -NODEFAULTLIB:MSVCRT.lib - EXTLIBS = advapi32.lib shell32.lib wininet.lib ws2_32.lib + EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib PTHREAD_LIBS = lib = ifndef DEBUG From 1a3b5a3e5cfc00ca36bdbc07b3ffebcdfc9dd989 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Sat, 4 Dec 2010 18:57:30 +0000 Subject: [PATCH 3/4] msvc: Fix build by adding missing INTMAX_MAX define Commit c03c831 (do not depend on signed integer overflow, 05-10-2010) provokes an msvc build failure. The cause of the failure is a missing definition of the INTMAX_MAX constant, used in the new maximum_signed_value_of_type(a) macro, which would normally be defined in the C99 header file. In order the fix the compilation error, we add an appropriate definition of the INTMAX_MAX constant, along with INTMAX_MIN and UINTMAX_MAX, to an msvc compat header file. Signed-off-by: Ramsay Jones Acked-by: Erik Faye-Lund Signed-off-by: Junio C Hamano --- compat/vcbuild/include/unistd.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compat/vcbuild/include/unistd.h b/compat/vcbuild/include/unistd.h index 2a4f276869..b14fcf94da 100644 --- a/compat/vcbuild/include/unistd.h +++ b/compat/vcbuild/include/unistd.h @@ -45,6 +45,10 @@ typedef unsigned long long uintmax_t; typedef int64_t off64_t; +#define INTMAX_MIN _I64_MIN +#define INTMAX_MAX _I64_MAX +#define UINTMAX_MAX _UI64_MAX + #define STDOUT_FILENO 1 #define STDERR_FILENO 2 From 93d85f57be00859f8adecd474da30a7279cd4ec2 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Sat, 4 Dec 2010 19:00:51 +0000 Subject: [PATCH 4/4] msvc: Fix macro redefinition warnings Commit 4091bfc (MinGW: Add missing file mode bit defines, 28-12-2009) causes the msvc build to issue many additional (currently 1008) macro redefinition warnings. The warnings relate to the S_IRUSR, S_IWUSR, S_IXUSR and S_IRWXU macros. In order to fix the warnings, we simply remove the offending macro definitions which, for both msvc and MinGW, are not required. Signed-off-by: Ramsay Jones Acked-by: Sebastian Schuberth Acked-by: Johannes Sixt Signed-off-by: Junio C Hamano --- compat/mingw.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/compat/mingw.h b/compat/mingw.h index 99a746703f..da316dc48e 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -14,12 +14,6 @@ typedef int socklen_t; #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK) #define S_ISSOCK(x) 0 -#ifndef _STAT_H_ -#define S_IRUSR 0 -#define S_IWUSR 0 -#define S_IXUSR 0 -#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) -#endif #define S_IRGRP 0 #define S_IWGRP 0 #define S_IXGRP 0