ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/vm_alloc.cpp
(Generate patch)

Comparing BasiliskII/src/Unix/vm_alloc.cpp (file contents):
Revision 1.34 by asvitkine, 2011-12-31T19:47:16Z vs.
Revision 1.35 by asvitkine, 2012-01-01T22:32:24Z

# Line 294 | Line 294 | int vm_acquire_fixed(void * addr, size_t
294                  return -1;
295   #endif
296  
297 < #ifdef HAVE_MACH_VM
297 > #if defined(HAVE_MACH_VM)
298          // vm_allocate() returns a zero-filled memory region
299          kern_return_t ret_code = vm_allocate(mach_task_self(), (vm_address_t *)&addr, size, 0);
300          if (ret_code != KERN_SUCCESS) {
301                  errno = vm_error(ret_code);
302                  return -1;
303          }
304 < #else
305 < #ifdef HAVE_MMAP_VM
304 > #elif defined(HAVE_MMAP_VM)
305          int fd = zero_fd;
306          int the_map_flags = translate_map_flags(options) | map_flags | MAP_FIXED;
307  
308          if (mmap((caddr_t)addr, size, VM_PAGE_DEFAULT, the_map_flags, fd, 0) == (void *)MAP_FAILED)
309                  return -1;
310 < #else
312 < #ifdef HAVE_WIN32_VM
310 > #elif defined(HAVE_WIN32_VM)
311          // Windows cannot allocate Low Memory
312          if (addr == NULL)
313                  return -1;
# Line 328 | Line 326 | int vm_acquire_fixed(void * addr, size_t
326          // Unsupported
327          return -1;
328   #endif
329 < #endif
332 < #endif
333 <        
329 >
330          // Explicitely protect the newly mapped region here because on some systems,
331          // say MacOS X, mmap() doesn't honour the requested protection flags.
332          if (vm_protect(addr, size, VM_PAGE_DEFAULT) != 0)
333                  return -1;
334 <        
334 >
335          return 0;
336   }
337  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines