1 #include "../git-compat-util.h"
3 void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
10 uint32_t l = o & 0xFFFFFFFF;
11 uint32_t h = (o >> 32) & 0xFFFFFFFF;
16 die("mmap: could not determine filesize");
18 if ((length + offset) > len)
19 length = xsize_t(len - offset);
21 if (!(flags & MAP_PRIVATE))
22 die("Invalid usage of mmap when built with USE_WIN32_MMAP");
24 hmap = CreateFileMapping((HANDLE)_get_osfhandle(fd), 0, PAGE_WRITECOPY,
30 temp = MapViewOfFileEx(hmap, FILE_MAP_COPY, h, l, length, start);
32 if (!CloseHandle(hmap))
33 warning("unable to close file mapping handle");
35 return temp ? temp : MAP_FAILED;
38 int git_munmap(void *start, size_t length)
40 return !UnmapViewOfFile(start);