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.20 by gbeauche, 2005-06-20T03:54:46Z vs.
Revision 1.21 by gbeauche, 2006-02-26T23:45:07Z

# Line 274 | Line 274 | void * vm_acquire(size_t size, int optio
274  
275                  if (ftruncate(fd, size) < 0)
276                          return VM_MAP_FAILED;
277
278                the_map_flags |= MAP_SHARED;
277          }
278   #endif
279  
# Line 344 | Line 342 | int vm_acquire_fixed(void * addr, size_t
342                  return -1;
343   #else
344   #ifdef HAVE_MMAP_VM
345 <        const int extra_map_flags = translate_map_flags(options);
345 >        int fd = zero_fd;
346 >        int the_map_flags = translate_map_flags(options) | map_flags | MAP_FIXED;
347 >
348 > #ifdef USE_33BIT_ADDRESSING
349 >        const char *shm_file = NULL;
350 >        if (sizeof(void *) == 8 && (options & VM_MAP_33BIT)) {
351 >                the_map_flags &= ~(MAP_PRIVATE | MAP_ANON | MAP_ANONYMOUS);
352 >                the_map_flags |= MAP_SHARED;
353  
354 <        if (mmap((caddr_t)addr, size, VM_PAGE_DEFAULT, extra_map_flags | map_flags | MAP_FIXED, zero_fd, 0) == (void *)MAP_FAILED)
354 >                if ((shm_file = build_shm_filename()) == NULL)
355 >                        return -1;
356 >
357 >                if ((fd = shm_open(shm_file, O_RDWR | O_CREAT | O_EXCL, 0644)) < 0)
358 >                        return -1;
359 >
360 >                if (ftruncate(fd, size) < 0)
361 >                        return -1;
362 >        }
363 > #endif
364 >
365 >        if (mmap((caddr_t)addr, size, VM_PAGE_DEFAULT, the_map_flags, fd, 0) == (void *)MAP_FAILED)
366                  return -1;
367          
368          // Since I don't know the standard behavior of mmap(), zero-fill here
369          if (memset(addr, 0, size) != addr)
370                  return -1;
371 +
372 +        // Remap to 33-bit space
373 + #ifdef USE_33BIT_ADDRESSING
374 +        if (sizeof(void *) == 8 && (options & VM_MAP_33BIT)) {
375 +                if (!add_shm_range(strdup(shm_file), addr, size))
376 +                        return -1;
377 +
378 +                if (mmap((char *)addr + (1L << 32), size, VM_PAGE_DEFAULT, the_map_flags, fd, 0) == (void *)MAP_FAILED)
379 +                        return -1;
380 +                close(fd);
381 +        }
382 + #endif
383   #else
384   #ifdef HAVE_WIN32_VM
385          // Windows cannot allocate Low Memory

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines