Skip to content

Commit

Permalink
x11-libs/libxshmfence: new package, add 1.3.2-r1
Browse files Browse the repository at this point in the history
Signed-off-by: James Calligeros <[email protected]>
  • Loading branch information
chadmed committed Nov 19, 2024
1 parent e76c4f5 commit 5db571a
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions x11-libs/libxshmfence/Manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DIST libxshmfence-1.3.2.tar.xz 259024 BLAKE2B 2f0ef0767fbb29349acf43b4cb4d7177956c06c389f0443db06e398c4e0f3b424432ce6fe8946d70fdd59b9446c53bf2f1ee126df4d41b3065f1e94438facecf SHA512 e20a6827e370726cf50489a69f4a52b897f1c44e3eba8c72a4e626b08724e877d090770b8016765736d887d5d5eaba1fda9c29066e62d259b4d1e2064bc1626c
53 changes: 53 additions & 0 deletions x11-libs/libxshmfence/files/libxshmfence-1.3.2-memfd-envvar.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
From 3aaf46a2742d1698f3a4399b2bb2f855c0b904fe Mon Sep 17 00:00:00 2001
From: Asahi Lina <[email protected]>
Date: Tue, 22 Oct 2024 22:28:19 +0900
Subject: [PATCH] alloc: Allow disabling memfd usage at runtime with
XSHMFENCE_NO_MEMFD=1

For thin VMs used for compatibility reasons, it is desirable to directly
proxy the X11 protocol between an application running in a VM and an X
server running on the host. We can proxy futex wakeups with some watcher
code, but we need the futex memory itself to be shared. This works when
/dev/shm is mounted with virtiofs with DAX, but cannot work for memfds.

Add a XSHMFENCE_NO_MEMFD environment variable that, when set, disables
the memfd codepath and falls back to /dev/shm.

Signed-off-by: Asahi Lina <[email protected]>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxshmfence/-/merge_requests/9>
---
src/xshmfence_alloc.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/xshmfence_alloc.c b/src/xshmfence_alloc.c
index 932adb9..77f968c 100644
--- a/src/xshmfence_alloc.c
+++ b/src/xshmfence_alloc.c
@@ -69,13 +69,22 @@ int
xshmfence_alloc_shm(void)
{
char template[] = SHMDIR "/shmfd-XXXXXX";
- int fd;
+ int fd = -1;
#ifndef HAVE_MKOSTEMP
int flags;
#endif

#if HAVE_MEMFD_CREATE
- fd = memfd_create("xshmfence", MFD_CLOEXEC|MFD_ALLOW_SEALING);
+ static int disable_memfd = -1;
+
+ if (disable_memfd == -1) {
+ const char *val = getenv("XSHMFENCE_NO_MEMFD");
+ disable_memfd = val ? !!atoi(val) : 0;
+ }
+
+ if (disable_memfd <= 0)
+ fd = memfd_create("xshmfence", MFD_CLOEXEC|MFD_ALLOW_SEALING);
+
if (fd < 0)
#endif
#ifdef SHM_ANON
--
GitLab

18 changes: 18 additions & 0 deletions x11-libs/libxshmfence/libxshmfence-1.3.2-r1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

XORG_MULTILIB=yes
XORG_TARBALL_SUFFIX="xz"
inherit xorg-3

DESCRIPTION="Shared memory fences using futexes"

KEYWORDS="~arm64"

DEPEND="x11-base/xorg-proto"

PATCHES="
${FILESDIR}/${P}-memfd-envvar.patch
"
11 changes: 11 additions & 0 deletions x11-libs/libxshmfence/metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="project">
<email>[email protected]</email>
<name>X11</name>
</maintainer>
<upstream>
<remote-id type="freedesktop-gitlab">xorg/lib/libxshmfence</remote-id>
</upstream>
</pkgmetadata>

0 comments on commit 5db571a

Please sign in to comment.