mmap: Reinstate passing MADV_MERGEABLE on private anonymous maps
Reinstate mmap calling madvise(MADV_MERGEABLE) removed in 635df850e5037be5093f64a87ec2e0a23bf7a50b (cherry-pick of c702a904679a36511bead29c51eeac15d81f4fd2.) Change-Id: I18803fb54701b2b3d8186dff5c678211ee3efa1f
This commit is contained in:
parent
2cf5a6f662
commit
e459bba398
@ -34,10 +34,17 @@ extern void* __mmap2(void*, size_t, int, int, int, size_t);
|
||||
#define MMAP2_SHIFT 12
|
||||
void* mmap(void *addr, size_t size, int prot, int flags, int fd, long offset)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
if (offset & ((1UL << MMAP2_SHIFT)-1)) {
|
||||
errno = EINVAL;
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
return __mmap2(addr, size, prot, flags, fd, (size_t)offset >> MMAP2_SHIFT);
|
||||
ret = __mmap2(addr, size, prot, flags, fd, (size_t)offset >> MMAP2_SHIFT);
|
||||
|
||||
if (ret && (flags & (MAP_PRIVATE | MAP_ANONYMOUS)))
|
||||
madvise(ret, size, MADV_MERGEABLE);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user