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