RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process
freebsd fixes
oxydizerdcbaec13ec78
diff --git a/docs/plans/freebsd.md b/docs/plans/freebsd.mdindex 794d5ef..c384cee 100644--- a/docs/plans/freebsd.md+++ b/docs/plans/freebsd.md@@ -3,7 +3,10 @@Status: draft, 2026-11-05. The Linux-side preparation (P.1–P.4, P.7–P.10) isdone, P.5 and P.6 are open. The FreeBSD parts of `platform` are written andthe whole tree cross-compiles for `x86_64-freebsd` (Debug, ReleaseSafe, tests;-see Validation), but nothing has run on FreeBSD yet. Decisions D1–D6 are open.+see Validation). The third outside build (fa55c2a, FreeBSD 15.1 VM without a DRM+render device) builds Debug and ReleaseSafe and passes the platform tests, but+the compositor stops at renderer initialisation, so only unit tests have run.+Decisions D1–D6 are open.Goal: run RediWM on FreeBSD: first the compositor in a seatd session on DRM,then the shell features and apps, and last `rediwm-dm` and packaging. Linux@@ -38,15 +41,24 @@ union, 16-bit `mode_t`, `landlock.h`, `pty.h`, `MADV_DONTDUMP`, `pam_start_confd`cmsghdr` is 12 bytes, its data starts at 16). All are fixed except what thenext paragraph lists.On 15.1 `sys/inotify.h`, `sys/timerfd.h`, `sys/eventfd.h` and `cr_pid` in-`sys/ucred.h` exist (header checks only). Not known yet: `memfd_create`, the-transfers helper's C++ flags under clang and libc++, whether `cr_pid` is filled-for a unix-socket peer, whether the kqueue child handles behave in the Wayland-loop (libepoll-shim), and whether a DRM session or the headless GLES2 path-works. The second tester log also showed a Debug `rediwm-cursorgen` dying with+`sys/ucred.h` exist (header checks only). The platform tests now pass on 15.1, among them kqueue child+exits and reaping, watchers and the `cr_pid` of a unix-socket peer. Not known+yet: `memfd_create`, the transfers helper's C++ flags under clang and libc++,+whether the kqueue child handles behave in the Wayland loop (libepoll-shim),+and whether a DRM session or the headless GLES2 path works: wlroots'+renderer needs a DRM render node (`drmGetDevices2 failed`), which the qemu VM+lacks, so `rediwm-msg` and the Files lifecycle are untested. The second tester log also showed a Debug `rediwm-cursorgen` dying with`Undefined symbol "environ"` while its ReleaseSafe build ran, so the build nowdefaults to LLVM on FreeBSD; confirm it. Two tests failed at run time: theD-Bus fd test (fixed, the offset above) and the images decoder test (probablya gdk-pixbuf port without the PNM loader; the test now skips there).+The third run failed in five places, all tests: the system monitor's `/proc`+readers (no procfs; they skip until P.6), the battery event test (raw Linux+syscalls; now libc), the polkit helper's backpressure test (its fill loop+stopped at 64 KiB; longer now, unverified on FreeBSD), the editor view tests+(row height 5 px; probably no monospace font in the VM, unchecked) and Files+collation (`de_DE` and `ru_RU` sort `Élan` and `Ёж` before `Apfel`; open, it+would misorder Files listings).### Interfaces still to portdiff --git a/src/polkit/helper.zig b/src/polkit/helper.zigindex 7cabfcd..65cdfe7 100644--- a/src/polkit/helper.zig+++ b/src/polkit/helper.zig@@ -430,7 +430,8 @@ test "helper preserves a backpressured response until cancellation erases it" {try std.testing.expectEqual(0, c.setsockopt(helper.fd, c.SOL_SOCKET, c.SO_SNDBUF, &size, @sizeOf(c_int)));const padding = @as([4096]u8, @splat(0));var full = false;- for (0..16) |_| {+ // Unix stream buffers differ by OS (FreeBSD's default is at least 64 KiB).+ for (0..4096) |_| {const n = c.send(helper.fd, &padding, padding.len, c.MSG_NOSIGNAL);if (n < 0) {try std.testing.expectEqual(std.posix.E.AGAIN, std.posix.errno(n));diff --git a/src/system_monitor_tests.zig b/src/system_monitor_tests.zigindex e2e3f6a..a30e471 100644--- a/src/system_monitor_tests.zig+++ b/src/system_monitor_tests.zig@@ -1,10 +1,17 @@const std = @import("std");+const builtin = @import("builtin");const platform = @import("platform");const proc = @import("system_monitor/proc.zig");const model = @import("system_monitor/model.zig");const collector = @import("system_monitor/collector.zig");const actions = @import("system_monitor/actions.zig");+/// These read /proc, which FreeBSD does not mount by default; the collector+/// port is plan P.6.+fn needsProcfs() !void {+ if (builtin.os.tag != .linux) return error.SkipZigTest;+}+test "monitor stat parsing preserves tricky names and rejects partial data" {const stat = proc.parseStat("123 (a ) strange\nname) S 1 2 3 4 5 6 7 8 9 10 100 50 0 0 20 0 1 0 987654 10000 42\n").?;try std.testing.expectEqualStrings("a ) strange\nname", stat.name);@@ -83,6 +90,7 @@ test "monitor history holds only the last 60 seconds including pause gaps" {try std.testing.expectEqual(@as(usize, 1), history.count);}test "monitor action authority rejects changed identities and protects session executables" {+ try needsProcfs();try std.testing.expect(proc.protectedName("/usr/bin/rediwm-session"));try std.testing.expect(proc.protectedName("/usr/bin/rediwm (deleted)"));try std.testing.expect(!proc.protectedName("/usr/bin/rediwm-files"));@@ -93,6 +101,7 @@ test "monitor action authority rejects changed identities and protects session etry std.testing.expectError(error.ProtectedProcess, actions.execute(.{ .pid = proc.c.getpid(), .start = own.start }, .force));}test "monitor real collection includes its background worker owner and cancels" {+ try needsProcfs();var generation = std.atomic.Value(u64).init(0);const snap = try collector.sample(&generation, 0);defer snap.deinit();@@ -106,6 +115,7 @@ test "monitor real collection includes its background worker owner and cancels"}test "monitor pidfd actions terminate only disposable fixtures and force a TERM-ignoring fixture" {+ try needsProcfs();const io = std.testing.io;var child = try std.process.spawn(io, .{ .argv = &.{ "/bin/sleep", "30" } });defer child.kill(io);diff --git a/src/taskbar/battery_tests.zig b/src/taskbar/battery_tests.zigindex a5bb552..40ad29e 100644--- a/src/taskbar/battery_tests.zig+++ b/src/taskbar/battery_tests.zig@@ -1,5 +1,5 @@const std = @import("std");-const linux = std.os.linux;+const c = @import("c");const battery = @import("battery.zig");const State = battery.State;const Snapshot = battery.Snapshot;@@ -27,18 +27,18 @@ test "only system power_supply uevents trigger a read" {}test "draining reports a queued power_supply event once and stops at EAGAIN" {- var fds: [2]i32 = undefined;- try std.testing.expectEqual(linux.E.SUCCESS, linux.errno(linux.socketpair(linux.AF.UNIX, linux.SOCK.DGRAM | linux.SOCK.NONBLOCK | linux.SOCK.CLOEXEC, 0, &fds)));+ var fds: [2]c_int = undefined;+ try std.testing.expectEqual(@as(c_int, 0), c.socketpair(c.AF_UNIX, c.SOCK_DGRAM | c.SOCK_NONBLOCK | c.SOCK_CLOEXEC, 0, &fds));defer for (fds) |fd| {- _ = std.posix.system.close(fd);+ _ = c.close(fd);};const usb = "add@/devices/usb1\x00SUBSYSTEM=usb\x00";const ac = "change@/devices/AC0/power_supply/AC0\x00SUBSYSTEM=power_supply\x00";try std.testing.expect(!drainUevents(fds[0]));- _ = linux.sendto(fds[1], usb, usb.len, 0, null, 0);+ _ = c.send(fds[1], usb, usb.len, 0);try std.testing.expect(!drainUevents(fds[0]));- _ = linux.sendto(fds[1], ac, ac.len, 0, null, 0);- _ = linux.sendto(fds[1], usb, usb.len, 0, null, 0);+ _ = c.send(fds[1], ac, ac.len, 0);+ _ = c.send(fds[1], usb, usb.len, 0);try std.testing.expect(drainUevents(fds[0]));try std.testing.expect(!drainUevents(fds[0]));}