diff options
author | Jed Davis <jld@mozilla.com> | 2019-02-07 16:30:44 -0700 |
---|---|---|
committer | Jed Davis <jld@mozilla.com> | 2019-02-07 16:30:44 -0700 |
commit | 7729becab763103ddddbdb2381891947f62b40a1 (patch) | |
tree | 470f339a9ca013b9a450c0eef0ec7888c227cb0d | |
parent | 7fa6f3b20ae4e4f1b0b5aa2592d29cd1d60c7035 (diff) | |
download | nspr-hg-7729becab763103ddddbdb2381891947f62b40a1.tar.gz |
Bug 1525803 - Use MAP_SHARED for read-only file mappings on MacOS and Android. r=glandium
-rw-r--r-- | pr/src/md/unix/unix.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/pr/src/md/unix/unix.c b/pr/src/md/unix/unix.c index 7c90b507..32ad3321 100644 --- a/pr/src/md/unix/unix.c +++ b/pr/src/md/unix/unix.c @@ -3569,12 +3569,20 @@ PRStatus _MD_CreateFileMap(PRFileMap *fmap, PRInt64 size) } if (fmap->prot == PR_PROT_READONLY) { fmap->md.prot = PROT_READ; -#ifdef OSF1V4_MAP_PRIVATE_BUG +#if defined(OSF1V4_MAP_PRIVATE_BUG) || defined(DARWIN) || defined(ANDROID) /* * Use MAP_SHARED to work around a bug in OSF1 V4.0D * (QAR 70220 in the OSF_QAR database) that results in * corrupted data in the memory-mapped region. This * bug is fixed in V5.0. + * + * This is also needed on OS X because its implementation of + * POSIX shared memory returns an error for MAP_PRIVATE, even + * when the mapping is read-only. + * + * And this is needed on Android, because mapping ashmem with + * MAP_PRIVATE creates a mapping of zeroed memory instead of + * the shm contents. */ fmap->md.flags = MAP_SHARED; #else |