Skip to content

refactor: Split Linux OS/sysfs backends into separate translation units - #2216

Open
Renkoto wants to merge 12 commits into
flightlessmango:masterfrom
Renkoto:pr2-backends
Open

Renkoto wants to merge 12 commits into
flightlessmango:masterfrom
Renkoto:pr2-backends

Conversation

@Renkoto

@Renkoto Renkoto commented Nov 17, 2026

Copy link
Copy Markdown

In preparation for supporting non-Linux Unix targets (such as FreeBSD), this PR separates Linux-specific /proc, /sys, and inotify data collection from the platform-independent HUD, logging, and overlay logic.

Summary of Changes

  • Platform backend extraction: Split OS-specific implementations into *_linux.cpp (and *_common.cpp where shared state/helpers live) while keeping existing headers as the internal interface:
    • gpu.cpp -> gpu_linux.cpp (gpu_enumerate())
    • amdgpu.cpp -> amdgpu_linux.cpp (AMDGPU::platform_init(), get_instant_metrics(), get_sysfs_metrics())
    • file_utils.cpp -> file_utils_linux.cpp (get_exe_path(), get_proc_comm(), get_proc_cmdline(), is_wine_loader(), lib_loaded())
    • cpu.cpp -> cpu_common.cpp (shared calculateCPUData(), constructors, Reinit(), cpuStats instance)
    • memory.cpp -> memory_common.cpp (shared memory metric globals)
    • iostats.cpp -> iostats_linux.cpp (read_io_counters())
    • net.cpp -> net_linux.cpp (net_list_interfaces(), net_read_counters())
    • notify.cpp -> notify_linux.cpp (notify_open(), notify_watch(), notify_poll(), notify_close())
    • overlay.cpp -> system_info_linux.cpp (get_system_info())
  • Preprocessor guards: Replace #ifdef __linux__ with #ifndef _WIN32 in common Unix code paths as suggested by FreeBSD support (part one: preparation) #652 (comment) (hud_elements.cpp, overlay.cpp, vulkan.cpp, shell.h, app/main.cpp, etc.), while keeping Linux-only synchronization primitives (esync/fsync/ntsync in winesync.h) restricted to __linux__ (Note that FreeBSD's own implementation of ntsync is expected to arrive in 15.2 RELEASE, but I left it aside because this is about Linux.).
  • Build wiring (src/meson.build): Add the new *_linux.cpp and *_common.cpp translation units to vklayer_files on Unix targets.

Purpose of this

This refactor is intended to preserve existing Linux behavior without regressions, however, I don't have a Linux install to validate it personally; in theory nothing should change functionally, but i'm open to any suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant