Add platform files for porting to MSVC
[git/git.git] / compat / msvc.h
1 #ifndef __MSVC__HEAD
2 #define __MSVC__HEAD
3
4 /* Define minimize windows version */
5 #define WINVER 0x0500
6 #define _WIN32_WINNT 0x0500
7 #define _WIN32_WINDOWS 0x0410
8 #define _WIN32_IE 0x0700
9 #define NTDDI_VERSION NTDDI_WIN2KSP1
10 #include <winsock2.h>
11 #include <direct.h>
12 #include <process.h>
13 #include <malloc.h>
14
15 /* porting function */
16 #define inline __inline
17 #define __inline__ __inline
18 #define __attribute__(x)
19 #define va_copy(dst, src) ((dst) = (src))
20
21 static __inline int strcasecmp (const char *s1, const char *s2)
22 {
23 int size1 = strlen(s1);
24 int sisz2 = strlen(s2);
25 return _strnicmp(s1, s2, sisz2 > size1 ? sisz2 : size1);
26 }
27
28 #undef ERROR
29 #undef stat
30 #undef _stati64
31 #include "compat/mingw.h"
32 #undef stat
33 #define stat _stati64
34 #define _stat64(x,y) mingw_lstat(x,y)
35
36 /*
37 Even though _stati64 is normally just defined at _stat64
38 on Windows, we specify it here as a proper struct to avoid
39 compiler warnings about macro redefinition due to magic in
40 mingw.h. Struct taken from ReactOS (GNU GPL license).
41 */
42 struct _stati64 {
43 _dev_t st_dev;
44 _ino_t st_ino;
45 unsigned short st_mode;
46 short st_nlink;
47 short st_uid;
48 short st_gid;
49 _dev_t st_rdev;
50 __int64 st_size;
51 time_t st_atime;
52 time_t st_mtime;
53 time_t st_ctime;
54 };
55 #endif