Bug 1164027 - Use MAP_ANONYMOUS instead of opening /dev/zero. r=jrmuizel
authorJamie Nicol <jnicol@mozilla.com>
Fri, 22 Jul 2016 14:16:22 +0100
changeset 346430 0dbf7d22b0632620d967daaf1ce1cb7694b02778
parent 346429 0476118cfea7aef2cb676cc9a78b6ce109cab270
child 346431 86816e25dea7cfcc8adbb70c575a04c8fa7be278
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1164027
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1164027 - Use MAP_ANONYMOUS instead of opening /dev/zero. r=jrmuizel MozReview-Commit-ID: 5GeNG5Tm1GS
gfx/gl/GLContext.cpp
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -7,17 +7,16 @@
 #include "GLContext.h"
 
 #include <algorithm>
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 #include <vector>
 #ifdef MOZ_WIDGET_ANDROID
-#include <fcntl.h>
 #include <sys/mman.h>
 #endif
 
 #include "GLBlitHelper.h"
 #include "GLReadTexImageHelper.h"
 #include "GLScreenBuffer.h"
 
 #include "gfxCrashReporterUtils.h"
@@ -2881,26 +2880,22 @@ GLContext::fDeleteFramebuffers(GLsizei n
 static bool
 WillTextureMapSucceed(GLsizei width, GLsizei height, GLenum format, GLenum type)
 {
     bool willSucceed = false;
     // Some drivers leave large gaps between textures, so require
     // there to be double the actual size of the texture available.
     size_t size = width * height * GetBytesPerTexel(format, type) * 2;
 
-    int fd = open("/dev/zero", O_RDONLY);
-
-    void *p = mmap(nullptr, size, PROT_NONE, MAP_SHARED, fd, 0);
+    void *p = mmap(nullptr, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
     if (p != MAP_FAILED) {
         willSucceed = true;
         munmap(p, size);
     }
 
-    close(fd);
-
     return willSucceed;
 }
 #endif // MOZ_WIDGET_ANDROID
 
 void
 GLContext::fTexImage2D(GLenum target, GLint level, GLint internalformat,
                        GLsizei width, GLsizei height, GLint border,
                        GLenum format, GLenum type, const GLvoid* pixels) {