win32: fixup some headers to improve win32 compilation Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
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
diff --git a/src/common.h b/src/common.h
index 798d197..14dc301 100644
--- a/src/common.h
+++ b/src/common.h
@@ -1,6 +1,10 @@
#ifndef INCLUDE_common_h__
#define INCLUDE_common_h__
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
+#define GIT_WIN32 1
+#endif
+
#include "git/thread-utils.h"
#ifdef GIT_HAS_PTHREAD
@@ -11,9 +15,26 @@
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
-#include <unistd.h>
+#include <stdio.h>
#include <string.h>
+#include <sys/types.h>
+
+#ifdef GIT_WIN32
+
+# include <io.h>
+# include <winsock2.h>
+
+typedef int ssize_t;
+
+#else
+
+# include <unistd.h>
+# include <sys/mman.h>
+# include <arpa/inet.h>
+
+#endif
+
#include "cc-compat.h"
#include "git/common.h"
#include "util.h"
diff --git a/src/fileops.c b/src/fileops.c
index 1f8435d..c7f0591 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -1,6 +1,5 @@
#include "common.h"
#include "fileops.h"
-#include <sys/mman.h>
int gitfo_open(const char *path, int flags)
{
diff --git a/src/fileops.h b/src/fileops.h
index f0374c8..963dd0f 100644
--- a/src/fileops.h
+++ b/src/fileops.h
@@ -10,14 +10,9 @@
#define _FILE_OFFSET_BITS 64
#include "common.h"
-#include <errno.h>
-#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <sys/types.h>
#include <time.h>
-#include <stdlib.h>
-#include <string.h>
#include <dirent.h>
#define GITFO_BUF_INIT {NULL, 0}
diff --git a/src/odb.c b/src/odb.c
index 2ca59d5..11fd982 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -28,8 +28,6 @@
#include "git/zlib.h"
#include "fileops.h"
#include "hash.h"
-#include <arpa/inet.h>
-#include <stdio.h>
#include "odb.h"
#define GIT_PACK_NAME_MAX (5 + 40 + 1)