aboutsummaryrefslogtreecommitdiff
path: root/compat/win32mmap.c
Commit message (Collapse)AuthorAge
* mmap(win32): avoid expensive fstat() callJohannes Schindelin2016-04-22
| | | | | | | | | | | | | On Windows, we have to emulate the fstat() call to fill out information that takes extra effort to obtain, such as the file permissions/type. If all we want is the file size, we can use the much cheaper GetFileSizeEx() function (available since Windows XP). Suggested by Philip Kelley. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mmap(win32): avoid copy-on-write when it is unnecessaryJohannes Schindelin2016-04-22
| | | | | | | | | | | | Often we are mmap()ing read-only. In those cases, it is wasteful to map in copy-on-write mode. Even worse: it can cause errors where we run out of space in the page file. So let's be extra careful to map files in read-only mode whenever possible. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* win32mmap: set errno appropriatelyJohannes Schindelin2016-04-22
| | | | | | | | | | | | | | | | | | | | | It is not really helpful when a `git fetch` fails with the message: fatal: mmap failed: No error In the particular instance encountered by a colleague of yours truly, the Win32 error code was ERROR_COMMITMENT_LIMIT which means that the page file is not big enough. Let's make the message fatal: mmap failed: File too large instead, which is only marginally better, but which can be associated with the appropriate work-around: setting `core.packedGitWindowSize` to a relatively small value. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* compat/win32mmap.c: Fix some sparse warningsRamsay Jones2013-04-28
| | | | | | | | | | | Sparse issues two 'Using plain integer as NULL pointer' warnings against the call to the CreateFileMapping() function. The warnings relate to the second and sixth parameters, which both have pointer type. In order to suppress the warnings, we simply pass the NULL pointer, rather than '0', to those parameters in the function call. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* remove superfluous newlines in error messagesPete Wyckoff2012-04-30
| | | | | | | | The error handling routines add a newline. Remove the duplicate ones in error messages. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix "Out of memory? mmap failed" for files larger than 4GB on WindowsIan McLean2010-05-20
| | | | | | | | | The git_mmap implementation was broken for file sizes that wouldn't fit into a size_t (32 bits). This was caused by intermediate variables that were only 32 bits wide when they should be 64 bits. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* MSVC: Add support for building with NO_MMAPRamsay Jones2009-11-08
| | | | | | | | | | | | | When the NO_MMAP build variable is set, the msvc linker complains: error LNK2001: unresolved external symbol _getpagesize The msvc libraries do not define the getpagesize() function, so we move the mingw_getpagesize() implementation from the conditionally built win32mmap.c file to mingw.c. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* MinGW: implement mmapJanos Laube2009-03-18
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 <janos.dev@gmail.com> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>