From 36ce73bbfdb1f80a010d64333a115e096f7233b8 Mon Sep 17 00:00:00 2001 From: Greg V Date: Sat, 22 Dec 2018 16:10:06 +0300 Subject: [PATCH] Wayland: use SHM_ANON on FreeBSD This works like memfd on Linux. --- src/wl_window.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wl_window.c b/src/wl_window.c index 98a64659..1d7cc9a0 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -156,6 +156,9 @@ static int createAnonymousFile(off_t size) fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL); } else +#elif defined(SHM_ANON) + fd = shm_open(SHM_ANON, O_RDWR | O_CLOEXEC, 0600); + if (fd < 0) #endif { path = getenv("XDG_RUNTIME_DIR"); @@ -175,7 +178,12 @@ static int createAnonymousFile(off_t size) return -1; } +#if defined(SHM_ANON) + // posix_fallocate does not work on SHM descriptors + ret = ftruncate(fd, size); +#else ret = posix_fallocate(fd, 0, size); +#endif if (ret != 0) { close(fd);