Changeset View
Changeset View
Standalone View
Standalone View
graphics/wayland/files/patch-cursor_os-compatibility.c
--- cursor/os-compatibility.c.orig 2019-03-21 00:55:25 UTC | --- cursor/os-compatibility.c.orig 2020-02-11 23:46:03 UTC | ||||
+++ cursor/os-compatibility.c | +++ cursor/os-compatibility.c | ||||
@@ -23,6 +23,10 @@ | @@ -34,7 +34,7 @@ | ||||
* SOFTWARE. | #include <string.h> | ||||
*/ | #include <stdlib.h> | ||||
+#ifdef __FreeBSD__ | -#ifdef HAVE_MEMFD_CREATE | ||||
+#include <sys/mman.h> | +#if defined(HAVE_MEMFD_CREATE) || defined(__FreeBSD__) | ||||
+#endif | #include <sys/mman.h> | ||||
+ | |||||
#define _GNU_SOURCE | |||||
#include <sys/types.h> | |||||
@@ -59,6 +63,7 @@ err: | |||||
} | |||||
#endif | #endif | ||||
+#ifndef __FreeBSD__ | @@ -132,6 +132,9 @@ os_create_anonymous_file(off_t size) | ||||
static int | */ | ||||
create_tmpfile_cloexec(char *tmpname) | fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL); | ||||
{ | } else | ||||
@@ -78,6 +83,7 @@ create_tmpfile_cloexec(char *tmpname) | +#elif defined(__FreeBSD__) | ||||
return fd; | |||||
} | |||||
+#endif | |||||
/* | |||||
* Create a new, unique, anonymous file of the given size, and | |||||
@@ -103,11 +109,14 @@ create_tmpfile_cloexec(char *tmpname) | |||||
int | |||||
os_create_anonymous_file(off_t size) | |||||
{ | |||||
+ int fd; | |||||
+ int ret; | |||||
+#ifdef __FreeBSD__ | |||||
+ fd = shm_open(SHM_ANON, O_CREAT | O_RDWR | O_CLOEXEC, 0600); // shm_open is always CLOEXEC | + fd = shm_open(SHM_ANON, O_CREAT | O_RDWR | O_CLOEXEC, 0600); // shm_open is always CLOEXEC | ||||
+#else | + if (fd < 0) | ||||
static const char template[] = "/wayland-cursor-shared-XXXXXX"; | #endif | ||||
const char *path; | { | ||||
char *name; | |||||
- int fd; | |||||
- int ret; | |||||
path = getenv("XDG_RUNTIME_DIR"); | path = getenv("XDG_RUNTIME_DIR"); | ||||
if (!path) { | |||||
@@ -125,11 +134,12 @@ os_create_anonymous_file(off_t size) | |||||
fd = create_tmpfile_cloexec(name); | |||||
free(name); | |||||
+#endif /* __FreeBSD__ */ | |||||
if (fd < 0) | |||||
return -1; | |||||
-#ifdef HAVE_POSIX_FALLOCATE | |||||
+#if defined(HAVE_POSIX_FALLOCATE) && !defined(__FreeBSD__) | |||||
ret = posix_fallocate(fd, 0, size); | |||||
if (ret != 0) { | |||||
close(fd); |