Build git with MSVC
cover Build git with MSVC
So, Frank Li started this series, and I took it upon my self to help out a bit; cleaning, reorganizing, rebasing the series. Hopefully we're now a bit closer to including the series into mainline..
Here's a summary of what has happend:
1) This series is rebased ontop of git.git 'next', which needed an extra patch to avoid a non-constant array creation, which mscv doesn't like.
2) I've polished (tied to anyways) the commit messages a bit.
3) I've applied much of the feedback provided to the first round of the patches.
4) I've split, merged and reordered some of the patches, so things that belong together are in the same commits, and in a order of 'importance'
5) I've removed the
#define func _func
stuff, as it's not needed and Microsoft cannot really kill the compatibility functions anyways. So, adding the define
_CRT_NONSTDC_NO_DEPRECATE
will kill the warnings seen without the defines above.
6) ..probably much more as well, but I forget..
Note: I did not sign off on the last two commits, which involve the adding of the vcproj files, since I don't agree on adding them as is. We need a Makefile way of compiling primarily, and second, a script to generate the vcproj, as already discussed. But the commits are included for completeness, at to let others compile and play with it.
I've kept the original author as is, and just signed the patches.. Thanks for watching, now bring on the comments!
Frank Li (11):
Avoid declaration after statement
Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++ Change regerror() declaration from K&R style to ANSI C (C89) mingw.c: Use the O_BINARY flag to open files
Fix __stdcall/WINAPI placement and function prototype Test for WIN32 instead of __MINGW32_
Avoid including windows.h in winansi.c for MSVC build Add MinGW header files to build git with MSVC
Add platform files for MSVC porting
Add MSVC project files
Add README and gitignore file for MSVC build
Marius Storm-Olsen (3):
Fix non-constant array creation
Add define guards to compat/win32.h
Add empty header files for MSVC port
builtin-apply.c | 3 +- compat/mingw.c | 20 +- compat/msvc.c | 35 + compat/msvc.h | 102 +++ compat/regex/regex.c | 7 +- compat/snprintf.c | 2 +- compat/vcbuild/.gitignore | 3 + compat/vcbuild/README | 13 + compat/vcbuild/git/git.vcproj | 197 +++++ compat/vcbuild/include/arpa/inet.h | 1 + compat/vcbuild/include/dirent.h | 128 ++++ compat/vcbuild/include/grp.h | 1 + compat/vcbuild/include/inttypes.h | 1 + compat/vcbuild/include/netdb.h | 1 + compat/vcbuild/include/netinet/in.h | 1 + compat/vcbuild/include/netinet/tcp.h | 1 + compat/vcbuild/include/pwd.h | 1 + compat/vcbuild/include/sys/ioctl.h | 1 + compat/vcbuild/include/sys/param.h | 1 + compat/vcbuild/include/sys/poll.h | 1 + compat/vcbuild/include/sys/select.h | 1 + compat/vcbuild/include/sys/socket.h | 1 + compat/vcbuild/include/sys/time.h | 1 + compat/vcbuild/include/sys/utime.h | 34 + compat/vcbuild/include/sys/wait.h | 1 + compat/vcbuild/include/unistd.h | 92 +++ compat/vcbuild/include/utime.h | 1 + compat/vcbuild/libgit/libgit.vcproj | 1359 ++++++++++++++++++++++++++++++++++ compat/win32.h | 5 + compat/winansi.c | 2 + git-compat-util.h | 3 + help.c | 5 +- pager.c | 4 +- run-command.c | 12 +- run-command.h | 2 +- setup.c | 2 +- 36 files changed, 2020 insertions(+), 25 deletions(-) create mode 100644 compat/msvc.c create mode 100644 compat/msvc.h create mode 100644 compat/vcbuild/.gitignore create mode 100644 compat/vcbuild/README create mode 100644 compat/vcbuild/git/git.vcproj create mode 100644 compat/vcbuild/include/arpa/inet.h create mode 100644 compat/vcbuild/include/dirent.h create mode 100644 compat/vcbuild/include/grp.h create mode 100644 compat/vcbuild/include/inttypes.h create mode 100644 compat/vcbuild/include/netdb.h create mode 100644 compat/vcbuild/include/netinet/in.h create mode 100644 compat/vcbuild/include/netinet/tcp.h create mode 100644 compat/vcbuild/include/pwd.h create mode 100644 compat/vcbuild/include/sys/ioctl.h create mode 100644 compat/vcbuild/include/sys/param.h create mode 100644 compat/vcbuild/include/sys/poll.h create mode 100644 compat/vcbuild/include/sys/select.h create mode 100644 compat/vcbuild/include/sys/socket.h create mode 100644 compat/vcbuild/include/sys/time.h create mode 100644 compat/vcbuild/include/sys/utime.h create mode 100644 compat/vcbuild/include/sys/wait.h create mode 100644 compat/vcbuild/include/unistd.h create mode 100644 compat/vcbuild/include/utime.h create mode 100644 compat/vcbuild/libgit/libgit.vcproj
PATCH 1/14 Fix non-constant array creation
MSVC doesn't munge the non-constant expression, so use xmalloc instead.
--- builtin-apply.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
builtin-apply.c +2 -1
@@ -1875,7 +1875,7 @@ static int match_fragment(struct image *img,size_t imgoff =0 ;size_t preoff =0 ;size_t postlen = postimage->len; -size_t imglen[preimage->nr]; +size_t *imglen =xmalloc (sizeof (size_t ) * preimage->nr);for (i =0 ; i < preimage->nr; i++) {size_t prelen = preimage->line[i].len;
@@ -1901,6 +1901,7 @@ static int match_fragment(struct image *img,memcpy (fixed_buf, img->buf + try, imgoff);for (i =0 ; i < preimage->nr; i++) preimage->line[i].len = imglen[i]; +free (imglen);/* * Update the preimage buffer and the postimage context lines.
Signature · 1 line
1.6.3.msysgit.0.18.gef407
Re: [PATCH 01/14] Fix non-constant array creation
builtin-apply.c static int match_fragment(struct image *img, · line 1878
Quoted 6 lines · Marius Storm-Olsen
builtin-apply.c +1
-1@@ -1875,7 +1875,7 @@ static int match_fragment(struct image *img, size_t imgoff = 0; size_t preoff = 0; size_t postlen = postimage->len; - size_t imglen[preimage->nr]; + size_t *imglen = xmalloc(sizeof(size_t) * preimage->nr);
How about using alloca instead? It allocates from the stack (just like the C99-style variable-length array you're replacing), and you don't need to free the memory afterwards.
... or is alloca frowned upon? I see it's already used both in compat/regex/regex.c and in compat/nedmalloc/malloc.c, but not apparently not in the git core.
Signature · 3 lines
Erik "kusma" Faye-Lund [email protected] (+47) 986 59 656
Re: [PATCH 01/14] Fix non-constant array creation
Erik Faye-Lund said the following on 21.08.2009 15:41:
Quoted 12 lines · Marius Storm-Olsen
builtin-apply.c static int match_fragment(struct image *img, · line 1878
Quoted 6 lines
builtin-apply.c +1
-1@@ -1875,7 +1875,7 @@ static int match_fragment(struct image *img,size_t imgoff =0 ;size_t preoff =0 ;size_t postlen = postimage->len; -size_t imglen[preimage->nr]; +size_t *imglen =xmalloc (sizeof (size_t ) * preimage->nr);How about using alloca instead? It allocates from the stack (just like the C99-style variable-length array you're replacing), and you don't need to free the memory afterwards.
Quoted 3 lines
... or is alloca frowned upon? I see it's already used both in
compat/regex/regex.cand incompat/nedmalloc/malloc.c, but not apparently not in the git core.
MSVC compiles regex.c, so it must handle it. I'm fine with that.
--
.marius
Re: [msysGit] Re: [PATCH 01/14] Fix non-constant array creation
Quoted 1 line
MSVC compiles
regex.c, so it must handle it. I'm fine with that.
msvc supports alloca, but regex.c doesn't make use of it per default (you must define HAVE_ALLOCA_H in order to use it). basically _alloca is fine for that task, but be aware that error handling on windows is a bit compilicated. when _alloca fails it throws a structured exception, you must reset the stack and use traditional memory allocation as fallback. see
http://msdn.microsoft.com/en-us/library/wb1s57t5.aspx. :-)
janos
Re: [msysGit] Re: [PATCH 01/14] Fix non-constant array creation
Janos Laube said the following on 21.08.2009 18:26:
Quoted 5 lines
Quoted 1 line
MSVC compiles
regex.c, so it must handle it. I'm fine with that.msvc supports alloca, but
regex.cdoesn't make use of it per default (you must defineHAVE_ALLOCA_Hin order to use it). basically_alloca
is fine for that task, but be aware that error handling on windows
is a bit compilicated. when_allocafails it throws a structured exception, you must reset the stack and use traditional memory allocation as fallback. see http://msdn.microsoft.com/en-us/library/wb1s57t5.aspx. :-)
I must admit that I didn't look much at the surrounding code to know how large preimage->nr can get. But assuming variable-length array is handled the same way by the compiler as alloca(), and this code seems to be performing fine, I guess it's safe to say that this code won't be triggering any SEH, and thus we won't need to handle it?
So, given my assumptions I think we can just replace that one line with alloca(), nuke the free(), and everything is ok.
--
.marius
Re: [msysGit] Re: [PATCH 01/14] Fix non-constant array creation
In reply to Janos LaubeJanos Laube schreef:
Quoted 10 lines
Quoted 1 line
MSVC compiles
regex.c, so it must handle it. I'm fine with that.msvc supports alloca, but
regex.cdoesn't make use of it per default (you must defineHAVE_ALLOCA_Hin order to use it). basically_allocais fine for that task, but be aware that error handling on windows is a bit compilicated. when_allocafails it throws a structured exception, you must reset the stack and use traditional memory allocation as fallback. see
http://msdn.microsoft.com/en-us/library/wb1s57t5.aspx. :-)
alloca() throws an exception when out of stack memory. But what would the dynamically alloced array do when it runs out of memory? (Supposing that those arrays are also created on the stack, which I don't know...) Is that realy more complicated?
Re: [msysGit] Re: [PATCH 01/14] Fix non-constant array creation
Quoted 4 lines · Johan 't Hart
alloca()throws an exception when out of stack memory. But what would the dynamically alloced array do when it runs out of memory? (Supposing that those arrays are also created on the stack, which I don't know...) Is that realy more complicated?
You get a run-time error. Or rather, you get a run-time error if you're out of address space. If you go out of memory, swapping mechanisms are used. And in turn, if the swapping mechanisms fail, you'll get a run-time error AFAIK.
Signature · 3 lines
Erik "kusma" Faye-Lund [email protected] (+47) 986 59 656
Re: [PATCH 01/14] Fix non-constant array creation
In reply to Erik Faye-LundQuoted 1 line · Erik Faye-Lund
How about using alloca instead?
I tend to avoid it; historically, alloca has been a worse portability nightmare.
Re: [PATCH 01/14] Fix non-constant array creation
In reply to Marius Storm-OlsenQuoted 1 line · Marius Storm-Olsen
MSVC doesn't munge the non-constant expression, so use xmalloc instead.
Thanks.
These things are called variable length array, and MSVC is not the only one that do not glok vla.
Subject: Avoid use of variable length array
Some compilers unfortunately do not understand these constructs. In codepaths that are not performance critical, use xmalloc() and free() instead.
There is another use of vla; I would suggest squashing the following patch in.
builtin-pack-objects.c +5 -1
@@ -1599,7 +1599,7 @@ static void *threaded_find_deltas(void *arg)static void ll_find_deltas (struct object_entry **list,unsigned list_size,int window,int depth,unsigned *processed) { -struct thread_params p[delta_search_threads]; +struct thread_params *p;int i, ret, active_threads =0 ;if (delta_search_threads <=1 ) {
@@ -1610,6 +1610,8 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,fprintf (stderr,"Delta compression using up to %d threads.\n" , delta_search_threads); + p =xcalloc (delta_search_threads,sizeof (*p)); +/* Partition the work amongst work threads. */ for (i =0 ; i < delta_search_threads; i++) {unsigned sub_size = list_size / (delta_search_threads - i);
@@ -1717,6 +1719,8 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size, active_threads--; } } + +free (p); }#else
PATCH 2/14 Avoid declaration after statement
In reply to Marius Storm-OlsenFrom: Frank Li <[email protected]>
Microsoft Visual C++ does not understand this C99 style
--- compat/mingw.c | 14 ++++++++++---- help.c | 3 ++- run-command.c | 2 ++ 3 files changed, 14 insertions(+), 5 deletions(-)
compat/mingw.c +10 -4
@@ -123,13 +123,17 @@ int mingw_open (const char *filename, int oflags, ...) {va_list args;unsigned mode; +int fd; +va_start (args, oflags); mode =va_arg (args, int);va_end (args);if (!strcmp (filename,"/dev/null" )) filename ="nul" ; -int fd =open (filename, oflags, mode); + + fd =open (filename, oflags, mode); +if (fd <0 && (oflags &O_CREAT ) && errno ==EACCES ) {DWORD attrs =GetFileAttributes (filename);if (attrs !=INVALID_FILE_ATTRIBUTES && (attrs &FILE_ATTRIBUTE_DIRECTORY ))
@@ -580,10 +584,11 @@ static char **get_path_split(void)static void free_path_split (char **path) { +char **p = path; +if (!path)return ; -char **p = path;while (*p)free (*p++);free (path);
@@ -1108,9 +1113,9 @@ int sigaction(int sig, struct sigaction *in, struct sigaction *out)#undef signalsig_handler_t mingw_signal (int sig,sig_handler_t handler) { +sig_handler_t old = timer_fn;if (sig !=SIGALRM )return signal (sig, handler); -sig_handler_t old = timer_fn; timer_fn = handler;return old; }
@@ -1197,8 +1202,9 @@ struct dirent *mingw_readdir(DIR *dir)if (dir->dd_handle == (long )INVALID_HANDLE_VALUE && dir->dd_stat ==0 ) { +DWORD lasterr; handle =FindFirstFileA (dir->dd_name, &buf); -DWORD lasterr =GetLastError (); + lasterr =GetLastError (); dir->dd_handle = (long )handle;if (handle ==INVALID_HANDLE_VALUE && (lasterr !=ERROR_NO_MORE_FILES )) { errno =err_win_to_posix (lasterr);
help.c +2 -1
@@ -127,7 +127,7 @@ static int is_executable(const char *name)return 0 ;#ifdef __MINGW32__ -/* cannot trust the executable bit, peek into the file instead */ +{/* cannot trust the executable bit, peek into the file instead */ char buf[3 ] = {0 };int n;int fd =open (name,O_RDONLY );
@@ -140,6 +140,7 @@ static int is_executable(const char *name) st.st_mode |=S_IXUSR ; close(fd); } +}#endif return st.st_mode &S_IXUSR ; }
run-command.c +2 -0
@@ -134,6 +134,7 @@ fail_pipe:error ("cannot fork() for %s: %s" , cmd->argv[0 ],strerror (failed_errno = errno));#else +{int s0 =-1 , s1 =-1 , s2 =-1 ;/* backups of stdin, stdout, stderr */ const char **sargv = cmd->argv;char **env = environ;
@@ -200,6 +201,7 @@ fail_pipe:dup2 (s1,1 ),close (s1);if (s2 >=0 ) dup2(s2, 2), close(s2); +}#endif if (cmd->pid <0 ) {
Signature · 1 line
1.6.3.msysgit.0.18.gef407
PATCH 3/14 Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++
From: Frank Li <[email protected]>
The Microsoft C runtime's vsnprintf function does not add NUL at the end of the buffer.
--- compat/snprintf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
compat/snprintf.c +1 -1
@@ -6,7 +6,7 @@* number of characters to write without the trailing NUL. */ #ifndef SNPRINTF_SIZE_CORR -#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ <4 +#if (defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ <4 ) || defined(_MSC_VER)#define SNPRINTF_SIZE_CORR 1#else #define SNPRINTF_SIZE_CORR 0
Signature · 1 line
1.6.3.msysgit.0.18.gef407
Re: [PATCH 03/14] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++
Quoted 4 lines · Marius Storm-Olsen
From: Frank Li <[email protected]>
The Microsoft C runtime's vsnprintf function does not add NUL at the end of the buffer.
This contradicts the way I read the comment in compat/snprintf.c from f4626df (Add target architecture MinGW., 2007-12-01).
As far as I can see, the correction is about the meaning of the size parameter to the function, namely, that a broken implementation may mistakenly think that it was told the maximum length of the meat of the string to write, and it is allowed to append a NUL beyond the limit, when the caller actually is telling it the size of the buffer.
So if my reading is correct, it is not about "does not add NUL at the end" at all; it is "adds NUL beyond the end of given output buffer."
Re: [PATCH 03/14] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++
Quoted 6 lines · Junio C Hamano
Quoted 4 lines · Marius Storm-Olsen
From: Frank Li <[email protected]>
The Microsoft C runtime's vsnprintf function does not add NUL at the end of the buffer.
Quoted 8 lines
This contradicts the way I read the comment in
compat/snprintf.cfrom f4626df (Add target architecture MinGW., 2007-12-01).As far as I can see, the correction is about the meaning of the size parameter to the function, namely, that a broken implementation may mistakenly think that it was told the maximum length of the meat of the string to write, and it is allowed to append a NUL beyond the limit, when the caller actually is telling it the size of the buffer.
Not quite. The parameter *is* the size of the buffer and vsnprintf does not write beyond the buffer. However, it has the awkward behavior that if the buffer is too short by exactly one byte, i.e. there is room for the complete string, but not for the terminating NUL, then vsnprintf does not report an error!
Therefore, we tell vsnprintf that the buffer is shorter by one byte and always write NUL in the last position so that we get a correctly terminated string even in this case.
-- Hannes
Re: [PATCH 03/14] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++
Quoted 3 lines · Johannes Sixt
Not quite. The parameter *is* the size of the buffer and vsnprintf does not write beyond the buffer. However, it has the awkward behavior that if the buffer is too short by exactly one byte...
Thanks; I was fooled by the leading comment. How about ...
compat/snprintf.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
compat/snprintf.c +2 -1
@@ -3,7 +3,8 @@/* * The size parameter specifies the available space, i.e. includes * the trailing NUL byte; but Windows's vsnprintf expects the -* number of characters to write without the trailing NUL. +* number of characters to write, and does not necessarily write the +* trailing NUL. */ #ifndef SNPRINTF_SIZE_CORR #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ <4
Re: [PATCH 03/14] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++
Quoted 18 lines · Junio C Hamano
Quoted 1 line · Johannes Sixt
Not quite. The parameter *is* the size of the buffer and vsnprintf does
not
Quoted 2 lines
write beyond the buffer. However, it has the awkward behavior that if the buffer is too short by exactly one byte...
Thanks; I was fooled by the leading comment. How about ...
compat/snprintf.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)compat/snprintf.c +0
-0
compat/snprintf.c line 10
Quoted 9 lines
compat/snprintf.c +2
-1@@ -3,7 +3,8 @@/* * The size parameter specifies the available space, i.e. includes * the trailing NUL byte; but Windows's vsnprintf expects the -* number of characters to write without the trailing NUL. +* number of characters to write, and does not necessarily write the +* trailing NUL. */ #ifndef SNPRINTF_SIZE_CORR #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ <4
Agreed. If you'd like, I'll squash that into the change, and make the commit msg more clear.
--
.marius
Re: [PATCH 03/14] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++
In reply to Junio C Hamano[Resending to list since gmail web interface was setup to do HTML mails by default. Grrr
Get plain text, reply with plain text. Obvious, isn't it Google? Sorry guys..]
Quoted 17 lines · Junio C Hamano
Quoted 3 lines · Johannes Sixt
Not quite. The parameter *is* the size of the buffer and vsnprintf does not write beyond the buffer. However, it has the awkward behavior that if the buffer is too short by exactly one byte...
Thanks; I was fooled by the leading comment. How about ...
compat/snprintf.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)compat/snprintf.c +0
-0
compat/snprintf.c line 10
Quoted 9 lines
compat/snprintf.c +2
-1@@ -3,7 +3,8 @@/* * The size parameter specifies the available space, i.e. includes * the trailing NUL byte; but Windows's vsnprintf expects the -* number of characters to write without the trailing NUL. +* number of characters to write, and does not necessarily write the +* trailing NUL. */ #ifndef SNPRINTF_SIZE_CORR #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ <4
Agreed. If you'd like, I'll squash that into the change, and make the commit msg more clear.
--
.marius
Re: [PATCH 03/14] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++
In reply to Junio C HamanoJunio C Hamano schreef:
Quoted 10 lines
Quoted 4 lines · Marius Storm-Olsen
From: Frank Li <[email protected]>
The Microsoft C runtime's vsnprintf function does not add NUL at the end of the buffer.
So if my reading is correct, it is not about "does not add NUL at the end" at all; it is "adds NUL beyond the end of given output buffer."
As far as I know, the windows implementation does not add a terminating NUL when the string to write is greater or equal to the given buffer size. Otherwise it does add the NUL. Same as for strncpy() on windows.
In my experience the windows implementation does never write behind the given buffer, not even a terminating zero.
PATCH 4/14 Add define guards to compat/win32.h
In reply to Marius Storm-Olsen--- compat/win32.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
compat/win32.h +5 -0
@@ -1,3 +1,6 @@ +#ifndef WIN32_H +#define WIN32_H +/* common Win32 functions for MinGW and Cygwin */ #include <windows.h>
@@ -32,3 +35,5 @@ static inline int get_file_attr(const char *fname, WIN32_FILE_ATTRIBUTE_DATA *fd return ENOENT; } } + +#endif
Signature · 1 line
1.6.3.msysgit.0.18.gef407
PATCH 5/14 Change regerror() declaration from K&R style to ANSI C (C89)
From: Frank Li <[email protected]>
The MSVC compiler doesn't like K&R style.
--- compat/regex/regex.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
compat/regex/regex.c +2 -5
@@ -4852,11 +4852,8 @@ regexec (preg, string, nmatch, pmatch, eflags)from either regcomp or regexec. We don't use PREG here. */ size_t -regerror (errcode, preg, errbuf, errbuf_size) -int errcode; -const regex_t *preg; -char *errbuf; -size_t errbuf_size; +regerror (int errcode,const regex_t *preg, +char *errbuf,size_t errbuf_size) {const char *msg;size_t msg_size;
Signature · 1 line
1.6.3.msysgit.0.18.gef407
PATCH v2 5/14 Change regerror() definition from K&R style to ANSI C (C89)
From: Frank Li <[email protected]>
The MSVC headers typedef errcode as int, and thus confused the compiler in the K&R style definition. ANSI style deconfuses it.
---
Frank, like this one better?
compat/regex/regex.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
compat/regex/regex.c +2 -5
@@ -4852,11 +4852,8 @@ regexec (preg, string, nmatch, pmatch, eflags)from either regcomp or regexec. We don't use PREG here. */ size_t -regerror (errcode, preg, errbuf, errbuf_size) -int errcode; -const regex_t *preg; -char *errbuf; -size_t errbuf_size; +regerror (int errcode,const regex_t *preg, +char *errbuf,size_t errbuf_size) {const char *msg;size_t msg_size;
Signature · 1 line
1.6.3.msysgit.0.18.gef407
Re: [PATCH v2 05/14] Change regerror() definition from K&R style to ANSI C (C89)
Quoted 4 lines
The MSVC headers typedef errcode as int, and thus confused the compiler in the K&R style definition. ANSI style deconfuses it.
It is better
best regards
Frank Li
Re: [PATCH v2 05/14] Change regerror() definition from K&R style to ANSI C (C89)
In reply to Marius Storm-OlsenQuoted 9 lines · Marius Storm-Olsen
size_t
compat/regex/regex.c +2
-5-regerror (errcode, preg, errbuf, errbuf_size) - int errcode; - const regex_t *preg; - char *errbuf; - size_t errbuf_size; +regerror(int errcode, const regex_t *preg, + char *errbuf, size_t errbuf_size){
Since the real reason isn't the K&R style defintion, but that "errcode" has been typedef'ed, perhaps it's better to either do something like this:
#ifdef _MSC_VER
#define errcode dummy_def
#include <crtdefs.h>
#undef errcode
#endif
...before the first crt-inclusion, or simply to rename "errcode" to something like "error"? The latter can be done with the preprocessor after the first crt-inclusion.
Signature · 3 lines
Erik "kusma" Faye-Lund [email protected] (+47) 986 59 656
Re: [PATCH 05/14] Change regerror() declaration from K&R style to ANSI C (C89)
In reply to Marius Storm-OlsenQuoted 10 lines
size_t
compat/regex/regex.c +2
-5-regerror (errcode, preg, errbuf, errbuf_size) - int errcode; - const regex_t *preg; - char *errbuf; - size_t errbuf_size; +regerror(int errcode, const regex_t *preg, + char *errbuf, size_t errbuf_size){
The true reason is MSVC type define errcode as int. Frank Li
PATCH 6/14 mingw.c: Use the O_BINARY flag to open files
In reply to Marius Storm-OlsenFrom: Frank Li <[email protected]>
On Windows, binary files must be opened using the O_BINARY flag for untranslated mode. MinGW does this for us automatically, but Microsoft Visual C++ does not.
--- compat/mingw.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
compat/mingw.c +2 -2
@@ -132,7 +132,7 @@ int mingw_open (const char *filename, int oflags, ...)if (!strcmp (filename,"/dev/null" )) filename ="nul" ; - fd =open (filename, oflags, mode); + fd =open (filename, oflags |O_BINARY , mode);if (fd <0 && (oflags &O_CREAT ) && errno ==EACCES ) {DWORD attrs =GetFileAttributes (filename);
@@ -278,7 +278,7 @@ int mkstemp(char *template)char *filename =mktemp (template);if (filename ==NULL )return -1 ; -return open (filename,O_RDWR |O_CREAT ,0600 ); +return open (filename,O_RDWR |O_CREAT |O_BINARY ,0600 ); }int gettimeofday (struct timeval *tv,void *tz)
Signature · 1 line
1.6.3.msysgit.0.18.gef407
PATCH 7/14 Fix __stdcall/WINAPI placement and function prototype
From: Frank Li <[email protected]>
WINAPI is a macro which translates into the proper calling convention, so replace __stdcall with that.
MSVC requires WINAPI to be between the functions return value and the function name, and that the function pointer type is in the form of
return_type (WINAPI *function_name)(arguments...)
--- compat/mingw.c | 4 ++-- run-command.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
compat/mingw.c +2 -2
@@ -1017,7 +1017,7 @@ static sig_handler_t timer_fn = SIG_DFL;* length to call the signal handler. */ -static __stdcall unsigned ticktack (void *dummy) +static unsigned WINAPI ticktack (void *dummy) {while (WaitForSingleObject (timer_event, timer_interval) ==WAIT_TIMEOUT ) {if (timer_fn ==SIG_DFL )
@@ -1144,7 +1144,7 @@ void mingw_open_html(const char *unixpath)int link (const char *oldpath,const char *newpath) { - typedef BOOL WINAPI (*T)(const char*, const char*, LPSECURITY_ATTRIBUTES); + typedef BOOL (WINAPI *T)(const char*, const char*, LPSECURITY_ATTRIBUTES);static T create_hard_link =NULL ;if (!create_hard_link) { create_hard_link = (T) GetProcAddress(
run-command.c +1 -1
@@ -319,7 +319,7 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const }#ifdef __MINGW32__ -static __stdcall unsigned run_thread (void *data) +static unsigned WINAPI run_thread (void *data) {struct async *async = data;return async->proc (async->fd_for_proc, async->data);
Signature · 1 line
1.6.3.msysgit.0.18.gef407
PATCH 8/14 Test for WIN32 instead of __MINGW32_
From: Frank Li <[email protected]>
The code which is conditional on MinGW32 is actually conditional on Windows. Use the WIN32 symbol, which is defined by the MINGW32 and MSVC environments, but not by Cygwin.
--- help.c | 2 +- pager.c | 4 ++-- run-command.c | 8 ++++---- run-command.h | 2 +- setup.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-)
help.c +1 -1
@@ -126,7 +126,7 @@ static int is_executable(const char *name) !S_ISREG(st.st_mode))return 0 ; -#ifdef __MINGW32__ +#ifdef WIN32 {/* cannot trust the executable bit, peek into the file instead */ char buf[3 ] = {0 };int n;
pager.c +2 -2
@@ -9,7 +9,7 @@static int spawned_pager; -#ifndef __MINGW32__ +#ifndef WIN32 static void pager_preexec (void ) {/*
@@ -70,7 +70,7 @@ void setup_pager(void) pager_argv[2 ] = pager; pager_process.argv = pager_argv; pager_process.in =-1 ; -#ifndef __MINGW32__ +#ifndef WIN32 pager_process.preexec_cb = pager_preexec;#endif if (start_command (&pager_process))
run-command.c +4 -4
@@ -75,7 +75,7 @@ fail_pipe:trace_argv_printf (cmd->argv,"trace: run_command:" ); -#ifndef __MINGW32__ +#ifndef WIN32 fflush (NULL ); cmd->pid =fork ();if (!cmd->pid) {
@@ -318,7 +318,7 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, constreturn run_command (&cmd); } -#ifdef __MINGW32__ +#ifdef WIN32 static unsigned WINAPI run_thread (void *data) {struct async *async = data;
@@ -334,7 +334,7 @@ int start_async(struct async *async)return error ("cannot create pipe: %s" ,strerror (errno)); async->out = pipe_out[0 ]; -#ifndef __MINGW32__ +#ifndef WIN32 /* Flush stdio before fork() to avoid cloning buffers */ fflush (NULL );
@@ -363,7 +363,7 @@ int start_async(struct async *async)int finish_async (struct async *async) { -#ifndef __MINGW32__ +#ifndef WIN32 int ret =wait_or_whine (async->pid,"child process" ,0 );#else DWORD ret =0 ;
run-command.h +1 -1
@@ -70,7 +70,7 @@ struct async {int (*proc)(int fd,void *data);void *data;int out;/* caller reads from here and closes it */ -#ifndef __MINGW32__ +#ifndef WIN32 pid_t pid;#else HANDLE tid;
setup.c +1 -1
@@ -41,7 +41,7 @@ const char *prefix_path(const char *prefix, int len, const char *path)const char *prefix_filename (const char *pfx,int pfx_len,const char *arg) {static char path[PATH_MAX ]; -#ifndef __MINGW32__ +#ifndef WIN32 if (!pfx || !*pfx ||is_absolute_path (arg))return arg;memcpy (path, pfx, pfx_len);
Signature · 1 line
1.6.3.msysgit.0.18.gef407
PATCH 9/14 Avoid including windows.h in winansi.c for MSVC build
From: Frank Li <[email protected]>
compat/msvc.h includes winsock2.h which conflicts with windows.h. msvc.h also defines the oldest Windows API version required.
--- compat/winansi.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
compat/winansi.c +2 -0
@@ -2,7 +2,9 @@* Copyright 2008 Peter Harris <[email protected]> */ +#ifndef _MSC_VER#include <windows.h> +#endif #include "../git-compat-util.h" /*
Signature · 1 line
1.6.3.msysgit.0.18.gef407
PATCH 10/14 Add empty header files for MSVC port
MSVC lacks many of the header files included by git-compat-util.h, so add blank header files for these instead of going ifdef crazy.
--- compat/vcbuild/include/arpa/inet.h | 1 + compat/vcbuild/include/grp.h | 1 + compat/vcbuild/include/inttypes.h | 1 + compat/vcbuild/include/netdb.h | 1 + compat/vcbuild/include/netinet/in.h | 1 + compat/vcbuild/include/netinet/tcp.h | 1 + compat/vcbuild/include/pwd.h | 1 + compat/vcbuild/include/sys/ioctl.h | 1 + compat/vcbuild/include/sys/param.h | 1 + compat/vcbuild/include/sys/poll.h | 1 + compat/vcbuild/include/sys/select.h | 1 + compat/vcbuild/include/sys/socket.h | 1 + compat/vcbuild/include/sys/time.h | 1 + compat/vcbuild/include/sys/wait.h | 1 + 14 files changed, 14 insertions(+), 0 deletions(-) create mode 100644 compat/vcbuild/include/arpa/inet.h create mode 100644 compat/vcbuild/include/grp.h create mode 100644 compat/vcbuild/include/inttypes.h create mode 100644 compat/vcbuild/include/netdb.h create mode 100644 compat/vcbuild/include/netinet/in.h create mode 100644 compat/vcbuild/include/netinet/tcp.h create mode 100644 compat/vcbuild/include/pwd.h create mode 100644 compat/vcbuild/include/sys/ioctl.h create mode 100644 compat/vcbuild/include/sys/param.h create mode 100644 compat/vcbuild/include/sys/poll.h create mode 100644 compat/vcbuild/include/sys/select.h create mode 100644 compat/vcbuild/include/sys/socket.h create mode 100644 compat/vcbuild/include/sys/time.h create mode 100644 compat/vcbuild/include/sys/wait.h
compat/vcbuild/include/arpa/inet.h new file +1 -0
@@ -0,0 +1 @@ +/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/grp.h new file +1 -0
@@ -0,0 +1 @@ +/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/inttypes.h new file +1 -0
@@ -0,0 +1 @@ +/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/netdb.h new file +1 -0
@@ -0,0 +1 @@ +/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/netinet/in.h new file +1 -0
@@ -0,0 +1 @@ +/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/netinet/tcp.h new file +1 -0
@@ -0,0 +1 @@ +/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/pwd.h new file +1 -0
@@ -0,0 +1 @@ +/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/sys/ioctl.h new file +1 -0
@@ -0,0 +1 @@ +/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/sys/param.h new file +1 -0
@@ -0,0 +1 @@ +/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/sys/poll.h new file +1 -0
@@ -0,0 +1 @@ +/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/sys/select.h new file +1 -0
@@ -0,0 +1 @@ +/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/sys/socket.h new file +1 -0
@@ -0,0 +1 @@ +/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/sys/time.h new file +1 -0
@@ -0,0 +1 @@ +/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/sys/wait.h new file +1 -0
@@ -0,0 +1 @@ +/* Intentionally empty file to support building git with MSVC */
Signature · 1 line
1.6.3.msysgit.0.18.gef407
PATCH 11/14 Add MinGW header files to build git with MSVC
From: Frank Li <[email protected]>
Added the header files dirent.h, unistd.h and utime.h
--- compat/vcbuild/include/dirent.h | 128 ++++++++++++++++++++++++++++++++++++ compat/vcbuild/include/sys/utime.h | 34 ++++++++++ compat/vcbuild/include/unistd.h | 92 ++++++++++++++++++++++++++ compat/vcbuild/include/utime.h | 1 + 4 files changed, 255 insertions(+), 0 deletions(-) create mode 100644 compat/vcbuild/include/dirent.h create mode 100644 compat/vcbuild/include/sys/utime.h create mode 100644 compat/vcbuild/include/unistd.h create mode 100644 compat/vcbuild/include/utime.h
compat/vcbuild/include/dirent.h new file +128 -0
@@ -0,0 +1,128 @@ +/* +* DIRENT.H (formerly DIRLIB.H) +* This file has no copyright assigned and is placed in the Public Domain. +* This file is a part of the mingw-runtime package. +* +* The mingw-runtime package and its code is distributed in the hope that it +* will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR +* IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to +* warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +* You are free to use this package and its code without limitation. +*/ +#ifndef _DIRENT_H_ +#define _DIRENT_H_ +#include <io.h> + +#define PATH_MAX 512 + +#define __MINGW_NOTHROW + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +struct dirent +{ +long d_ino;/* Always zero. */ +unsigned short d_reclen;/* Always zero. */ +unsigned short d_namlen;/* Length of name in d_name. */ +char d_name[FILENAME_MAX ];/* File name. */ +}; + +/* +* This is an internal data structure. Good programmers will not use it +* except as an argument to one of the functions below. +* dd_stat field is now int (was short in older versions). +*/ +typedef struct +{ +/* disk transfer area for this dir */ +struct _finddata_t dd_dta; + +/* dirent struct to return from dir (NOTE: this makes this thread +* safe as long as only one thread uses a particular DIR struct at +* a time) */ +struct dirent dd_dir; + +/* _findnext handle */ +long dd_handle; + +/* +* Status of search: +* 0 = not started yet (next entry to read is first entry) +* -1 = off the end +* positive = 0 based index of next entry +*/ +int dd_stat; + +/* given path for dir with search pattern (struct is extended) */ +char dd_name[PATH_MAX +3 ]; +}DIR ; + +DIR* __cdecl __MINGW_NOTHROW opendir (const char*); +struct dirent* __cdecl __MINGW_NOTHROW readdir (DIR*); +int __cdecl __MINGW_NOTHROW closedir (DIR*); +void __cdecl __MINGW_NOTHROW rewinddir (DIR*); +long __cdecl __MINGW_NOTHROW telldir (DIR*); +void __cdecl __MINGW_NOTHROW seekdir (DIR*, long); + + +/* wide char versions */ + +struct _wdirent +{ +long d_ino;/* Always zero. */ +unsigned short d_reclen;/* Always zero. */ +unsigned short d_namlen;/* Length of name in d_name. */ +wchar_t d_name[FILENAME_MAX ];/* File name. */ +}; + +/* +* This is an internal data structure. Good programmers will not use it +* except as an argument to one of the functions below. +*/ +typedef struct +{ +/* disk transfer area for this dir */ +//struct _wfinddata_t dd_dta; + +/* dirent struct to return from dir (NOTE: this makes this thread +* safe as long as only one thread uses a particular DIR struct at +* a time) */ +struct _wdirent dd_dir; + +/* _findnext handle */ +long dd_handle; + +/* +* Status of search: +* 0 = not started yet (next entry to read is first entry) +* -1 = off the end +* positive = 0 based index of next entry +*/ +int dd_stat; + +/* given path for dir with search pattern (struct is extended) */ +wchar_t dd_name[1 ]; +}_WDIR ; + + + +_WDIR* __cdecl __MINGW_NOTHROW _wopendir (const wchar_t*); +struct _wdirent* __cdecl __MINGW_NOTHROW _wreaddir (_WDIR*); +int __cdecl __MINGW_NOTHROW _wclosedir (_WDIR*); +void __cdecl __MINGW_NOTHROW _wrewinddir (_WDIR*); +long __cdecl __MINGW_NOTHROW _wtelldir (_WDIR*); +void __cdecl __MINGW_NOTHROW _wseekdir (_WDIR*, long); + + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _DIRENT_H_ */
compat/vcbuild/include/sys/utime.h new file +34 -0
@@ -0,0 +1,34 @@ +#ifndef _UTIME_H_ +#define _UTIME_H_ +/* +* UTIME.H +* This file has no copyright assigned and is placed in the Public Domain. +* This file is a part of the mingw-runtime package. +* +* The mingw-runtime package and its code is distributed in the hope that it +* will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR +* IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to +* warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +* You are free to use this package and its code without limitation. +*/ + +/* +* Structure used by _utime function. +*/ +struct _utimbuf +{ +time_t actime;/* Access time */ +time_t modtime;/* Modification time */ +}; + +#ifndef _NO_OLDNAMES +/* NOTE: Must be the same as _utimbuf above. */ +struct utimbuf +{ +time_t actime; +time_t modtime; +}; +#endif /* Not _NO_OLDNAMES */ + +#endif
compat/vcbuild/include/unistd.h new file +92 -0
92 lines not on this page · raw message
compat/vcbuild/include/utime.h new file +1 -0
@@ -0,0 +1 @@ +#include <sys/utime.h>
Signature · 1 line
1.6.3.msysgit.0.18.gef407
PATCH 12/14 Add platform files for MSVC porting
From: Frank Li <[email protected]>
Add msvc.c and msvc.h to build git under MSVC
--- compat/msvc.c | 35 ++++++++++++++++++ compat/msvc.h | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++ git-compat-util.h | 3 ++ 3 files changed, 140 insertions(+), 0 deletions(-) create mode 100644 compat/msvc.c create mode 100644 compat/msvc.h
compat/msvc.c new file +35 -0
@@ -0,0 +1,35 @@ +#include "../git-compat-util.h" +#include "win32.h" +#include <conio.h> +#include "../strbuf.h" + +DIR *opendir (const char *name) +{ +int len; +DIR *p; + p = (DIR *)malloc (sizeof (DIR )); +memset (p,0 ,sizeof (DIR )); +strncpy (p->dd_name, name,PATH_MAX ); + len =strlen (p->dd_name); + p->dd_name[len] ='/' ; + p->dd_name[len+1 ] ='*' ; + +if (p ==NULL ) +return NULL ; + + p->dd_handle =_findfirst (p->dd_name, &p->dd_dta); + +if (p->dd_handle ==-1 ) { +free (p); +return NULL ; + } +return p; +} +int closedir (DIR *dir) +{ +_findclose (dir->dd_handle); +free (dir); +return 0 ; +} + +#include "mingw.c"
compat/msvc.h new file +102 -0
102 lines not on this page · raw message
git-compat-util.h +3 -0
@@ -113,6 +113,9 @@/* pull in Windows compatibility stuff */ #include "compat/mingw.h" #endif /* __MINGW32__ */ +#ifdef _MSC_VER +#include "compat/msvc.h" +#endif #ifndef NO_LIBGEN_H #include <libgen.h>
Signature · 1 line
1.6.3.msysgit.0.18.gef407
PATCH 13/14 Add MSVC project files
From: Frank Li <[email protected]>
Add libgit.vcproj to build common library, and git.vcproj to build git itself.
--- compat/vcbuild/git/git.vcproj | 197 +++++ compat/vcbuild/libgit/libgit.vcproj | 1359 +++++++++++++++++++++++++++++++++++ 2 files changed, 1556 insertions(+), 0 deletions(-) create mode 100644 compat/vcbuild/git/git.vcproj create mode 100644 compat/vcbuild/libgit/libgit.vcproj
compat/vcbuild/git/git.vcproj new file +197 -0
@@ -0,0 +1,197 @@ +<?xml version="1.0" encoding="gb2312"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="git" + ProjectGUID="{E3E30E51-C5AD-407B-AB43-985E4111474A}" + RootNamespace="git" + Keyword="Win32Proj" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)\bin" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="0" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..;..\..\..\..\zlib;..\..;..\;..\include;..\..\..\compat;..\..\..\compat\fnmatch;..\..\..\compat\regex;.\" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="wininet.lib ws2_32.lib " + LinkIncremental="2" + GenerateDebugInformation="true" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)\bin" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="0" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + AdditionalIncludeDirectories="..\..\..;..\..\..\..\zlib;..\..;..\;..\include;..\..\..\compat;..\..\..\compat\fnmatch;..\..\..\compat\regex;.\" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="wininet.lib ws2_32.lib " + LinkIncremental="1" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath="..\..\..\git.c" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject>
compat/vcbuild/libgit/libgit.vcproj new file +1359 -0
1,359 lines not on this page · raw message
Signature · 1 line
1.6.3.msysgit.0.18.gef407
PATCH 14/14 Add README and gitignore file for MSVC build
From: Frank Li <[email protected]>
Add a README file to tell users how to build git with MSVC.
Also add a gitignore file to make git ignore files generated by a MSVC build.
--- compat/vcbuild/.gitignore | 3 +++ compat/vcbuild/README | 13 +++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) create mode 100644 compat/vcbuild/.gitignore create mode 100644 compat/vcbuild/README
compat/vcbuild/.gitignore new file +3 -0
@@ -0,0 +1,3 @@ +Debug +Release +*.user
compat/vcbuild/README new file +13 -0
@@ -0,0 +1,13 @@ +The Steps of Build Git with VS2008 + +1. Create VC Build Environment. + + git clone git://repo.or.cz/gitbuild.git + + gitbuild include VS solution file and library such as zlib. + +2. Get Submodule + + git submodule update --init + +3. Open gitbuild\gitbuild.sln with VS2008. Then press F7.
Signature · 1 line
1.6.3.msysgit.0.18.gef407
Re: [PATCH 14/14] Add README and gitignore file for MSVC build
Hi,
Quoted 3 lines · Marius Storm-Olsen
From: Frank Li <[email protected]>
+3. Open gitbuild\gitbuild.sln with VS2008. Then press F7.
F7 does nothing in VS2008, to build the solution you have to press Ctrl+Shift+B. To build and start debugging you have to press F5, and for start without debbuging support is Ctrl+F5.
Regards
Re: [PATCH 14/14] Add README and gitignore file for MSVC build
2009/8/23 Thiago Farina <[email protected]>:
Quoted 9 lines
Hi,
Quoted 3 lines · Marius Storm-Olsen
From: Frank Li <[email protected]>
+3. Open gitbuild\gitbuild.sln with VS2008. Then press F7.
F7 does nothing in VS2008, to build the solution you have to press Ctrl+Shift+B. To build and start debugging you have to press F5, and for start without debbuging support is Ctrl+F5.
IIRC, Visual Studio can be configured to use different keyboard shortcuts.
However, saying "press F7" says nothing of the intent. It would probably be better to have this say something like "Then build the solution." or "Open gitbuild\gitbuild.sln with Visual Studio 2008, then build it." But then you don't need to open Visual Studio 2008 to build it (you can build it from command line).
So, how about:
3. You can now build git with Visual Studio 2008 using the
gitbuild\gitbuild.sln file.
- Reece
Re: [PATCH 14/14] Add README and gitignore file for MSVC build
Reece Dunn said the following on 23.08.2009 20:22:
Quoted 19 lines
2009/8/23 Thiago Farina <[email protected]>:
Quoted 9 lines
Hi,
Quoted 3 lines · Marius Storm-Olsen
From: Frank Li <[email protected]>
+3. Open gitbuild\gitbuild.sln with VS2008. Then press F7.
F7 does nothing in VS2008, to build the solution you have to press Ctrl+Shift+B. To build and start debugging you have to press F5, and for start without debbuging support is Ctrl+F5.
IIRC, Visual Studio can be configured to use different keyboard shortcuts.
However, saying "press F7" says nothing of the intent. It would probably be better to have this say something like "Then build the solution." or "Open gitbuild\gitbuild.sln with Visual Studio 2008, then build it." But then you don't need to open Visual Studio 2008 to build it (you can build it from command line).
Quoted 5 lines
So, how about:
3. You can now build git with Visual Studio 2008 using the
gitbuild\gitbuild.sln file.- Reece
Agreed.
Thanks guys.
--
.marius
Re: [PATCH 14/14] Add README and gitignore file for MSVC build
Marius, how common-cmds.h will be generated? In the header file says that it's generated by generate-cmdlist.sh, so the VS user will need to generate this file first (before compiling)?
When I tried to compile after pulling from the repository, I couldn't, so I copied it from the the msysgit.
Re: [PATCH 14/14] Add README and gitignore file for MSVC build
Quoted 2 lines
that it's generated by
generate-cmdlist.sh, so the VS user will need to generate this file first (before compiling)?
I update http://repo.or.cz/w/gitbuild.git.
Add create_command.bat to create common-cmds.h.
Re: [PATCH 14/14] Add README and gitignore file for MSVC build
Hi,
Quoted 6 lines · Frank Li
Quoted 2 lines
that it's generated by
generate-cmdlist.sh, so the VS user will need to generate this file first (before compiling)?I update http://repo.or.cz/w/gitbuild.git.
Add create_command.bat to createcommon-cmds.h.
This is great, thank you for adding this tool.
Today I ran 'git submodule update --init' and I recieved this error:
No submodule mapping found in .gitmodules for path 'ext/zlib' The entry I have for zlib in .gitmodules is:
[submodule "ext\\zlib"]
path = ext\\zlib
url = git://repo.or.cz/zlib.git
Is this correct? All the others entries are configured like this:
[submodule ext/git]
path = ext/git
url = git://repo.or.cz/tgit.git
Another question: Is not better to put the README inside gitbuild with the other files instead of compat/vcbuild/?
Re: [PATCH 14/14] Add README and gitignore file for MSVC build
Quoted 5 lines
[submodule "ext\\zlib"]
path = ext\\zlib
url =git://repo.or.cz/zlib.git
I fixed this problem
It should be ext/zlib
Re: [PATCH 14/14] Add README and gitignore file for MSVC build
Hi
Quoted 3 lines · Frank Li
I fixed this problem
It should be ext/zlib
Thanks!
Now when I run 'git submodule update' I recieve this error:
'fatal: Needed a single revision
Unable to find the current revision in submodule path 'ext/OpenSSL''
If the output of 'git submodule status' help, this is:
fdd0f73b9a3e7c1fdf15c2e2a52582c637ec96f1 ext/OpenSSL
+3136d3b72e199ad1484629e8ff4563a918cad953 ext/git (remotes/origin/vcpatch) -c891963b1c9d2ffbf194b2c2283639d784fa3690 ext/libcurl -62cb93cb25e2fbdbc89f90249cd8a024afad8a94 ext/zlib
Re: [PATCH 14/14] Add README and gitignore file for MSVC build
In reply to Frank LiQuoted 2 lines · Frank Li
I update http://repo.or.cz/w/gitbuild.git.
Add create_command.bat to createcommon-cmds.h.
I just gave this script a try, but if I simply click the .bat-file, I get the following crash in sh.exe: "Unhandled exception at 0x77ba8e7c in sh.exe: 0xC0000005: Access violation writing location 0x00000014."
Here's the output I get on the console:
--->8---
C:\Users\Erik\src\git-msvc\gitbuild>setlocal
C:\Users\Erik\src\git-msvc\gitbuild>set tools=C:\Users\Erik\src\git-msvc\gitbuil d\tools
C:\Users\Erik\src\git-msvc\gitbuild>echo C:\Users\Erik\src\git-msvc\gitbuild\too ls
C:\Users\Erik\src\git-msvc\gitbuild\tools
C:\Users\Erik\src\git-msvc\gitbuild>set path=C:\Users\Erik\src\git-msvc\gitbuild \tools
C:\Users\Erik\src\git-msvc\gitbuild>cd ext\git
C:\Users\Erik\src\git-msvc\gitbuild\ext\git>sh generate-cmdlist.sh 1>common-cmd s.h
abnormal program termination
--->8---
Since the path is set to only point to the tools, my guess is that other msys installations (I've got two) shouldn't affect this, no?
I'm running Vista 64bit.
Signature · 3 lines
Erik "kusma" Faye-Lund [email protected] (+47) 986 59 656
Re: [msysGit] Re: [PATCH 14/14] Add README and gitignore file for MSVC build
In reply to Thiago FarinaThiago Farina said the following on 23.08.2009 21:29:
Quoted 5 lines
Marius, how
common-cmds.hwill be generated? In the header file says that it's generated bygenerate-cmdlist.sh, so the VS user will need to generate this file first (before compiling)?
When I tried to compile after pulling from the repository, I couldn't, so I copied it from the the msysgit.
The easiest is just do the following on the command line, provided that you have the msysgit environment available (so GNU Make etc):
make common-cmds.h
That will ensure that the file is generated correctly. After that you can build with msvc, based on the patch series.
--
.marius
Re: [PATCH 09/14] Avoid including windows.h in winansi.c for MSVC build
In reply to Marius Storm-OlsenQuoted 4 lines · Marius Storm-Olsen
From: Frank Li <[email protected]>
compat/msvc.hincludeswinsock2.hwhich conflicts withwindows.h.msvc.halso defines the oldest Windows API version required.
The first sentence sort-of makes sense; compat/msvc.h will be included by git-compat-util.h and including <windows.h> here will bring conflicting definitions, so we avoid doing so when on MSC.
The second sentence does not make any sense to me. It may be correctly stating a fact (i.e. "defines required WAPI version"), but it is unclear what relevance it has to this change to stop including <windows.h>.
Having said that, the first sentence hints me that perhaps you guys should include (conditionally only on windows but not with MSC) <windows.h> not from this file, but from git-compat-util.h?
Quoted 22 lines
Signed-off-by Frank Li <[email protected]>Signed-off-by Marius Storm-Olsen <[email protected]>--- compat/winansi.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)compat/winansi.c +2
-0@@ -2,7 +2,9 @@* Copyright 2008 Peter Harris <[email protected]> */ +#ifndef _MSC_VER#include <windows.h> +#endif #include "../git-compat-util.h" /* Signature · 1 line
1.6.3.msysgit.0.18.gef407
Re: [PATCH 09/14] Avoid including windows.h in winansi.c for MSVC build
2009/8/21 Junio C Hamano <[email protected]>:
Quoted 7 lines
Quoted 4 lines · Marius Storm-Olsen
From: Frank Li <[email protected]>
compat/msvc.hincludeswinsock2.hwhich conflicts withwindows.h.msvc.halso defines the oldest Windows API version required.
Quoted 7 lines
The first sentence sort-of makes sense;
compat/msvc.hwill be included bygit-compat-util.hand including <windows.h> here will bring conflicting definitions, so we avoid doing so when on MSC.The second sentence does not make any sense to me. It may be correctly stating a fact (i.e. "defines required WAPI version"), but it is unclear what relevance it has to this change to stop including <
windows.h>.
The way things are configured, windows.h is pulling in winsock.h. In git-compat-util.h, winsock2.h is included which has conflicting definitions of various functions and data structures.
Quoted 3 lines
Having said that, the first sentence hints me that perhaps you guys should include (conditionally only on windows but not with MSC) <
windows.h> not from this file, but fromgit-compat-util.h?
It would make sense for windows.h to be included in git-compat-util.h.
According to http://social.msdn.microsoft.com/Forums/en-US/windowssdk/thread/4a90b143-1fb8-43e9-a54c-956127e0c579,
the following will work:
#define _WINSOCKAPI_ // stops windows.h including winsock.h
#include <winsock2.h>
#include <windows.h>
Also, if you define WIN32_LEAN_AND_MEAN, windows.h will pull in a subset of the Windows header files (which also improves compilation times). Adding this may prevent it from pulling in winsock.h. This would be a better approach (and would make sense to go into git-compat-util.h).
I don't have access to a Windows dev box at the moment, so can't verify that this does indeed work.
- Reece
Re: [PATCH 09/14] Avoid including windows.h in winansi.c for MSVC build
Quoted 39 lines · Reece Dunn
2009/8/21 Junio C Hamano <[email protected]>:
Quoted 7 lines
Quoted 4 lines · Marius Storm-Olsen
From: Frank Li <[email protected]>
compat/msvc.hincludeswinsock2.hwhich conflicts withwindows.h.msvc.halso defines the oldest Windows API version required.Quoted 7 lines
The first sentence sort-of makes sense;
compat/msvc.hwill be included bygit-compat-util.hand including <windows.h> here will bring conflicting definitions, so we avoid doing so when on MSC.The second sentence does not make any sense to me. It may be correctly stating a fact (i.e. "defines required WAPI version"), but it is unclear what relevance it has to this change to stop including <
windows.h>.The way things are configured,
windows.his pulling inwinsock.h. Ingit-compat-util.h,winsock2.his included which has conflicting definitions of various functions and data structures.Quoted 3 lines
Having said that, the first sentence hints me that perhaps you guys should include (conditionally only on windows but not with MSC) <
windows.h> not from this file, but fromgit-compat-util.h?It would make sense for
windows.hto be included ingit-compat-util.h.According to http://social.msdn.microsoft.com/Forums/en-US/windowssdk/thread/4a90b143-1fb8-43e9-a54c-956127e0c579,
the following will work:#define _WINSOCKAPI_ // stops
windows.hincludingwinsock.h
#include <winsock2.h>
#include <windows.h>Also, if you define
WIN32_LEAN_AND_MEAN,windows.hwill pull in a subset of the Windows header files (which also improves compilation times). Adding this may prevent it from pulling inwinsock.h. This would be a better approach (and would make sense to go intogit-compat-util.h).
Quoted 5 lines
I don't have access to a Windows dev box at the moment, so can't verify that this does indeed work.
- Reece
I'll check this on Monday, and send out a v3 of the series, incorporating the pieces commented on, and clarifying some of the still confusing commit msgs.
--
.marius
Re: [PATCH 08/14] Test for WIN32 instead of __MINGW32_
In reply to Marius Storm-OlsenSince you are doing this, you may as well change patch 3 from
+#if (defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ < 4) || defined(_MSC_VER)
to this:
#if defined WIN32 && (!defined (__GNUC__) || __GNUC__ < 4))
Paolo
Re: [msysGit] [PATCH 07/14] Fix __stdcall/WINAPI placement and function prototype
In reply to Marius Storm-Olsenrun-command.c int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const · line 322
Quoted 5 lines · Marius Storm-Olsen
run-command.c +2
-2-static __stdcall unsigned ticktack(void *dummy) +static unsigned WINAPI ticktack(void *dummy) -static __stdcall unsigned run_thread(void *data) +static unsigned WINAPI run_thread(void *data)
These two are not nice. As I said in an earlier mail: The documentation says that the thread function pointer that is passed to _beginthreadex must have __stdcall calling convention. Therefore, you should not change these to WINAPI.
-- Hannes
Re: [msysGit] [PATCH 07/14] Fix __stdcall/WINAPI placement and function prototype
Johannes Sixt said the following on 21.08.2009 19:37:
Quoted 11 lines · Marius Storm-Olsen
run-command.c int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const · line 322
Quoted 5 lines
run-command.c +2
-2-static __stdcall unsigned ticktack(void *dummy) +static unsigned WINAPI ticktack(void *dummy) -static __stdcall unsigned run_thread(void *data) +static unsigned WINAPI run_thread(void *data)These two are not nice. As I said in an earlier mail: The documentation says that the thread function pointer that is passed to
_beginthreadexmust have__stdcallcalling convention. Therefore, you should not change these to WINAPI.
WINAPI is just a define for __stdcall (since _MSC_VER >= 800 anyways; VC 6.0 being _MSC_VER == 1200), and won't change.
So, IMO the change is not bad, and makes things less convoluted by using the same convention all over.
(And _beginthreadex actually accepts both __stdcall and __clrcall calling conventions.)
--
.marius