NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: mmap and MAP_FIXED



Here is an excerpt from example code that is known to work:

/* For various ports, try to guess a fixed spot in the vm space
   that's probably free.  */
#if defined(__sparc64__)
# define TRY_EMPTY_VM_SPACE    0x40000000000
#elif defined(_LP64)
# define TRY_EMPTY_VM_SPACE    0x400000000000
#elif defined(__mips__) || defined(__vax__) || defined (__arm__)
# define TRY_EMPTY_VM_SPACE    0x60000000
#else
# define TRY_EMPTY_VM_SPACE    0xb0000000
#endif

  addr = mmap ((void *) TRY_EMPTY_VM_SPACE, size, PROT_READ | PROT_WRITE,
              MAP_PRIVATE | MAP_FIXED, fd, 0);


And size is allowed to be smaller than the page size.

Martin


Home | Main Index | Thread Index | Old Index