Commit 840fb8b7cb13069c2c5f691beb30c8039b384526

Ramsay Jones 2009-02-18T18:53:48

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>

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)