mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-27 08:29:31 -05:00
1df7c7f1d4
Signed-off-by: Tad <tad@spotco.us>
47 lines
1.7 KiB
Diff
47 lines
1.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Micay <danielmicay@gmail.com>
|
|
Date: Sat, 19 Nov 2016 09:56:14 -0500
|
|
Subject: [PATCH] stop implicitly marking mappings as mergeable
|
|
|
|
---
|
|
libc/bionic/mmap.cpp | 19 +------------------
|
|
1 file changed, 1 insertion(+), 18 deletions(-)
|
|
|
|
diff --git a/libc/bionic/mmap.cpp b/libc/bionic/mmap.cpp
|
|
index 35033199a..c08106892 100644
|
|
--- a/libc/bionic/mmap.cpp
|
|
+++ b/libc/bionic/mmap.cpp
|
|
@@ -39,8 +39,6 @@ extern "C" void* __mmap2(void*, size_t, int, int, int, size_t);
|
|
|
|
#define MMAP2_SHIFT 12 // 2**12 == 4096
|
|
|
|
-static bool kernel_has_MADV_MERGEABLE = true;
|
|
-
|
|
void* mmap64(void* addr, size_t size, int prot, int flags, int fd, off64_t offset) {
|
|
if (offset < 0 || (offset & ((1UL << MMAP2_SHIFT)-1)) != 0) {
|
|
errno = EINVAL;
|
|
@@ -54,22 +52,7 @@ 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)) == (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 && !is_stack_or_grows_down) {
|
|
- ErrnoRestorer errno_restorer;
|
|
- int rc = madvise(result, size, MADV_MERGEABLE);
|
|
- if (rc == -1 && errno == EINVAL) {
|
|
- kernel_has_MADV_MERGEABLE = false;
|
|
- }
|
|
- }
|
|
-
|
|
- return result;
|
|
+ return __mmap2(addr, size, prot, flags, fd, offset >> MMAP2_SHIFT);
|
|
}
|
|
|
|
void* mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset) {
|