From ce8fd042a5b0130cc5c62981828b122127711712 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tapani=20P=C3=A4lli?= Date: Tue, 20 Aug 2019 08:59:23 +0300 Subject: [PATCH] util: fix os_create_anonymous_file on android MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Commit fixes current crashes with Vulkan applications on Android. Fixes: c0376a123418 "util: add anon_file.h for all memfd/temp file usage" Signed-off-by: Tapani Pälli Reviewed-by: Eric Engestrom --- src/util/anon_file.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/util/anon_file.c b/src/util/anon_file.c index 2780c74a680..e36800482fc 100644 --- a/src/util/anon_file.c +++ b/src/util/anon_file.c @@ -36,15 +36,16 @@ #ifdef __FreeBSD__ #include -#elif defined(HAVE_MEMFD_CREATE) +#elif defined(HAVE_MEMFD_CREATE) || defined(ANDROID) #include #include +#include #else #include #include #endif -#if !(defined(__FreeBSD__) || defined(HAVE_MEMFD_CREATE) || defined(HAVE_MKOSTEMP)) +#if !(defined(__FreeBSD__) || defined(HAVE_MEMFD_CREATE) || defined(HAVE_MKOSTEMP) || defined(ANDROID)) static int set_cloexec_or_close(int fd) { @@ -68,7 +69,7 @@ err: } #endif -#if !(defined(__FreeBSD__) || defined(HAVE_MEMFD_CREATE)) +#if !(defined(__FreeBSD__) || defined(HAVE_MEMFD_CREATE) || defined(ANDROID)) static int create_tmpfile_cloexec(char *tmpname) { @@ -118,7 +119,7 @@ os_create_anonymous_file(off_t size, const char *debug_name) #ifdef __FreeBSD__ (void*)debug_name; fd = shm_open(SHM_ANON, O_CREAT | O_RDWR | O_CLOEXEC, 0600); -#elif defined(HAVE_MEMFD_CREATE) +#elif defined(HAVE_MEMFD_CREATE) || defined(ANDROID) if (!debug_name) debug_name = "mesa-shared"; fd = syscall(SYS_memfd_create, debug_name, MFD_CLOEXEC); -- 2.30.2