From: Pino Toscano Date: Fri, 3 Jul 2026 06:31:51 +0000 (+0200) Subject: [PATCH] KMemoryInfo: add basic GNU/Hurd support X-Git-Tag: archive/raspbian/6.26.0-2+rpi1^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e6f92ced4b5268122a593ed5e8ac79033fb505b8;p=kf6-kcoreaddons.git [PATCH] KMemoryInfo: add basic GNU/Hurd support Add a basic support for reading the memory details on GNU/Hurd. The swap support is not implemented yet, as it requires a bit more work (i.e. query the default pager); since there are no users of the swap APIs currently, then it can be implemented at a later stage if needed. Gbp-Pq: Name upstream_KMemoryInfo-add-basic-GNU-Hurd-support.patch --- diff --git a/src/lib/util/kmemoryinfo.cpp b/src/lib/util/kmemoryinfo.cpp index 35b5384..2dd3ebd 100644 --- a/src/lib/util/kmemoryinfo.cpp +++ b/src/lib/util/kmemoryinfo.cpp @@ -39,6 +39,13 @@ Q_LOGGING_CATEGORY(LOG_KMEMORYINFO, "kf.coreaddons.kmemoryinfo", QtWarningMsg) #include #include #include +#elif defined(Q_OS_HURD) + extern "C" { + #include + #include + #include + #include + } #endif // clang-format on @@ -512,6 +519,35 @@ bool KMemoryInfo::update() return true; } + +#elif defined(Q_OS_HURD) +/***************************************************************************** + * GNU/Hurd + ****************************************************************************/ + +bool KMemoryInfo::update() +{ + vm_statistics_data_t vmstats; + vm_cache_statistics_data_t cache_stats; + + if (vm_statistics(mach_task_self(), &vmstats) != 0) { + return false; + } + + if (vm_cache_statistics(mach_task_self(), &cache_stats) != 0) { + return false; + } + + d->m_totalPhysical = static_cast(vmstats.free_count + vmstats.active_count + vmstats.inactive_count + vmstats.wire_count) * PAGE_SIZE; + d->m_freePhysical = static_cast(vmstats.free_count) * PAGE_SIZE; + d->m_totalSwapFile = 0; // TODO + d->m_freeSwapFile = 0; // TODO + d->m_cached = static_cast(cache_stats.cache_count) * PAGE_SIZE; + d->m_buffers = 0; + d->m_availablePhysical = d->m_totalPhysical - d->m_freePhysical; + + return true; +} #else /***************************************************************************** * Unsupported platform