diff options
author | Flemmard <flemmard@gmail.com> | 2014-11-13 00:12:22 +0100 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2015-10-19 23:53:50 +0200 |
commit | c82102f470244762cf108a6fedd8538f37a510d3 (patch) | |
tree | ae004aced5b96ce9dd3cfeb4c8499e3cec08226d /libc/bionic | |
parent | 4b5256a4395495f7de3224483605e169599bc5a3 (diff) | |
download | bionic-c82102f470244762cf108a6fedd8538f37a510d3.zip bionic-c82102f470244762cf108a6fedd8538f37a510d3.tar.gz bionic-c82102f470244762cf108a6fedd8538f37a510d3.tar.bz2 |
bionic: Add flag to restore legacy mmap behavior
* Pre-lollipop mmap would not care whether offset was signed
or unsigned.
* Lollipop adds 64-bit support which results in sign extension
of offset, causing a negative offset when
a positive offset > 2^31 is given.
Change-Id: I5d19d898fc131cf848217974915d1b466a474f99
Diffstat (limited to 'libc/bionic')
-rw-r--r-- | libc/bionic/mmap.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libc/bionic/mmap.cpp b/libc/bionic/mmap.cpp index 8f25a89..53e8b46 100644 --- a/libc/bionic/mmap.cpp +++ b/libc/bionic/mmap.cpp @@ -36,6 +36,11 @@ extern "C" void* __mmap2(void*, size_t, int, int, int, size_t); #define MMAP2_SHIFT 12 // 2**12 == 4096 +#ifdef LEGACY_MMAP +#define TO_64(a) ((a) & 0x00000000ffffffff) +#else +#define TO_64(a) (a) +#endif static bool kernel_has_MADV_MERGEABLE = true; @@ -60,5 +65,5 @@ void* mmap64(void* addr, size_t size, int prot, int flags, int fd, off64_t offse } void* mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset) { - return mmap64(addr, size, prot, flags, fd, static_cast<off64_t>(offset)); + return mmap64(addr, size, prot, flags, fd, TO_64(static_cast<off64_t>(offset))); } |