On Fri Nov 10, 2023 at 03:48:10PM +0100, Rafael Sadowski wrote: > low hanging fruits ... OK? >
Here is a more complete version. diff --git a/devel/kf5/kcoreaddons/Makefile b/devel/kf5/kcoreaddons/Makefile index ca11f306cab..7bd262e896d 100644 --- a/devel/kf5/kcoreaddons/Makefile +++ b/devel/kf5/kcoreaddons/Makefile @@ -1,5 +1,6 @@ COMMENT = core KDE extensions to Qt classes DISTNAME = kcoreaddons-${VERSION} +REVISION = 0 SHARED_LIBS = KF5CoreAddons 9.0 @@ -21,6 +22,9 @@ TESTS_IS_INTERACTIVE = X11 DEBUG_PACKAGES = ${BUILD_PACKAGES} +# TODO impl +# src/lib/util/kprocesslist_unix.cpp + # gamin is totally unmaintained low quality software CONFIGURE_ARGS = -DCMAKE_DISABLE_FIND_PACKAGE_FAM=ON diff --git a/devel/kf5/kcoreaddons/patches/patch-src_lib_util_kmemoryinfo_cpp b/devel/kf5/kcoreaddons/patches/patch-src_lib_util_kmemoryinfo_cpp new file mode 100644 index 00000000000..f46921a009b --- /dev/null +++ b/devel/kf5/kcoreaddons/patches/patch-src_lib_util_kmemoryinfo_cpp @@ -0,0 +1,101 @@ +Index: src/lib/util/kmemoryinfo.cpp +--- src/lib/util/kmemoryinfo.cpp.orig ++++ src/lib/util/kmemoryinfo.cpp +@@ -27,6 +27,17 @@ Q_LOGGING_CATEGORY(LOG_KMEMORYINFO, "kf.coreaddons.kme + #include <fcntl.h> + #include <kvm.h> + #include <sys/sysctl.h> ++#elif defined(Q_OS_OPENBSD) ++ #include <sys/mount.h> ++ #include <sys/param.h> /* DEV_BSIZE PZERO */ ++ #include <sys/swap.h> ++ #include <sys/syscall.h> ++ #include <sys/sysctl.h> ++ ++ #include <stdio.h> ++ #include <stdlib.h> ++ #include <strings.h> ++ #include <unistd.h> + #endif + // clang-format on + +@@ -414,6 +425,79 @@ bool KMemoryInfo::update() + d->m_freeSwapFile = swap_free; + d->m_cached = pageSize * v_cache_count + zfs_arcstats_size; + d->m_buffers = vfs_bufspace; ++ ++ return true; ++} ++ ++#elif defined(Q_OS_OPENBSD) ++/***************************************************************************** ++ * OpenBSD ++ ****************************************************************************/ ++// From src/usr.bin/top/machine.c ++static int ++swap_usage(int *used, int *total) ++{ ++ struct swapent *swdev; ++ int nswap, rnswap, i; ++ ++ nswap = swapctl(SWAP_NSWAP, nullptr, 0); ++ if (nswap == 0) ++ return 0; ++ ++ swdev = static_cast<struct swapent*>(calloc(nswap, sizeof(*swdev))); ++ if (swdev == NULL) ++ return 0; ++ ++ rnswap = swapctl(SWAP_STATS, swdev, nswap); ++ if (rnswap == -1) { ++ free(swdev); ++ return 0; ++ } ++ /* Total things up */ ++ *total = *used = 0; ++ for (i = 0; i < nswap; i++) { ++ if (swdev[i].se_flags & SWF_ENABLE) { ++ *used += (swdev[i].se_inuse / (1024 / DEV_BSIZE)); ++ *total += (swdev[i].se_nblks / (1024 / DEV_BSIZE)); ++ } ++ } ++ free(swdev); ++ return 1; ++} ++ ++bool KMemoryInfo::update() ++{ ++ // total available phsycial memory ++ const long phys_pages = sysconf(_SC_PHYS_PAGES); ++ const long pagesize = sysconf(_SC_PAGESIZE); ++ if (phys_pages != -1 && pagesize != -1) ++ d->m_availablePhysical = ((uint64_t)phys_pages * (uint64_t)pagesize / 1024); ++ ++ int swap_free = 0; ++ int swap_tot = 0; ++ if (swap_usage(&swap_free, &swap_tot)) ++ { ++ d->m_totalSwapFile = swap_tot; ++ d->m_freeSwapFile = swap_free; ++ } ++ ++ int uvmexp_mib[] = {CTL_VM, VM_UVMEXP}; ++ struct uvmexp uvmexp; ++ size_t size= sizeof(uvmexp); ++ if (sysctl(uvmexp_mib, 2, &uvmexp, &size, NULL, 0) == -1) { ++ bzero(&uvmexp, sizeof(uvmexp)); ++ return false; ++ } ++ d->m_freePhysical = uvmexp.free * pagesize / 1024; ++ ++ int bcstats_mib[] = {CTL_VFS, VFS_GENERIC, VFS_BCACHESTAT}; ++ struct bcachestats bcstats; ++ size = sizeof(bcstats); ++ if (sysctl(bcstats_mib, 3, &bcstats, &size, NULL, 0) == -1) { ++ bzero(&bcstats, sizeof(bcstats)); ++ return false; ++ } ++ d->m_cached = bcstats.numbufpages * pagesize / 1024; + + return true; + }