Commit 0ab0232d authored by Simon Marlow's avatar Simon Marlow
Browse files

mmap() errors on Darwin: use errorBelch/exit instead of barf()

The most likely cause is out-of-memory, not an RTS error.
parent 04c0256a
...@@ -181,10 +181,14 @@ my_mmap (void *addr, lnat size) ...@@ -181,10 +181,14 @@ my_mmap (void *addr, lnat size)
if(!addr || err) // try to allocate anywhere if(!addr || err) // try to allocate anywhere
err = vm_allocate(mach_task_self(),(vm_address_t*) &ret, size, TRUE); err = vm_allocate(mach_task_self(),(vm_address_t*) &ret, size, TRUE);
if(err) // don't know what the error codes mean exactly if(err) {
barf("memory allocation failed (requested %lu bytes)", size); // don't know what the error codes mean exactly, assume it's
else // not our problem though.
errorBelch("memory allocation failed (requested %lu bytes)", size);
stg_exit(EXIT_FAILURE);
} else {
vm_protect(mach_task_self(),ret,size,FALSE,VM_PROT_READ|VM_PROT_WRITE); vm_protect(mach_task_self(),ret,size,FALSE,VM_PROT_READ|VM_PROT_WRITE);
}
#else #else
ret = mmap(addr, size, PROT_READ | PROT_WRITE | PROT_EXEC, ret = mmap(addr, size, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_ANON | MAP_PRIVATE, -1, 0); MAP_ANON | MAP_PRIVATE, -1, 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment