236 |
|
return VM_MAP_FAILED; |
237 |
|
#endif |
238 |
|
|
239 |
< |
#ifdef HAVE_MACH_VM |
239 |
> |
#if defined(HAVE_MACH_VM) |
240 |
|
// vm_allocate() returns a zero-filled memory region |
241 |
|
kern_return_t ret_code = vm_allocate(mach_task_self(), (vm_address_t *)&addr, size, TRUE); |
242 |
|
if (ret_code != KERN_SUCCESS) { |
243 |
|
errno = vm_error(ret_code); |
244 |
|
return VM_MAP_FAILED; |
245 |
|
} |
246 |
< |
#else |
247 |
< |
#ifdef HAVE_MMAP_VM |
246 |
> |
#elif defined(HAVE_MMAP_VM) |
247 |
|
int fd = zero_fd; |
248 |
|
int the_map_flags = translate_map_flags(options) | map_flags; |
249 |
|
|
255 |
|
return VM_MAP_FAILED; |
256 |
|
|
257 |
|
next_address = (char *)addr + size; |
258 |
< |
#else |
260 |
< |
#ifdef HAVE_WIN32_VM |
258 |
> |
#elif defined(HAVE_WIN32_VM) |
259 |
|
int alloc_type = MEM_RESERVE | MEM_COMMIT; |
260 |
|
if (options & VM_MAP_WRITE_WATCH) |
261 |
|
alloc_type |= MEM_WRITE_WATCH; |
269 |
|
// Omit changes for protections because they are not supported in this mode |
270 |
|
return addr; |
271 |
|
#endif |
274 |
– |
#endif |
275 |
– |
#endif |
272 |
|
|
273 |
|
// Explicitely protect the newly mapped region here because on some systems, |
274 |
|
// say MacOS X, mmap() doesn't honour the requested protection flags. |