summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
authorMiguel A. Vico <[email protected]>2017-07-19 17:25:08 -0700
committerEmil Velikov <[email protected]>2017-07-24 10:27:43 +0100
commit045108938c11f507dcc3c50b59b0a8a8529486bd (patch)
tree4a3da7ffdf0113c0a05b5789ee55fc1eef58001e /src/egl
parentdad0c5d2d7ef91accc768a7192f6c9284080ab6f (diff)
egl: Move _eglPointerIsDereferencable() to eglglobals.[ch]
Move _eglPointerIsDereferencable() to eglglobals.[ch] and make it a non-static function so it can be used out of egldisplay.c Signed-off-by: Miguel A. Vico <[email protected]> Reviewed-by: James Jones <[email protected]> Acked-by: Daniel Stone <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/main/egldisplay.c33
-rw-r--r--src/egl/main/eglglobals.c31
-rw-r--r--src/egl/main/eglglobals.h6
3 files changed, 37 insertions, 33 deletions
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index 7aaab3c2c94..690728d2f70 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -49,10 +49,6 @@
#include "eglsync.h"
/* Includes for _eglNativePlatformDetectNativeDisplay */
-#ifdef HAVE_MINCORE
-#include <unistd.h>
-#include <sys/mman.h>
-#endif
#ifdef HAVE_WAYLAND_PLATFORM
#include <wayland-client.h>
#endif
@@ -106,35 +102,6 @@ _eglGetNativePlatformFromEnv(void)
/**
- * Perform validity checks on a generic pointer.
- */
-static EGLBoolean
-_eglPointerIsDereferencable(void *p)
-{
-#ifdef HAVE_MINCORE
- uintptr_t addr = (uintptr_t) p;
- unsigned char valid = 0;
- const long page_size = getpagesize();
-
- if (p == NULL)
- return EGL_FALSE;
-
- /* align addr to page_size */
- addr &= ~(page_size - 1);
-
- if (mincore((void *) addr, page_size, &valid) < 0) {
- _eglLog(_EGL_DEBUG, "mincore failed: %m");
- return EGL_FALSE;
- }
-
- return (valid & 0x01) == 0x01;
-#else
- return p != NULL;
-#endif
-}
-
-
-/**
* Try detecting native platform with the help of native display characteristcs.
*/
static _EGLPlatformType
diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c
index baf96bb1ec5..6fdc6c31ce3 100644
--- a/src/egl/main/eglglobals.c
+++ b/src/egl/main/eglglobals.c
@@ -37,6 +37,12 @@
#include "eglglobals.h"
#include "egldisplay.h"
#include "egldriver.h"
+#include "egllog.h"
+
+#ifdef HAVE_MINCORE
+#include <unistd.h>
+#include <sys/mman.h>
+#endif
static mtx_t _eglGlobalMutex = _MTX_INITIALIZER_NP;
@@ -142,3 +148,28 @@ _eglGetClientExtensionString(void)
mtx_unlock(_eglGlobal.Mutex);
return ret;
}
+
+EGLBoolean
+_eglPointerIsDereferencable(void *p)
+{
+#ifdef HAVE_MINCORE
+ uintptr_t addr = (uintptr_t) p;
+ unsigned char valid = 0;
+ const long page_size = getpagesize();
+
+ if (p == NULL)
+ return EGL_FALSE;
+
+ /* align addr to page_size */
+ addr &= ~(page_size - 1);
+
+ if (mincore((void *) addr, page_size, &valid) < 0) {
+ _eglLog(_EGL_DEBUG, "mincore failed: %m");
+ return EGL_FALSE;
+ }
+
+ return (valid & 0x01) == 0x01;
+#else
+ return p != NULL;
+#endif
+}
diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h
index c6ef59d4820..6655ccab65c 100644
--- a/src/egl/main/eglglobals.h
+++ b/src/egl/main/eglglobals.h
@@ -87,4 +87,10 @@ static inline unsigned int DebugBitFromType(EGLenum type)
extern const char *
_eglGetClientExtensionString(void);
+/**
+ * Perform validity checks on a generic pointer.
+ */
+extern EGLBoolean
+_eglPointerIsDereferencable(void *p);
+
#endif /* EGLGLOBALS_INCLUDED */