wireplumber: remove redundant byteswap.h and sys/mman.h shims

relibc now provides the real <byteswap.h> header and Linux mmap
extension flags (MAP_LOCKED, MAP_HUGETLB, etc.) in <sys/mman.h>.
Drop the redox_compat/ shim files from the WirePlumber patch, update
README-redbear.md to say no shims are needed, and remove the recipe's
redox_compat CFLAGS include and staging/copy step.
This commit is contained in:
2026-07-10 16:16:53 +03:00
parent 787b5b6702
commit 796c7ee85a
2 changed files with 12 additions and 150 deletions
@@ -1,7 +1,7 @@
From 851ab7d96d6a10c5c67f50988db75810bc61ebbc Mon Sep 17 00:00:00 2001
From: Red Bear Maintainer <maintainer@redbearos.org>
Date: Вт, 09 июн 2026 19:50:57 +0000
Subject: [PATCH] wireplumber: redox_compat shim headers and Red Bear README
Subject: [PATCH] wireplumber: Red Bear README and port status notes
Red Bear OS external patch for wireplumber, applied on top of the
upstream freedesktop wireplumber 0.4.14
@@ -17,24 +17,18 @@ Changes (vs upstream 0.4.14):
* README-redbear.md: Red Bear port status and intentionally-disabled
plugins (systemd, elogind, GObject introspection) — same role as
the pipewire fork README; documents the build gap analysis.
* redox_compat/byteswap.h: glibc <byteswap.h> API (bswap_16/32/64)
on top of relibc <endian.h>. Reached via CFLAGS -I in the recipe.
* redox_compat/sys/mman.h: Linux mmap() extension flags
(MAP_LOCKED, MAP_HUGETLB, MAP_NORESERVE, MAP_POPULATE,
MAP_NONBLOCK, MAP_DENYWRITE, MAP_EXECUTABLE, MAP_GROWSDOWN) that
relibc does not yet provide. Values match the Linux kernel UABI.
Reached via CFLAGS -I in the recipe.
These shims are the same ones used by the pipewire recipe and address
the same relibc gaps. They will be removed once relibc gains the
upstream equivalents.
The previous redox_compat/byteswap.h and redox_compat/sys/mman.h shim
headers have been removed because relibc now provides the real
<byteswap.h> and Linux mmap extension flags (MAP_LOCKED, etc.) in
<sys/mman.h>. The WirePlumber recipe no longer stages those shims.
---
diff --git a/README-redbear.md b/README-redbear.md
new file mode 100644
index 0000000..a155dee
--- /dev/null
+++ b/README-redbear.md
@@ -0,0 +1,70 @@
@@ -0,0 +1,69 @@
+# WirePlumber — Red Bear OS source fork
+
+This is the Red Bear OS fork of upstream WirePlumber, baseline at tag
@@ -97,136 +91,10 @@ index 0000000..a155dee
+./target/release/repo cook local/recipes/libs/wireplumber
+```
+
+The build uses the same redox_compat shim headers (byteswap.h,
+sys/mman.h) that the pipewire recipe uses, because the same relibc
+gaps affect the wireplumber build.
+The recipe applies this README patch; no additional shim headers are needed
+because relibc now provides the byteswap.h and Linux mmap extension flags.
+
+## License
+
+MIT (WirePlumber). The Red Bear OS fork inherits this term. See the
+upstream `LICENSE` file for details.
diff --git a/redox_compat/byteswap.h b/redox_compat/byteswap.h
new file mode 100644
index 0000000..e9b3520
--- /dev/null
+++ b/redox_compat/byteswap.h
@@ -0,0 +1,56 @@
+/*
+ * byteswap.h — Redox compatibility shim for the glibc <byteswap.h> header.
+ *
+ * glibc's <byteswap.h> provides bswap_16, bswap_32, bswap_64, bswap_128
+ * inline functions that perform raw byte-swap operations. Redox's relibc
+ * provides <endian.h> with the equivalent functionality as htobe* and
+ * be*toh macros. This shim exposes the byteswap.h API on top of relibc's
+ * endian primitives so that upstream code that includes <byteswap.h> works
+ * unchanged on Redox.
+ *
+ * This shim is part of the Red Bear OS PipeWire source fork. The
+ * corresponding upstream PipeWire source includes <byteswap.h> directly
+ * on non-FreeBSD / non-MidnightBSD platforms; this shim is reached by
+ * adding -I${REDOX_COMPAT_DIR} to CFLAGS in local/recipes/libs/pipewire/
+ * recipe.toml. The shim is used *instead of* the system byteswap.h on
+ * __redox__ targets.
+ *
+ * This is a real implementation, not a stub: every bswap_N function
+ * actually performs the byte swap, and the function semantics match
+ * glibc's byteswap.h (bswap_32(x) returns a 32-bit value with bytes
+ * reversed; bswap_64(x) returns a 64-bit value with bytes reversed).
+ *
+ * Tracking: a real <byteswap.h> is planned for upstream relibc. Once
+ * that lands, this shim should be removed and the recipe's CFLAGS
+ * adjusted. See local/sources/pipewire/README-redbear.md.
+ */
+#ifndef REDBEAR_PIPEWIRE_BYTESWAP_H
+#define REDBEAR_PIPEWIRE_BYTESWAP_H
+
+#include <endian.h>
+#include <stdint.h>
+
+static inline uint16_t bswap_16(uint16_t __x)
+{
+ return (uint16_t)(((uint16_t)(__x & 0x00ff) << 8) | ((__x & 0xff00) >> 8));
+}
+
+static inline uint32_t bswap_32(uint32_t __x)
+{
+ return ((((__x) & 0xff000000u) >> 24) | (((__x) & 0x00ff0000u) >> 8) |
+ (((__x) & 0x0000ff00u) << 8) | (((__x) & 0x000000ffu) << 24));
+}
+
+static inline uint64_t bswap_64(uint64_t __x)
+{
+ return ((((__x) & 0xff00000000000000ull) >> 56) |
+ (((__x) & 0x00ff000000000000ull) >> 40) |
+ (((__x) & 0x0000ff0000000000ull) >> 24) |
+ (((__x) & 0x000000ff00000000ull) >> 8) |
+ (((__x) & 0x00000000ff000000ull) << 8) |
+ (((__x) & 0x0000000000ff0000ull) << 24) |
+ (((__x) & 0x000000000000ff00ull) << 40) |
+ (((__x) & 0x00000000000000ffull) << 56));
+}
+
+#endif /* REDBEAR_PIPEWIRE_BYTESWAP_H */
diff --git a/redox_compat/sys/mman.h b/redox_compat/sys/mman.h
new file mode 100644
index 0000000..4102f79
--- /dev/null
+++ b/redox_compat/sys/mman.h
@@ -0,0 +1,57 @@
+/*
+ * sys/mman.h — Redox compatibility shim for Linux-specific mmap flags.
+ *
+ * relibc's <sys/mman.h> provides the POSIX mmap() flags (MAP_SHARED,
+ * MAP_PRIVATE, MAP_ANON, MAP_FIXED, etc.) but is missing the Linux
+ * extensions (MAP_LOCKED, MAP_HUGETLB, MAP_NORESERVE, MAP_POPULATE,
+ * MAP_NONBLOCK, MAP_STACK, MAP_DENYWRITE on older glibc, etc.).
+ *
+ * This shim pulls in the upstream relibc header first and then adds
+ * the Linux extension flags that PipeWire and SPA actually use. The
+ * value of MAP_LOCKED matches the Linux kernel's UAPI value (0x2000),
+ * which is what the kernel expects on a real mmap call; on Redox
+ * where the kernel does not honor MAP_LOCKED, the mmap still succeeds
+ * and the memory is simply not pre-locked (POSIX allows this — the
+ * call is best-effort and a portable program must tolerate either
+ * behavior).
+ *
+ * This is a real implementation, not a stub: every flag here matches
+ * the Linux kernel UABI value, so any downstream code that does a
+ * syscall (or a libc call that forwards the flag) will pass the right
+ * bit pattern.
+ *
+ * Tracking: a complete <sys/mman.h> with all Linux extensions is
+ * planned for upstream relibc. Once that lands, this shim should be
+ * removed. See local/sources/pipewire/README-redbear.md.
+ */
+#ifndef REDBEAR_PIPEWIRE_SYS_MMAN_H
+#define REDBEAR_PIPEWIRE_SYS_MMAN_H
+
+#include_next <sys/mman.h>
+
+#ifndef MAP_LOCKED
+#define MAP_LOCKED 0x02000
+#endif
+#ifndef MAP_HUGETLB
+#define MAP_HUGETLB 0x40000
+#endif
+#ifndef MAP_NORESERVE
+#define MAP_NORESERVE 0x04000
+#endif
+#ifndef MAP_POPULATE
+#define MAP_POPULATE 0x08000
+#endif
+#ifndef MAP_NONBLOCK
+#define MAP_NONBLOCK 0x10000
+#endif
+#ifndef MAP_DENYWRITE
+#define MAP_DENYWRITE 0x00800
+#endif
+#ifndef MAP_EXECUTABLE
+#define MAP_EXECUTABLE 0x01000
+#endif
+#ifndef MAP_GROWSDOWN
+#define MAP_GROWSDOWN 0x01000
+#endif
+
+#endif /* REDBEAR_PIPEWIRE_SYS_MMAN_H */
+4 -10
View File
@@ -13,9 +13,8 @@
# upstream syncs a `rev = "..."` bump + patch rebase instead of a
# full rebase of a Red Bear fork.
#
# All Red Bear-specific wireplumber changes (redox_compat/ shim
# headers for relibc gaps, README-redbear.md port status) live as
# patches under local/patches/wireplumber/. To add a new wireplumber
# All Red Bear-specific wireplumber changes (README-redbear.md port
# status) live as patches under local/patches/wireplumber/. To add a new wireplumber
# change:
# 1. make the change in the fetched tree
# 2. `git diff > local/patches/wireplumber/NN-short-description.patch`
@@ -98,14 +97,9 @@ export CXX="x86_64-unknown-redox-g++"
export AR="x86_64-unknown-redox-ar"
export STRIP="x86_64-unknown-redox-strip"
export RANLIB="x86_64-unknown-redox-ranlib"
export CFLAGS="-I${COOKBOOK_SOURCE}/redox_compat -I${COOKBOOK_SYSROOT}/usr/include --sysroot=${COOKBOOK_SYSROOT} -Wno-error=format-overflow -Wno-error=stringop-truncation -Wno-error=array-bounds -Wno-error=use-after-free -Wno-error=array-parameter -Wno-error=cast-function-type -Wno-error=deprecated-declarations -Wno-error=stringop-overread -Wno-error=dangling-pointer -Wno-error=uninitialized -Wno-error=maybe-uninitialized -Wno-error=incompatible-pointer-types"
export CFLAGS="-I${COOKBOOK_SYSROOT}/usr/include --sysroot=${COOKBOOK_SYSROOT} -Wno-error=format-overflow -Wno-error=stringop-truncation -Wno-error=array-bounds -Wno-error=use-after-free -Wno-error=array-parameter -Wno-error=cast-function-type -Wno-error=deprecated-declarations -Wno-error=stringop-overread -Wno-error=dangling-pointer -Wno-error=uninitialized -Wno-error=maybe-uninitialized -Wno-error=incompatible-pointer-types"
export LDFLAGS="--sysroot=${COOKBOOK_SYSROOT}"
# Stage the redox_compat shim headers (same shims the pipewire
# recipe uses; the same relibc gaps affect wireplumber).
mkdir -p "${COOKBOOK_SYSROOT}/usr/include"
cp -r "${COOKBOOK_SOURCE}/redox_compat/." "${COOKBOOK_SYSROOT}/usr/include/"
# Disable the Linux-specific optional integrations. Keep the core
# session manager, the C library, and the command-line tools.
cookbook_meson \\
@@ -125,4 +119,4 @@ cookbook_meson \\
[package]
version = "0.4.14"
description = "WirePlumber 0.4.14 — PipeWire session and policy manager (v6.0 2026 Red Bear). Provides libwireplumber-0.4.so, the wireplumber session manager daemon, and the wpctl control utility. Compiled against the Redox toolchain to serve as the audio session manager for KDE Plasma on Red Bear OS; the systemd and elogind integration paths are disabled because Redox uses init.d, and the optional PulseAudio helper is disabled because pipewire-pulse (from the pipewire recipe) already provides the PulseAudio client surface. Per local/AGENTS.md Rule 2, all Red Bear-specific edits to upstream wireplumber live as external patches in local/patches/wireplumber/ (currently: 01 — redox_compat shim headers for relibc gaps and the Red Bear port README). The previous source fork at local/sources/wireplumber/ is preserved as historical reference but is no longer used by the build system."
description = "WirePlumber 0.4.14 — PipeWire session and policy manager (v6.0 2026 Red Bear). Provides libwireplumber-0.4.so, the wireplumber session manager daemon, and the wpctl control utility. Compiled against the Redox toolchain to serve as the audio session manager for KDE Plasma on Red Bear OS; the systemd and elogind integration paths are disabled because Redox uses init.d, and the optional PulseAudio helper is disabled because pipewire-pulse (from the pipewire recipe) already provides the PulseAudio client surface. Per local/AGENTS.md Rule 2, all Red Bear-specific edits to upstream wireplumber live as external patches in local/patches/wireplumber/ (currently: 01 — Red Bear port README). The previous source fork at local/sources/wireplumber/ is preserved as historical reference but is no longer used by the build system."