path: root/compat/mingw.h
diff options
authorJanos Laube <>2009-03-13 15:50:45 (GMT)
committerJunio C Hamano <>2009-03-19 02:23:04 (GMT)
commitb130a72b274441bb5d687de93efef4d990c40c0a (patch)
tree094a2c29c15061b4124cde258dd6de3be8f254eb /compat/mingw.h
parent1c192f3442414a6ce83f9a524806fc26a0861d2d (diff)
MinGW: implement mmap
Add USE_WIN32_MMAP which triggers the use of windows' native file memory mapping functionality in git_mmap()/git_munmap() functions. As git functions currently use mmap with MAP_PRIVATE set only, this implementation supports only that mode for now. On Windows, offsets for memory mapped files need to match the allocation granularity. Take this into account when calculating the packed git- windowsize and file offsets. At the moment, the only function which makes use of offsets in conjunction with mmap is use_pack() in sha1-file.c. Git fast-import's code path tries to map a portion of the temporary packfile that exceeds the current filesize, i.e. offset+length is greater than the filesize. The NO_MMAP code worked with that since pread() just reads the file content until EOF and returns gracefully, while MapViewOfFile() aborts the mapping and returns 'Access Denied'. Working around that by determining the filesize and adjusting the length parameter. Signed-off-by: Janos Laube <> Signed-off-by: Johannes Sixt <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'compat/mingw.h')
1 files changed, 5 insertions, 0 deletions
diff --git a/compat/mingw.h b/compat/mingw.h
index 7e52f36..762eb14 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -159,6 +159,11 @@ int mingw_connect(int sockfd, struct sockaddr *sa, size_t sz);
int mingw_rename(const char*, const char*);
#define rename mingw_rename
+#ifdef USE_WIN32_MMAP
+int mingw_getpagesize(void);
+#define getpagesize mingw_getpagesize
/* Use mingw_lstat() instead of lstat()/stat() and
* mingw_fstat() instead of fstat() on Windows.