{"thread":{"id":"34903","subject":"[PATCH 0/3] Fix MSVC compile errors and cleanup stat definitions","startedAt":"2013-09-10T23:20:57Z","lastAt":"2013-09-11T18:11:44Z","messageCount":9,"participants":["Karsten Blees","Eric Sunshine","Sebastian Schuberth","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"227389","messageId":"522FA959.80108@gmail.com","threadId":"34903","inReplyTo":null,"subject":"[PATCH 0/3] Fix MSVC compile errors and cleanup stat definitions","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2013-09-10T23:20:57Z","receivedAt":"2013-09-10T23:20:57Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"A few minor fixes for the MSVC build.\n\nAlso here: https://github.com/kblees/git/tree/kb/fix-msvc-stat-definitions\n\nKarsten Blees (3):\n  MSVC: fix compile errors due to missing libintl.h\n  MSVC: fix compile errors due to macro redefinitions\n  MSVC: fix stat definition hell\n\n compat/mingw.h   | 21 +++++++++++++++++----\n compat/msvc.h    | 15 ---------------\n config.mak.uname |  1 +\n 3 files changed, 18 insertions(+), 19 deletions(-)\n\n-- \n1.8.4.8243.gbcbdefd\n"},{"id":"227390","messageId":"522FA991.60807@gmail.com","threadId":"34903","inReplyTo":"522FA959.80108@gmail.com","subject":"[PATCH 1/3] MSVC: fix compile errors due to missing libintl.h","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2013-09-10T23:21:53Z","receivedAt":"2013-09-10T23:21:53Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Set NO_GETTEXT in config.mak.uname to get rid of libintl.h dependency.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\n---\n config.mak.uname | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex b27f51d..64b7f49 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -340,6 +340,7 @@ ifeq ($(uname_S),Windows)\n \tOBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo\n \tNO_REGEX = YesPlease\n \tNO_CURL = YesPlease\n+\tNO_GETTEXT = YesPlease\n \tNO_PYTHON = YesPlease\n \tBLK_SHA1 = YesPlease\n \tETAGS_TARGET = ETAGS\n-- \n1.8.4.8243.gbcbdefd\n"},{"id":"227391","messageId":"522FA9BA.6020303@gmail.com","threadId":"34903","inReplyTo":"522FA959.80108@gmail.com","subject":"[PATCH 2/3] MSVC: fix compile errors due to macro redefinitions","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2013-09-10T23:22:34Z","receivedAt":"2013-09-10T23:22:34Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Skip errno.h definitions if they are already defined.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\n---\n compat/mingw.h | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex bd0a88b..6b531e4 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -32,7 +32,9 @@ typedef int socklen_t;\n #define WEXITSTATUS(x) ((x) & 0xff)\n #define WTERMSIG(x) SIGTERM\n \n+#ifndef EWOULDBLOCK\n #define EWOULDBLOCK EAGAIN\n+#endif\n #define SHUT_WR SD_SEND\n \n #define SIGHUP 1\n@@ -46,8 +48,12 @@ typedef int socklen_t;\n #define F_SETFD 2\n #define FD_CLOEXEC 0x1\n \n+#ifndef EAFNOSUPPORT\n #define EAFNOSUPPORT WSAEAFNOSUPPORT\n+#endif\n+#ifndef ECONNABORTED\n #define ECONNABORTED WSAECONNABORTED\n+#endif\n \n struct passwd {\n \tchar *pw_name;\n-- \n1.8.4.8243.gbcbdefd\n"},{"id":"227392","messageId":"522FA9E1.7010705@gmail.com","threadId":"34903","inReplyTo":"522FA959.80108@gmail.com","subject":"[PATCH 3/3] MSVC: fix stat definition hell","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2013-09-10T23:23:13Z","receivedAt":"2013-09-10T23:23:13Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"In msvc.h, there's a couple of stat related functions defined diffently\nfrom mingw.h. When we remove these definitions, the only problem we get is\n\"warning C4005: '_stati64' : macro redefinition\" for this line in mingw.h:\n\n#define _stati64(x,y) mingw_stat(x,y)\n\nThe reason is that as of MSVCR80.dll (distributed with MSVC 2005), the\noriginal _stati64 family of functions was renamed to _stat32i64, and the\nformer function names became macros (pointing to the appropriate function\nbased on the definition of _USE_32BIT_TIME_T).\n\nDefining _stati64 works on MinGW because MinGW by default compiles against\nthe MSVCRT.DLL that is part of Windows (i.e. _stati64 is a function rather\nthan a macro).\n\nNote: MinGW *can* compile for newer MSVC runtime versions, and MSVC\napparently can also compile for the Windows MSVCRT.DLL via the DDK (see\nhttp://www.syndicateofideas.com/posts/fighting-the-msvcrt-dll-hell ).\n\nRemove the stat definitions from msvc.h, as they are not compiler related.\n\nIn mingw.h, determine the runtime version in use from the definitions of\n_stati64 and _USE_32BIT_TIME_T, and define stat() accordingly.\n\nThis also fixes that stat() in MSVC builds still resolves to mingw_lstat()\ninstead of mingw_stat().\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\n---\n compat/mingw.h | 15 +++++++++++----\n compat/msvc.h  | 15 ---------------\n 2 files changed, 11 insertions(+), 19 deletions(-)\n\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 6b531e4..3c3a9d9 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -264,19 +264,26 @@ static inline int getrlimit(int resource, struct rlimit *rlp)\n \treturn 0;\n }\n \n-/* Use mingw_lstat() instead of lstat()/stat() and\n- * mingw_fstat() instead of fstat() on Windows.\n+/*\n+ * Use mingw specific stat()/lstat()/fstat() implementations on Windows.\n  */\n #define off_t off64_t\n #define lseek _lseeki64\n-#ifndef ALREADY_DECLARED_STAT_FUNCS\n+\n+/* use struct stat with 64 bit st_size */\n #define stat _stati64\n int mingw_lstat(const char *file_name, struct stat *buf);\n int mingw_stat(const char *file_name, struct stat *buf);\n int mingw_fstat(int fd, struct stat *buf);\n #define fstat mingw_fstat\n #define lstat mingw_lstat\n-#define _stati64(x,y) mingw_stat(x,y)\n+\n+#ifndef _stati64\n+# define _stati64(x,y) mingw_stat(x,y)\n+#elif defined (_USE_32BIT_TIME_T)\n+# define _stat32i64(x,y) mingw_stat(x,y)\n+#else\n+# define _stat64(x,y) mingw_stat(x,y)\n #endif\n \n int mingw_utime(const char *file_name, const struct utimbuf *times);\ndiff --git a/compat/msvc.h b/compat/msvc.h\nindex 96b6d60..580bb55 100644\n--- a/compat/msvc.h\n+++ b/compat/msvc.h\n@@ -24,21 +24,6 @@ static __inline int strcasecmp (const char *s1, const char *s2)\n \n #undef ERROR\n \n-/* Use mingw_lstat() instead of lstat()/stat() and mingw_fstat() instead\n- * of fstat(). We add the declaration of these functions here, suppressing\n- * the corresponding declarations in mingw.h, so that we can use the\n- * appropriate structure type (and function) names from the msvc headers.\n- */\n-#define stat _stat64\n-int mingw_lstat(const char *file_name, struct stat *buf);\n-int mingw_fstat(int fd, struct stat *buf);\n-#define fstat mingw_fstat\n-#define lstat mingw_lstat\n-#define _stat64(x,y) mingw_lstat(x,y)\n-#define ALREADY_DECLARED_STAT_FUNCS\n-\n #include \"compat/mingw.h\"\n \n-#undef ALREADY_DECLARED_STAT_FUNCS\n-\n #endif\n-- \n1.8.4.8243.gbcbdefd\n"},{"id":"227400","messageId":"CAPig+cTU6iuv84QH+Y+u4UJ9b-aHQo7zzTv6umnG1tZ9v7+nvw@mail.gmail.com","threadId":"34903","inReplyTo":"522FA9E1.7010705@gmail.com","subject":"Re: [PATCH 3/3] MSVC: fix stat definition hell","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-09-11T00:35:41Z","receivedAt":"2013-09-11T00:35:41Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Sep 10, 2013 at 7:23 PM, Karsten Blees <karsten.blees@gmail.com> wrote:\n> In msvc.h, there's a couple of stat related functions defined diffently\n\ns/diffently/differently/\n\n> from mingw.h. When we remove these definitions, the only problem we get is\n> \"warning C4005: '_stati64' : macro redefinition\" for this line in mingw.h:\n>\n> #define _stati64(x,y) mingw_stat(x,y)\n>\n> The reason is that as of MSVCR80.dll (distributed with MSVC 2005), the\n> original _stati64 family of functions was renamed to _stat32i64, and the\n> former function names became macros (pointing to the appropriate function\n> based on the definition of _USE_32BIT_TIME_T).\n>\n> Defining _stati64 works on MinGW because MinGW by default compiles against\n> the MSVCRT.DLL that is part of Windows (i.e. _stati64 is a function rather\n> than a macro).\n>\n> Note: MinGW *can* compile for newer MSVC runtime versions, and MSVC\n> apparently can also compile for the Windows MSVCRT.DLL via the DDK (see\n> http://www.syndicateofideas.com/posts/fighting-the-msvcrt-dll-hell ).\n>\n> Remove the stat definitions from msvc.h, as they are not compiler related.\n>\n> In mingw.h, determine the runtime version in use from the definitions of\n> _stati64 and _USE_32BIT_TIME_T, and define stat() accordingly.\n>\n> This also fixes that stat() in MSVC builds still resolves to mingw_lstat()\n> instead of mingw_stat().\n>\n> Signed-off-by: Karsten Blees <blees@dcon.de>\n"},{"id":"227454","messageId":"52309401.7000508@gmail.com","threadId":"34903","inReplyTo":"522FA9E1.7010705@gmail.com","subject":"Re: [PATCH 3/3] MSVC: fix stat definition hell","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2013-09-11T16:02:09Z","receivedAt":"2013-09-11T16:02:09Z","isPatch":true,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On 11.09.2013 01:23, Karsten Blees wrote:\n\n> In msvc.h, there's a couple of stat related functions defined diffently\n> from mingw.h. When we remove these definitions, the only problem we get is\n> \"warning C4005: '_stati64' : macro redefinition\" for this line in mingw.h:\n> \n> #define _stati64(x,y) mingw_stat(x,y)\n\nI have a similar patch at [1] to fix similar compilation issues with MinGW runtime version 4.0, which was recently released. I like your patch better, so I've rebased mine on top of yours:\n\n[PATCH] MinGW: Fix stat definitions to work with MinGW runtime version 4.0\n\nFor an overview of changes in mingwrt-4.0 see:\n\n    http://sourceforge.net/p/mingw/mingw-org-wsl/ci/4.0.0/tree/NEWS\n\nSigned-off-by: Sebastian Schuberth <sschuberth@gmail.com>\n---\n compat/mingw.c   | 1 -\n compat/mingw.h   | 9 +++++++++\n config.mak.uname | 2 +-\n 3 files changed, 10 insertions(+), 2 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 96d9ac4..29c051f 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -616,7 +616,6 @@ int mingw_stat(const char *file_name, struct stat *buf)\n \treturn do_stat_internal(1, file_name, buf);\n }\n \n-#undef fstat\n int mingw_fstat(int fd, struct stat *buf)\n {\n \tHANDLE fh = (HANDLE)_get_osfhandle(fd);\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex b521900..0d2faac 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -278,11 +278,20 @@ static inline int getrlimit(int resource, struct rlimit *rlp)\n #define lseek _lseeki64\n \n /* use struct stat with 64 bit st_size */\n+#ifdef stat\n+#undef stat\n+#endif\n #define stat _stati64\n int mingw_lstat(const char *file_name, struct stat *buf);\n int mingw_stat(const char *file_name, struct stat *buf);\n int mingw_fstat(int fd, struct stat *buf);\n+#ifdef fstat\n+#undef fstat\n+#endif\n #define fstat mingw_fstat\n+#ifdef lstat\n+#undef lstat\n+#endif\n #define lstat mingw_lstat\n \n #ifndef _stati64\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 9249ee3..983ecc1 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -499,7 +499,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tNO_POSIX_GOODIES = UnfortunatelyYes\n \tDEFAULT_HELP_FORMAT = html\n \tNO_D_INO_IN_DIRENT = YesPlease\n-\tCOMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/win32\n+\tCOMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32\n \tCOMPAT_CFLAGS += -DSTRIP_EXTENSION=\\\".exe\\\"\n \tCOMPAT_OBJS += compat/mingw.o compat/winansi.o \\\n \t\tcompat/win32/pthread.o compat/win32/syslog.o \\\n-- \n1.8.3.mingw.1.2.g56240b5.dirty\n\nI don't think we should squash this patch to yours, however, because yours addressed MSVC compilation issues, and mine address MinGW compilation issues. But my patch could go to your branch.\n\n[1] https://github.com/sschuberth/git/commit/841cdf60faa134eef031a7cf6d6692473a18cb65\n\n-- \nSebastian Schuberth\n"},{"id":"227457","messageId":"xmqqa9jjuypf.fsf@gitster.dls.corp.google.com","threadId":"34903","inReplyTo":"522FA959.80108@gmail.com","subject":"Re: [PATCH 0/3] Fix MSVC compile errors and cleanup stat definitions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-09-11T16:09:48Z","receivedAt":"2013-09-11T16:09:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karsten Blees <karsten.blees@gmail.com> writes:\n\n> A few minor fixes for the MSVC build.\n>\n> Also here: https://github.com/kblees/git/tree/kb/fix-msvc-stat-definitions\n>\n> Karsten Blees (3):\n>   MSVC: fix compile errors due to missing libintl.h\n>   MSVC: fix compile errors due to macro redefinitions\n>   MSVC: fix stat definition hell\n>\n>  compat/mingw.h   | 21 +++++++++++++++++----\n>  compat/msvc.h    | 15 ---------------\n>  config.mak.uname |  1 +\n>  3 files changed, 18 insertions(+), 19 deletions(-)\n\nI won't be a good person to review, suggest improvements on, and/or\njudge these patches.  I'm Cc'ing regulars who work on mingw port for\ntheir help and Ack.\n\nThanks.\n"},{"id":"227460","messageId":"CAHGBnuOFYS-9+h0H3VD5X-EbZKX9nENaZfAZbLUm9zwDtr-3SA@mail.gmail.com","threadId":"34903","inReplyTo":"xmqqa9jjuypf.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 0/3] Fix MSVC compile errors and cleanup stat definitions","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2013-09-11T16:16:05Z","receivedAt":"2013-09-11T16:16:05Z","isPatch":true,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On Wed, Sep 11, 2013 at 6:09 PM, Junio C Hamano <gitster@pobox.com> wrote:\n\n> Karsten Blees <karsten.blees@gmail.com> writes:\n>\n>> A few minor fixes for the MSVC build.\n>>\n>> Also here: https://github.com/kblees/git/tree/kb/fix-msvc-stat-definitions\n>>\n>> Karsten Blees (3):\n>>   MSVC: fix compile errors due to missing libintl.h\n>>   MSVC: fix compile errors due to macro redefinitions\n>>   MSVC: fix stat definition hell\n>>\n>>  compat/mingw.h   | 21 +++++++++++++++++----\n>>  compat/msvc.h    | 15 ---------------\n>>  config.mak.uname |  1 +\n>>  3 files changed, 18 insertions(+), 19 deletions(-)\n>\n> I won't be a good person to review, suggest improvements on, and/or\n> judge these patches.  I'm Cc'ing regulars who work on mingw port for\n> their help and Ack.\n\nAcked-by: Sebastian Schuberth <sschuberth@gmail.com>\n\n-- \nSebastian Schuberth\n"},{"id":"227473","messageId":"xmqqd2oftehr.fsf@gitster.dls.corp.google.com","threadId":"34903","inReplyTo":"CAHGBnuOFYS-9+h0H3VD5X-EbZKX9nENaZfAZbLUm9zwDtr-3SA@mail.gmail.com","subject":"Re: [PATCH 0/3] Fix MSVC compile errors and cleanup stat definitions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-09-11T18:11:44Z","receivedAt":"2013-09-11T18:11:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sebastian Schuberth <sschuberth@gmail.com> writes:\n\n> On Wed, Sep 11, 2013 at 6:09 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>\n>> Karsten Blees <karsten.blees@gmail.com> writes:\n>>\n>>> A few minor fixes for the MSVC build.\n>>>\n>>> Also here: https://github.com/kblees/git/tree/kb/fix-msvc-stat-definitions\n>>>\n>>> Karsten Blees (3):\n>>>   MSVC: fix compile errors due to missing libintl.h\n>>>   MSVC: fix compile errors due to macro redefinitions\n>>>   MSVC: fix stat definition hell\n>>>\n>>>  compat/mingw.h   | 21 +++++++++++++++++----\n>>>  compat/msvc.h    | 15 ---------------\n>>>  config.mak.uname |  1 +\n>>>  3 files changed, 18 insertions(+), 19 deletions(-)\n>>\n>> I won't be a good person to review, suggest improvements on, and/or\n>> judge these patches.  I'm Cc'ing regulars who work on mingw port for\n>> their help and Ack.\n>\n> Acked-by: Sebastian Schuberth <sschuberth@gmail.com>\n\nThanks; will queue these three and your follow-up on top.\n"}]}