win32: Add separate MinGW and MSVC compatability header files Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
diff --git a/src/common.h b/src/common.h
index 29a61a7..18c321c 100644
--- a/src/common.h
+++ b/src/common.h
@@ -32,43 +32,13 @@
# include <io.h>
# include <direct.h>
# include <windows.h>
+# include "msvc-compat.h"
+# include "mingw-compat.h"
# define snprintf _snprintf
-# if defined(__DMC__)
-# if defined(_M_AMD64)
-# define SSIZE_T long long
-# else
-# define SSIZE_T int
-# endif
-# endif
-
typedef SSIZE_T ssize_t;
-# if defined(_MSC_VER)
-/* access() mode parameter #defines */
-# define F_OK 0 /* existence check */
-# define W_OK 2 /* write mode check */
-# define R_OK 4 /* read mode check */
-# endif
-
-#if defined(__MINGW32__)
-
-# define off_t off64_t
-# define lseek _lseeki64
-# define stat _stati64
-# define fstat _fstati64
-
-#elif defined(_MSC_VER)
-
-typedef __int64 off64_t;
-# define off_t off64_t
-# define lseek _lseeki64
-# define stat _stat64
-# define fstat _fstat64
-
-#endif
-
#else
# include <unistd.h>
@@ -83,13 +53,4 @@ typedef __int64 off64_t;
#define GIT_PATH_MAX 4096
-#ifndef GIT_HAVE_INTTYPES_H
-/* add some missing <stdint.h> typedef's */
-typedef long int32_t;
-typedef unsigned long uint32_t;
-
-typedef long long int64_t;
-typedef unsigned long long uint64_t;
-#endif
-
#endif /* INCLUDE_common_h__ */
diff --git a/src/mingw-compat.h b/src/mingw-compat.h
new file mode 100644
index 0000000..e3805df
--- /dev/null
+++ b/src/mingw-compat.h
@@ -0,0 +1,14 @@
+#ifndef INCLUDE_mingw_compat__
+#define INCLUDE_mingw_compat__
+
+#if defined(__MINGW32__)
+
+/* use a 64-bit file offset type */
+# define off_t off64_t
+# define lseek _lseeki64
+# define stat _stati64
+# define fstat _fstati64
+
+#endif
+
+#endif /* INCLUDE_mingw_compat__ */
diff --git a/src/msvc-compat.h b/src/msvc-compat.h
new file mode 100644
index 0000000..62ab0af
--- /dev/null
+++ b/src/msvc-compat.h
@@ -0,0 +1,41 @@
+#ifndef INCLUDE_msvc_compat__
+#define INCLUDE_msvc_compat__
+
+#if defined(_MSC_VER)
+
+/* access() mode parameter #defines */
+# define F_OK 0 /* existence check */
+# define W_OK 2 /* write mode check */
+# define R_OK 4 /* read mode check */
+
+/* use a 64-bit file offset type */
+typedef __int64 off64_t;
+# define off_t off64_t
+# define lseek _lseeki64
+# define stat _stat64
+# define fstat _fstat64
+
+/* stat: file mode type testing macros */
+# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
+# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
+# define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
+
+/* add some missing <stdint.h> typedef's */
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
+
+typedef short int16_t;
+typedef unsigned short uint16_t;
+
+typedef long int32_t;
+typedef unsigned long uint32_t;
+
+typedef long long int64_t;
+typedef unsigned long long uint64_t;
+
+typedef long long intmax_t;
+typedef unsigned long long uintmax_t;
+
+#endif
+
+#endif /* INCLUDE_msvc_compat__ */