1 #include "../git-compat-util.h"
4 * Note that this doesn't return the actual pagesize, but
5 * the allocation granularity. If future Windows specific git code
6 * needs the real getpagesize function, we need to find another solution.
8 int mingw_getpagesize(void)
12 return si
.dwAllocationGranularity
;
15 void *git_mmap(void *start
, size_t length
, int prot
, int flags
, int fd
, off_t offset
)
22 uint32_t l
= o
& 0xFFFFFFFF;
23 uint32_t h
= (o
>> 32) & 0xFFFFFFFF;
26 len
= xsize_t(st
.st_size
);
28 die("mmap: could not determine filesize");
30 if ((length
+ offset
) > len
)
31 length
= len
- offset
;
33 if (!(flags
& MAP_PRIVATE
))
34 die("Invalid usage of mmap when built with USE_WIN32_MMAP");
36 hmap
= CreateFileMapping((HANDLE
)_get_osfhandle(fd
), 0, PAGE_WRITECOPY
,
42 temp
= MapViewOfFileEx(hmap
, FILE_MAP_COPY
, h
, l
, length
, start
);
44 if (!CloseHandle(hmap
))
45 warning("unable to close file mapping handle\n");
47 return temp
? temp
: MAP_FAILED
;
50 int git_munmap(void *start
, size_t length
)
52 return !UnmapViewOfFile(start
);