[Bf-blender-cvs] [1ff52369bb3] wayland: GHOST/wayland: create temporary file manually for older kernel versions
Christian Rauch
noreply at git.blender.org
Tue Jul 13 00:39:59 CEST 2021
Commit: 1ff52369bb3b99761f4823abac3c64510011910c
Author: Christian Rauch
Date: Mon Jul 12 23:28:41 2021 +0100
Branches: wayland
https://developer.blender.org/rB1ff52369bb3b99761f4823abac3c64510011910c
GHOST/wayland: create temporary file manually for older kernel versions
===================================================================
M intern/ghost/intern/GHOST_SystemWayland.cpp
===================================================================
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 75a80de983d..4ed8241d5b1 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -49,6 +49,7 @@
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
+#include <linux/version.h>
#include <cstring>
@@ -1804,8 +1805,22 @@ GHOST_TSuccess GHOST_SystemWayland::setCustomCursorShape(uint8_t *bitmap,
static const int32_t stride = sizex * 4; /* ARGB */
cursor->file_buffer->size = size_t(stride * sizey);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
const int fd = memfd_create("blender-cursor-custom", MFD_CLOEXEC | MFD_ALLOW_SEALING);
fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK);
+#else
+ char *tmpname;
+ asprintf(&tmpname, "%s/%s", getenv("XDG_RUNTIME_DIR"), "blender-XXXXXX");
+ const int fd = mkostemp(tmpname, O_CLOEXEC);
+ if (fd >= 0) {
+ unlink(tmpname);
+ }
+ free(tmpname);
+ if (fd < 0) {
+ return GHOST_kFailure;
+ }
+#endif
+
posix_fallocate(fd, 0, int32_t(cursor->file_buffer->size));
cursor->file_buffer->data = mmap(
More information about the Bf-blender-cvs
mailing list