Merge "mmap: fix calculation of is_private_anonymous variable"
am: 43c9045017
* commit '43c90450174ab8839c05702ac01c4092f5b6cd19':
mmap: fix calculation of is_private_anonymous variable
This commit is contained in:
commit
cb3af215dc
1 changed files with 6 additions and 2 deletions
|
@ -54,10 +54,14 @@ void* mmap64(void* addr, size_t size, int prot, int flags, int fd, off64_t offse
|
|||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
bool is_private_anonymous = (flags & (MAP_PRIVATE | MAP_ANONYMOUS)) != 0;
|
||||
bool is_private_anonymous =
|
||||
(flags & (MAP_PRIVATE | MAP_ANONYMOUS)) == (MAP_PRIVATE | MAP_ANONYMOUS);
|
||||
bool is_stack_or_grows_down = (flags & (MAP_STACK | MAP_GROWSDOWN)) != 0;
|
||||
|
||||
void* result = __mmap2(addr, size, prot, flags, fd, offset >> MMAP2_SHIFT);
|
||||
|
||||
if (result != MAP_FAILED && kernel_has_MADV_MERGEABLE && is_private_anonymous) {
|
||||
if (result != MAP_FAILED && kernel_has_MADV_MERGEABLE &&
|
||||
is_private_anonymous && !is_stack_or_grows_down) {
|
||||
ErrnoRestorer errno_restorer;
|
||||
int rc = madvise(result, size, MADV_MERGEABLE);
|
||||
if (rc == -1 && errno == EINVAL) {
|
||||
|
|
Loading…
Reference in a new issue