From: Frank Li <lznuaa@xxxxxxxxx> Add msvc.c and msvc.h to build git under MSVC Signed-off-by: Frank Li <lznuaa@xxxxxxxxx> Signed-off-by: Marius Storm-Olsen <mstormo@xxxxxxxxx> --- 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 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..3e22186 --- /dev/null +++ b/compat/msvc.h @@ -0,0 +1,102 @@ +#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> + +/* 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 "block-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 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.3.msysgit.0.18.gef407 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html