support for win32 mmap
commit7e5a4c563667d011c0655679be3190461884a78e
authorJanos Laube <janos.dev@gmail.com>
Sat, 7 Mar 2009 02:54:10 +0000 (7 03:54 +0100)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 20 Mar 2009 10:49:02 +0000 (20 11:49 +0100)
treef13825d16a862c143eee4d610c4d473e7bde9670
parentc43fb7fe2367a1b3a8ba76cf66212aa517a46e2d
support for win32 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 which 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 filecontent 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 <janos.dev@gmail.com>
Makefile
compat/mingw.h
compat/win32mmap.c [new file with mode: 0644]
git-compat-util.h