From 41f2999180f5a58f2a4214d896359c1587c9024f Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Thu, 31 Jan 2013 18:28:35 +0000 Subject: [PATCH 1/5] msvc: Fix compilation errors caused by poll.h emulation Commit 0f77dea9 ("mingw: move poll out of sys-folder", 24-10-2011), along with other commits in the 'ef/mingw-upload-archive' branch (see commit 7406aa20), effectively reintroduced the same problem addressed by commit 56fb3ddc ("msvc: Fix compilation errors in compat/win32/sys/poll.c", 04-12-2010). In order to fix the compilation errors, we use the same solution adopted in that earlier commit. In particular, we set _WIN32_WINNT to 0x0502 (which would target Windows Server 2003) prior to including the winsock2.h header file. Also, we delete the compat/vcbuild/include/sys/poll.h header file, since it is now redundant and it's presence may cause some confusion. Signed-off-by: Ramsay Jones Tested-by: Johannes Sixt Signed-off-by: Junio C Hamano --- compat/vcbuild/include/sys/poll.h | 1 - git-compat-util.h | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 compat/vcbuild/include/sys/poll.h diff --git a/compat/vcbuild/include/sys/poll.h b/compat/vcbuild/include/sys/poll.h deleted file mode 100644 index 0d8552a2c..000000000 --- a/compat/vcbuild/include/sys/poll.h +++ /dev/null @@ -1 +0,0 @@ -/* Intentionally empty file to support building git with MSVC */ diff --git a/git-compat-util.h b/git-compat-util.h index b7eaaa99a..490afb6af 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -86,6 +86,9 @@ #define _SGI_SOURCE 1 #ifdef WIN32 /* Both MinGW and MSVC */ +# if defined (_MSC_VER) +# define _WIN32_WINNT 0x0502 +# endif #define WIN32_LEAN_AND_MEAN /* stops windows.h including winsock.h */ #include #include From 4ab7527458a908b51891cbaa6bc0da9b711ebd19 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Thu, 31 Jan 2013 18:30:14 +0000 Subject: [PATCH 2/5] msvc: git-daemon: Fix linker "unresolved external" errors In particular, while linking git-daemon.exe, the linker complains that the external symbols _inet_pton and _inet_ntop are unresolved. Commit a666b472 ("daemon: opt-out on features that require posix", 04-11-2010) addressed this problem for MinGW by configuring the use of the internal 'compat' versions of these function. Although the MSVC header contains the prototypes for the inet_pton and inet_ntop functions, they are only visible for Windows API versions from 0x0600 (Windows Vista) or later. (In addition, on Windows XP, ws2_32.dll does not export these symbols). In order to fix the linker errors, we also configure the MSVC build to use the internal compat versions of these functions by setting the NO_INET_{PTON,NTOP} build variables. Signed-off-by: Ramsay Jones Tested-by: Johannes Sixt Signed-off-by: Junio C Hamano --- config.mak.uname | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.mak.uname b/config.mak.uname index 8743a6d0a..911c13ec7 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -344,6 +344,8 @@ ifeq ($(uname_S),Windows) NO_CURL = YesPlease NO_PYTHON = YesPlease BLK_SHA1 = YesPlease + NO_INET_PTON = YesPlease + NO_INET_NTOP = YesPlease NO_POSIX_GOODIES = UnfortunatelyYes NATIVE_CRLF = YesPlease DEFAULT_HELP_FORMAT = html From 93e38ed0c5a632d7b785357a309ac83e4df066fa Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Thu, 31 Jan 2013 18:31:30 +0000 Subject: [PATCH 3/5] msvc: Fix build by adding missing symbol defines In particular, remote-testsvn.c fails to compile with two undeclared identifier errors relating to the 'UINT32_MAX' and 'STDIN_FILENO' symbols. In order to fix the compilation errors, we add appropriate definitions for the UINT32_MAX and STDIN_FILENO constants to an msvc compat header file. Signed-off-by: Ramsay Jones Tested-by: Johannes Sixt Signed-off-by: Junio C Hamano --- compat/vcbuild/include/unistd.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compat/vcbuild/include/unistd.h b/compat/vcbuild/include/unistd.h index b14fcf94d..c65c2cd56 100644 --- a/compat/vcbuild/include/unistd.h +++ b/compat/vcbuild/include/unistd.h @@ -49,6 +49,9 @@ typedef int64_t off64_t; #define INTMAX_MAX _I64_MAX #define UINTMAX_MAX _UI64_MAX +#define UINT32_MAX 0xffffffff /* 4294967295U */ + +#define STDIN_FILENO 0 #define STDOUT_FILENO 1 #define STDERR_FILENO 2 From d0f9dbb9e29b8dc289ae3b8028586a99fdb0d194 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Thu, 31 Jan 2013 18:32:55 +0000 Subject: [PATCH 4/5] msvc: test-svn-fe: Fix linker "unresolved external" error In particular, while linking test-svn-fe.exe, the linker complains that the external symbol _strtoull is unresolved. A call to this function was added in commit ddcc8c5b ("vcs-svn: skeleton of an svn delta parser", 25-12-2010). The NO_STRTOULL build variable attempts to provide support to old systems which can't even declare 'unsigned long long' variables, let alone provide the strtoll() or strtoull() functions. Setting this build variable does not provide an implementation of these functions. Rather, it simply allows the compat implementations of strto{i,u}max() to use strtol() and strtoul() instead. In order to fix the linker error on systems with NO_STRTOULL set, currently MSVC and OSF1, we can substitute a call to strtoumax(). However, we can easily provide support for the strtoull() and strtoll() functions on MSVC, since they are essentially already available as _strtoui64() and _strtoi64(). This allows us to remove NO_STRTOULL for MSVC. Signed-off-by: Ramsay Jones Tested-by: Johannes Sixt Signed-off-by: Junio C Hamano --- compat/msvc.h | 2 ++ config.mak.uname | 1 - test-svn-fe.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compat/msvc.h b/compat/msvc.h index aa4b56315..96b6d605d 100644 --- a/compat/msvc.h +++ b/compat/msvc.h @@ -12,6 +12,8 @@ #define __attribute__(x) #define strncasecmp _strnicmp #define ftruncate _chsize +#define strtoull _strtoui64 +#define strtoll _strtoi64 static __inline int strcasecmp (const char *s1, const char *s2) { diff --git a/config.mak.uname b/config.mak.uname index 911c13ec7..43c79e5bc 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -327,7 +327,6 @@ ifeq ($(uname_S),Windows) # NEEDS_LIBICONV = YesPlease NO_ICONV = YesPlease NO_STRTOUMAX = YesPlease - NO_STRTOULL = YesPlease NO_MKDTEMP = YesPlease NO_MKSTEMPS = YesPlease SNPRINTF_RETURNS_BOGUS = YesPlease diff --git a/test-svn-fe.c b/test-svn-fe.c index 0f2d9a4a3..120ec96b0 100644 --- a/test-svn-fe.c +++ b/test-svn-fe.c @@ -24,7 +24,7 @@ static int apply_delta(int argc, char *argv[]) die_errno("cannot open preimage"); if (buffer_init(&delta, argv[3])) die_errno("cannot open delta"); - if (svndiff0_apply(&delta, (off_t) strtoull(argv[4], NULL, 0), + if (svndiff0_apply(&delta, (off_t) strtoumax(argv[4], NULL, 0), &preimage_view, stdout)) return 1; if (buffer_deinit(&preimage)) From e0492c5be123ca264a5477e3481a8a765fe9ae99 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Thu, 31 Jan 2013 18:33:57 +0000 Subject: [PATCH 5/5] msvc: avoid collisions between "tags" and "TAGS" Commit 2f769195 ("MinGW: avoid collisions between "tags" and "TAGS", 28-09-2010) enabled MinGW to use an ETAGS file in order to avoid filename collisions on (Windows) case insensitive filesystems. In addition, this prevents 'make' from issuing several warning messages. When using the Makefile to perform an MSVC build, which is usually executed using MinGW tools, we can also benefit from this capability. In order to reap the above benefits, we set the ETAGS_TARGET build variable to ETAGS in the MSVC config block. Signed-off-by: Ramsay Jones Tested-by: Johannes Sixt 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 43c79e5bc..bb8246b63 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -343,6 +343,7 @@ ifeq ($(uname_S),Windows) NO_CURL = YesPlease NO_PYTHON = YesPlease BLK_SHA1 = YesPlease + ETAGS_TARGET = ETAGS NO_INET_PTON = YesPlease NO_INET_NTOP = YesPlease NO_POSIX_GOODIES = UnfortunatelyYes