radeonsi: kill point size VS output if it's not used by the rasterizer
[mesa.git] / src / util / anon_file.c
index 90c55cd5af0c8a7347ffbddeaa718ae8a96f4738..6c8885707f4912147486d3077d443ad41bdbe918 100644 (file)
  * Based on weston shared/os-compatibility.c
  */
 
-#ifndef WIN32
+#ifndef _WIN32
 #include "anon_file.h"
 
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <stdio.h>
 #include <stdlib.h>
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
 #include <sys/mman.h>
-#elif defined(HAVE_MEMFD_CREATE)
+#elif defined(HAVE_MEMFD_CREATE) || defined(ANDROID)
 #include <sys/syscall.h>
 #include <linux/memfd.h>
 #else
 #include <stdio.h>
-#include <stdlib.h>
 #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)
 {
@@ -70,7 +68,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)
 {
@@ -120,7 +118,12 @@ 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(__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";
    fd = syscall(SYS_memfd_create, debug_name, MFD_CLOEXEC);