|
@ -68,16 +68,16 @@ void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset |
|
|
dwDesiredAccess |= FILE_MAP_COPY; |
|
|
dwDesiredAccess |= FILE_MAP_COPY; |
|
|
void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length); |
|
|
void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length); |
|
|
if (ret == NULL) { |
|
|
if (ret == NULL) { |
|
|
CloseHandle(h); |
|
|
|
|
|
ret = MAP_FAILED; |
|
|
ret = MAP_FAILED; |
|
|
} |
|
|
} |
|
|
|
|
|
// since we are handling the file ourselves with fd, close the Windows Handle here
|
|
|
|
|
|
CloseHandle(h); |
|
|
return ret; |
|
|
return ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void munmap(void *addr, size_t length) |
|
|
void munmap(void *addr, size_t length) |
|
|
{ |
|
|
{ |
|
|
UnmapViewOfFile(addr); |
|
|
UnmapViewOfFile(addr); |
|
|
/* ruh-ro, we leaked handle from CreateFileMapping() ... */ |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#undef DWORD_HI |
|
|
#undef DWORD_HI |
|
|