Implement mremap(2) usage on NetBSD
The NetBSD version of mremap takes additional argument "newp" to hint
new position of a mapped range.
void *
mremap(void *oldp, size_t oldsize, void *newp, size_t newsize,
int flags);
-- NetBSD's mremap(2)
While Linux by default sets old_address and fails if the resize
operation cannot be finished for the original address.
void *mremap(void *old_address, size_t old_size,
size_t new_size, int flags, ... /* void *new_address */);
-- Linux's mremap(2)
NetBSD offers inversed logic with the MAP_FIXED flag to Linux's MREMAP_MAYMOVE:
MAP_FIXED newp is tried and mremap() fails if that address can't
be used as new base address for the range. Otherwise,
oldp and newp are used as hints for the position,
factoring in the given alignment.
-- NetBSD's mremap(2)
MREMAP_MAYMOVE
By default, if there is not sufficient space to expand a mapping
at its current location, then mremap() fails. If this flag is
specified, then the kernel is permitted to relocate the
mapping to a new virtual address, if necessary. If the mapping
is relocated, then absolute pointers into the old mapping
location become invalid (offsets relative to the starting address
of the mapping should be employed).
-- Linux's mremap(2)
The thing that bothers is calling mremap(2) syntax from Linux "posix", but we
cannot do anything with it, for now just simulate the Linux behavior on NetBSD.