git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frank Li <lznuaa@gmail.com>
To: git@vger.kernel.org, msysgit@googlegroups.com
Cc: Frank Li <lznuaa@gmail.com>
Subject: [PATCH 08/12] Add MSVC porting files.
Date: Wed, 19 Aug 2009 23:52:43 +0800	[thread overview]
Message-ID: <1250697167-5536-8-git-send-email-lznuaa@gmail.com> (raw)
In-Reply-To: <1250697167-5536-7-git-send-email-lznuaa@gmail.com>

Add msvc.c and msvc.h to build git under MSVC

Signed-off-by: Frank Li <lznuaa@gmail.com>
---
 compat/msvc.c |   33 ++++++++++++++++++++++
 compat/msvc.h |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 119 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..80afd4d
--- /dev/null
+++ b/compat/msvc.c
@@ -0,0 +1,33 @@
+#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;
+}
diff --git a/compat/msvc.h b/compat/msvc.h
new file mode 100644
index 0000000..76cc6e5
--- /dev/null
+++ b/compat/msvc.h
@@ -0,0 +1,86 @@
+#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>
+
+/*Configuration*/
+#define NO_PREAD
+#define NO_OPENSSL
+#define NO_LIBGEN_H
+#define NO_SYMLINK_HEAD
+#define NO_IPV6
+#define NO_SETENV
+#define NO_UNSETENV
+#define NO_STRCASESTR
+#define NO_STRLCPY
+#define NO_MEMMEM
+#define NO_C99_FORMAT
+#define NO_STRTOUMAX
+#define NO_MKDTEMP
+#define NO_MKSTEMPS
+#define NO_ST_BLOCKS_IN_STRUCT_STAT
+#define NO_NSEC
+#define NO_REGEX
+#define NO_SYS_SELECT_H
+#define NO_PTHEADS
+#define NO_ICONV
+#define NO_PTHREADS
+#define NO_CURL
+#define NO_STRTOUMAX
+#define NO_STRLCPY
+#define NO_UNSETENV
+#define NO_SETENV
+
+#define USE_WIN32_MMAP
+#define USE_NED_ALLOCATOR
+#define HAVE_STRING_H 1
+#define STDC_HEADERS
+#define SNPRINTF_RETURNS_BOGUS
+#define RUNTIME_PREFIX
+#define REGEX_MALLOC
+
+/*Git runtime infomation*/
+#define ETC_GITCONFIG "%HOME%"
+#define SHA1_HEADER "mozilla-sha1\\sha1.h"
+#define GIT_EXEC_PATH "bin"
+#define GIT_VERSION "1.6"
+#define BINDIR "bin"
+#define PREFIX "."
+#define GIT_MAN_PATH "man"
+#define GIT_INFO_PATH "info"
+#define GIT_HTML_PATH "html"
+#define DEFAULT_GIT_TEMPLATE_DIR "templates"
+
+/*porting function*/
+#define strdup _strdup
+#define read _read
+#define close _close
+#define dup _dup
+#define dup2 _dup2
+#define strncasecmp _strnicmp
+#define strtoull _strtoui64
+#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);
+}
+
+#include "compat/mingw.h"
+#undef ERROR
+#undef stat
+#define stat(x,y) mingw_lstat(x,y)
+#define stat      _stat64
+#endif
\ No newline at end of file
-- 
1.6.4.msysgit.0

  reply	other threads:[~2009-08-19 15:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-19 15:52 [PATCH 01/12] Avoid declaration after instruction Frank Li
2009-08-19 15:52 ` [PATCH 02/12] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++ Frank Li
2009-08-19 15:52   ` [PATCH 03/12] Using macro WIN32 replace __MINGW32_ at Windows special handler The code which is conditional on MinGW32 is actually conditional on Windows. Use WIN32 macro will share both MINGW32 and MSVC environment Frank Li
2009-08-19 15:52     ` [PATCH 04/12] mingw.c: Use the O_BINARY flag to open files Frank Li
2009-08-19 15:52       ` [PATCH 05/12] Place __stdcall between return value and function name Frank Li
2009-08-19 15:52         ` [PATCH 06/12] Add _MSC_VER in porting head file git-compat-util.h Frank Li
2009-08-19 15:52           ` [PATCH 07/12] Add Unix header files to build git at MSVC Frank Li
2009-08-19 15:52             ` Frank Li [this message]
2009-08-19 15:52               ` [PATCH 09/12] Don't include windows.h at winansi.c at MSVC build Frank Li
2009-08-19 15:52                 ` [PATCH 10/12] Fix errcode have defined as int at MSVC Frank Li
2009-08-19 15:52                   ` [PATCH 11/12] Add MSVC Project file Frank Li
2009-08-19 15:59               ` [PATCH 08/12] Add MSVC porting files 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

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

  git send-email \
    --in-reply-to=1250697167-5536-8-git-send-email-lznuaa@gmail.com \
    --to=lznuaa@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=msysgit@googlegroups.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 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 NNTP newsgroup(s).