All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Borzenkov <snaury@gmail.com>
To: Marius Storm-Olsen <mstormo@gmail.com>
Cc: Johannes.Schindelin@gmx.de, msysgit@googlegroups.com,
	git@vger.kernel.org, lznuaa@gmail.com, raa.lkml@gmail.com
Subject: Re: [PATCH 04/14] Set _O_BINARY as default fmode for both MinGW and  MSVC
Date: Tue, 15 Sep 2009 23:07:47 +0400	[thread overview]
Message-ID: <e2480c70909151207v4d89d302m27aecff0d4a11d45@mail.gmail.com> (raw)
In-Reply-To: <badc5d24387c28c752a45f75e8aec6bce64f81fe.1253021728.git.mstormo@gmail.com>

GMail ate the bottom half of my message... again. :( Seems like
there's a strange bug in copy/pasting, I better compose long emails in
TextMate from now on. Here's a "reconstruction":

On Tue, Sep 15, 2009 at 5:44 PM, Marius Storm-Olsen <mstormo@gmail.com> wrote:
> +extern int _fmode;

And indeed. I just ported this patch to my custom msysgit branch
(based on v1.6.4.3) and it didn't compile:

   CC git.o
cc1.exe: warnings being treated as errors
In file included from git-compat-util.h:116,
                from builtin.h:4,
                from git.c:1:
compat/mingw.h:243: error: '_fmode' redeclared without dllimport
attribute: previous dllimport ignored
git.c: In function 'main':
git.c:456: error: the address of '_iob' will always evaluate as 'true'
make: *** [git.o] Error 1

> +       if (stdin) \
> +               _setmode(_fileno(stdin), _O_BINARY); \
> +       if (stdout) \
> +               _setmode(_fileno(stdout), _O_BINARY); \
> +       if (stderr) \
> +               _setmode(_fileno(stderr), _O_BINARY); \

Also, at least mingw/gcc that is coming with msysgit thinks that
stdin/stdout/stderr always evaluate to true, and this check causes
problems as well. In the end, your patch should become something like
this:

diff --git a/compat/mingw.c b/compat/mingw.c
index fd642e4..807996c 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -5,7 +5,6 @@
 #include "../strbuf.h"

 extern int hide_dotfiles;
-unsigned int _CRT_fmode = _O_BINARY;

 static int err_win_to_posix(DWORD winerr)
 {
diff --git a/compat/mingw.h b/compat/mingw.h
index cfbcc0e..46473c5 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -244,6 +244,10 @@ char **env_setenv(char **env, const char *name);
 static int mingw_main(); \
 int main(int argc, const char **argv) \
 { \
+	_fmode = _O_BINARY; \
+	_setmode(_fileno(stdin), _O_BINARY); \
+	_setmode(_fileno(stdout), _O_BINARY); \
+	_setmode(_fileno(stderr), _O_BINARY); \
 	argv[0] = xstrdup(_pgmptr); \
 	return mingw_main(argc, argv); \
 } \

I can't check if it compiles with MSVC, but with msysgit it compiles
fine. Tests pass at least up to 3400 (haven't finished the rest).

  parent reply	other threads:[~2009-09-15 19:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-15 13:44 [RFC/PATCH v3 00/14] Build Git with MSVC Marius Storm-Olsen
     [not found] ` <cover.1253021728.git.mstormo@gmail.com>
2009-09-15 13:44   ` [PATCH 01/14] Avoid declaration after statement Marius Storm-Olsen
2009-09-15 13:44   ` [PATCH 02/14] Add define guards to compat/win32.h Marius Storm-Olsen
2009-09-15 13:44   ` [PATCH 03/14] Change regerror() declaration from K&R style to ANSI C (C89) Marius Storm-Olsen
2009-09-15 13:44   ` [PATCH 04/14] Set _O_BINARY as default fmode for both MinGW and MSVC Marius Storm-Olsen
2009-09-15 18:40     ` Alexey Borzenkov
2009-09-15 19:01     ` Alexey Borzenkov
2009-09-15 19:07     ` Alexey Borzenkov [this message]
2009-09-15 19:12       ` Marius Storm-Olsen
2009-09-15 13:44   ` [PATCH 05/14] Fix __stdcall placement and function prototype Marius Storm-Olsen
2009-09-15 13:44   ` [PATCH 06/14] Test for WIN32 instead of __MINGW32_ Marius Storm-Olsen
2009-09-15 13:44   ` [PATCH 07/14] Add empty header files for MSVC port Marius Storm-Olsen
2009-09-15 13:44   ` [PATCH 08/14] Add MinGW header files to build git with MSVC Marius Storm-Olsen
2009-09-15 13:44   ` [PATCH 09/14] Add platform files for MSVC porting Marius Storm-Olsen
2009-09-15 13:44   ` [PATCH 10/14] Make usage of windows.h lean and mean Marius Storm-Olsen
2009-09-15 13:44     ` [PATCH 11/14] Define strncasecmp and ftruncate for MSVC Marius Storm-Olsen
2009-09-15 13:44   ` [PATCH 12/14] Add MSVC to Makefile Marius Storm-Olsen
2009-09-15 13:44   ` [PATCH 13/14] Add README for MSVC build Marius Storm-Olsen
2009-09-16  1:22     ` Thiago Farina
2009-09-16  5:26       ` Marius Storm-Olsen
2009-09-15 13:44   ` [PATCH 14/14] Add scripts to generate projects for other buildsystems (MSVC vcproj, QMake) Marius Storm-Olsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e2480c70909151207v4d89d302m27aecff0d4a11d45@mail.gmail.com \
    --to=snaury@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=lznuaa@gmail.com \
    --cc=mstormo@gmail.com \
    --cc=msysgit@googlegroups.com \
    --cc=raa.lkml@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.