NetBSD-Users archive

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

Re: mmap and MAP_FIXED



In article <20160512093311.GD19334%mail.duskware.de@localhost>,
Martin Husemann  <martin%duskware.de@localhost> wrote:
>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.

Can't MAP_ALIGNED(n) be used to avoid this mess? You probably need a different
argument depending on _LP64 or not, but that should be it... This could avoid
using MAP_FIXED.

christos



Home | Main Index | Thread Index | Old Index