mirror of https://github.com/inolen/redream.git
don't commit the entire 4gb address space on Windows
This commit is contained in:
parent
0d59e0baf8
commit
d9d8d14a6c
|
@ -77,12 +77,24 @@ int map_shared_memory(shmem_handle_t handle, size_t offset, void *start,
|
||||||
DWORD file_flags = access_to_file_flags(access);
|
DWORD file_flags = access_to_file_flags(access);
|
||||||
void *ptr = MapViewOfFileEx(handle, file_flags, (DWORD)(offset >> 32),
|
void *ptr = MapViewOfFileEx(handle, file_flags, (DWORD)(offset >> 32),
|
||||||
(DWORD)offset, size, start);
|
(DWORD)offset, size, start);
|
||||||
return ptr == start;
|
if (ptr != start) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* commit the pages backing the file mapping now */
|
||||||
|
DWORD protect = access_to_protection_flags(access);
|
||||||
|
ptr = VirtualAlloc(ptr, size, MEM_COMMIT, protect);
|
||||||
|
if (!ptr) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
shmem_handle_t create_shared_memory(const char *filename, size_t size,
|
shmem_handle_t create_shared_memory(const char *filename, size_t size,
|
||||||
enum page_access access) {
|
enum page_access access) {
|
||||||
DWORD protect = access_to_protection_flags(access);
|
DWORD protect = access_to_protection_flags(access);
|
||||||
return CreateFileMapping(INVALID_HANDLE_VALUE, NULL, protect | SEC_COMMIT,
|
/* note, only reserve the pages for now */
|
||||||
|
return CreateFileMapping(INVALID_HANDLE_VALUE, NULL, protect | SEC_RESERVE,
|
||||||
(DWORD)(size >> 32), (DWORD)(size), filename);
|
(DWORD)(size >> 32), (DWORD)(size), filename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ struct address_space {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* memory
|
* memory
|
||||||
a*/
|
*/
|
||||||
#define ADDRESS_SPACE_SIZE (UINT64_C(1) << 32)
|
#define ADDRESS_SPACE_SIZE (UINT64_C(1) << 32)
|
||||||
|
|
||||||
enum region_type {
|
enum region_type {
|
||||||
|
|
Loading…
Reference in New Issue