Module: Mesa Branch: staging/20.1 Commit: 521ba8b2a9b066eba3b2c22194f8e497eb8344da URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=521ba8b2a9b066eba3b2c22194f8e497eb8344da
Author: Jonathan Gray <[email protected]> Date: Thu Nov 1 13:16:13 2018 +1100 util/anon_file: add OpenBSD shm_mkstemp() path memfd_create() is a linux syscall replace the use of it with shm_mkstemp() on OpenBSD. unconditionally include stdlib.h for mkstemp()/mkostemp() Fixes: c0376a12341 ("util: add anon_file.h for all memfd/temp file usage") Signed-off-by: Jonathan Gray <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5630> (cherry picked from commit 6e9c0661f8538cdabe7d7de73af11b4165f51f93) --- .pick_status.json | 2 +- src/util/anon_file.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 56804aeeb01..1aaf2c3ffab 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -814,7 +814,7 @@ "description": "util/anon_file: add OpenBSD shm_mkstemp() path", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "c0376a123418df0050dc45d3e1e84f6b29a6a1f3" }, diff --git a/src/util/anon_file.c b/src/util/anon_file.c index bd415adb647..6c8885707f4 100644 --- a/src/util/anon_file.c +++ b/src/util/anon_file.c @@ -33,16 +33,15 @@ #include <unistd.h> #include <fcntl.h> #include <errno.h> +#include <stdlib.h> -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__OpenBSD__) #include <sys/mman.h> #elif defined(HAVE_MEMFD_CREATE) || defined(ANDROID) #include <sys/syscall.h> #include <linux/memfd.h> -#include <stdlib.h> #else #include <stdio.h> -#include <stdlib.h> #endif #if !(defined(__FreeBSD__) || defined(HAVE_MEMFD_CREATE) || defined(HAVE_MKOSTEMP) || defined(ANDROID)) @@ -119,6 +118,11 @@ 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(__OpenBSD__) + char template[] = "/tmp/mesa-XXXXXXXXXX"; + fd = shm_mkstemp(template); + if (fd != -1) + shm_unlink(template); #elif defined(HAVE_MEMFD_CREATE) || defined(ANDROID) if (!debug_name) debug_name = "mesa-shared"; _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
