From: Marius Storm-Olsen <mstormo@gmail.com>
To: git@vger.kernel.org
Cc: Johannes.Schindelin@gmx.de, msysgit@googlegroups.com,
gitster@pobox.com, j6t@kdbg.org, lznuaa@gmail.com,
raa.lkml@gmail.com, snaury@gmail.com,
Marius Storm-Olsen <mstormo@gmail.com>
Subject: [PATCH 09/15] Add platform files for MSVC porting
Date: Wed, 16 Sep 2009 10:20:25 +0200 [thread overview]
Message-ID: <489a0e7c6c41985a5208e85e9b24900c97dcacdb.1253088099.git.mstormo@gmail.com> (raw)
In-Reply-To: <7afd55f9b2f0f7859f757c715034cc3520e07f0e.1253088099.git.mstormo@gmail.com>
In-Reply-To: <cover.1253088099.git.mstormo@gmail.com>
From: Frank Li <lznuaa@gmail.com>
Add msvc.c and msvc.h to build git under MSVC
Signed-off-by: Frank Li <lznuaa@gmail.com>
Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com>
---
compat/msvc.c | 35 +++++++++++++++++++++++++++++++++
compat/msvc.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
git-compat-util.h | 3 ++
3 files changed, 93 insertions(+), 0 deletions(-)
create mode 100644 compat/msvc.c
create mode 100644 compat/msvc.h
diff --git a/compat/msvc.c b/compat/msvc.c
new file mode 100644
index 0000000..ac04a4c
--- /dev/null
+++ b/compat/msvc.c
@@ -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"
diff --git a/compat/msvc.h b/compat/msvc.h
new file mode 100644
index 0000000..6daf313
--- /dev/null
+++ b/compat/msvc.h
@@ -0,0 +1,55 @@
+#ifndef __MSVC__HEAD
+#define __MSVC__HEAD
+
+/* Define minimize windows version */
+#define WINVER 0x0500
+#define _WIN32_WINNT 0x0500
+#define _WIN32_WINDOWS 0x0410
+#define _WIN32_IE 0x0700
+#define NTDDI_VERSION NTDDI_WIN2KSP1
+#include <winsock2.h>
+#include <direct.h>
+#include <process.h>
+#include <malloc.h>
+
+/* porting function */
+#define inline __inline
+#define __inline__ __inline
+#define __attribute__(x)
+#define va_copy(dst, src) ((dst) = (src))
+
+static __inline int strcasecmp (const char *s1, const char *s2)
+{
+ int size1 = strlen(s1);
+ int sisz2 = strlen(s2);
+ return _strnicmp(s1, s2, sisz2 > size1 ? sisz2 : size1);
+}
+
+#undef ERROR
+#undef stat
+#undef _stati64
+#include "compat/mingw.h"
+#undef stat
+#define stat _stati64
+#define _stat64(x,y) mingw_lstat(x,y)
+
+/*
+ Even though _stati64 is normally just defined at _stat64
+ on Windows, we specify it here as a proper struct to avoid
+ compiler warnings about macro redefinition due to magic in
+ mingw.h. Struct taken from ReactOS (GNU GPL license).
+*/
+struct _stati64 {
+ _dev_t st_dev;
+ _ino_t st_ino;
+ unsigned short st_mode;
+ short st_nlink;
+ short st_uid;
+ short st_gid;
+ _dev_t st_rdev;
+ __int64 st_size;
+ time_t st_atime;
+ time_t st_mtime;
+ time_t st_ctime;
+};
+#endif
diff --git a/git-compat-util.h b/git-compat-util.h
index e5e9f39..8ea444f 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -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>
--
1.6.2.1.418.g33d56.dirty
next prev parent reply other threads:[~2009-09-16 8:21 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-16 8:20 [PATCH v4 00/15] Build Git with MSVC Marius Storm-Olsen
2009-09-16 8:20 ` [PATCH 01/15] Avoid declaration after statement Marius Storm-Olsen
2009-09-16 8:20 ` [PATCH 02/15] Add define guards to compat/win32.h Marius Storm-Olsen
2009-09-16 8:20 ` [PATCH 03/15] Change regerror() declaration from K&R style to ANSI C (C89) Marius Storm-Olsen
2009-09-16 8:20 ` [PATCH 04/15] Set _O_BINARY as default fmode for both MinGW and MSVC Marius Storm-Olsen
2009-09-16 8:20 ` [PATCH 05/15] Fix __stdcall placement and function prototype Marius Storm-Olsen
2009-09-16 8:20 ` [PATCH 06/15] Test for WIN32 instead of __MINGW32_ Marius Storm-Olsen
2009-09-16 8:20 ` [PATCH 07/15] Add empty header files for MSVC port Marius Storm-Olsen
2009-09-16 8:20 ` [PATCH 08/15] Add MinGW header files to build git with MSVC Marius Storm-Olsen
2009-09-16 8:20 ` Marius Storm-Olsen [this message]
2009-09-16 8:20 ` [PATCH 10/15] Make usage of windows.h lean and mean Marius Storm-Olsen
2009-09-16 8:20 ` [PATCH 11/15] Define strncasecmp and ftruncate for MSVC Marius Storm-Olsen
2009-09-16 8:20 ` [PATCH 12/15] Add MSVC to Makefile Marius Storm-Olsen
2009-09-16 8:20 ` [PATCH 13/15] Add README for MSVC build Marius Storm-Olsen
2009-09-16 8:20 ` [PATCH 14/15] Add scripts to generate projects for other buildsystems (MSVC vcproj, QMake) Marius Storm-Olsen
2009-09-16 8:20 ` [RFC 15/15] Tag GIT_VERSION when Git is built with MSVC Marius Storm-Olsen
2009-09-17 20:18 ` Johannes Sixt
2009-09-18 6:44 ` Marius Storm-Olsen
2009-09-17 20:28 ` [PATCH 14/15] Add scripts to generate projects for other buildsystems (MSVC vcproj, QMake) Johannes Sixt
2009-09-18 6:59 ` Marius Storm-Olsen
2009-09-18 8:21 ` Johannes Sixt
2009-09-23 15:04 ` Sebastian Schuberth
2009-09-23 20:37 ` Johannes Schindelin
2009-09-24 6:05 ` Marius Storm-Olsen
2009-09-23 10:03 ` Add MinGW header files to build git with MSVC Sebastian Schuberth
2009-09-23 11:29 ` Marius Storm-Olsen
2009-09-25 0:18 ` [msysGit] " Frank Li
2009-09-16 16:14 ` [PATCH 04/15] Set _O_BINARY as default fmode for both MinGW and MSVC Johannes Sixt
2009-09-16 20:00 ` Alexey Borzenkov
2009-09-17 7:11 ` Johannes Sixt
2009-09-17 7:25 ` Junio C Hamano
2009-09-17 7:27 ` Marius Storm-Olsen
2009-09-17 7:36 ` Johannes Sixt
2009-09-17 7:53 ` Marius Storm-Olsen
2009-09-17 8:10 ` Johannes Sixt
2009-09-17 8:14 ` Marius Storm-Olsen
2009-09-17 8:39 ` Alexey Borzenkov
2009-09-17 8:45 ` Marius Storm-Olsen
2009-09-17 8:57 ` Alexey Borzenkov
2009-09-17 9:03 ` Johannes Sixt
2009-09-17 9:28 ` Marius Storm-Olsen
2009-09-17 13:02 ` Alexey Borzenkov
2009-09-17 13:30 ` Johannes Sixt
2009-09-17 8:02 ` Marius Storm-Olsen
2009-09-17 10:44 ` Johannes Sixt
[not found] ` <4AB212FA.9080102@viscovery.netm>
2009-09-17 11:04 ` Marius Storm-Olsen
2009-09-16 9:42 ` [msysGit] [PATCH 02/15] Add define guards to compat/win32.h Erik Faye-Lund
2009-09-16 10:10 ` Marius Storm-Olsen
2009-09-23 9:44 ` Avoid declaration after statement Sebastian Schuberth
2009-09-25 13:34 ` Erik Faye-Lund
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=489a0e7c6c41985a5208e85e9b24900c97dcacdb.1253088099.git.mstormo@gmail.com \
--to=mstormo@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
--cc=lznuaa@gmail.com \
--cc=msysgit@googlegroups.com \
--cc=raa.lkml@gmail.com \
--cc=snaury@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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).