From: Stuart Henderson Subject: Re: kinfocenter: replace sysconf with sysctl To: Rafael Sadowski Cc: ports@openbsd.org Date: Sun, 28 Dec 2025 13:14:16 +0000 On 2025/12/28 13:55, Rafael Sadowski wrote: > Simple diff to replace sysconf with sysctl in > MemoryEntry::calculateAvailableRam() and MemoryEntry::calculateTotalRam(). why? > Feedback, OK? > > Index: Makefile > =================================================================== > RCS file: /cvs/ports/x11/kde-plasma/kinfocenter/Makefile,v > diff -u -p -u -p -r1.10 Makefile > --- Makefile 22 Feb 2025 14:34:43 -0000 1.10 > +++ Makefile 28 Dec 2025 12:50:38 -0000 > @@ -1,5 +1,6 @@ > COMMENT = core components for the KDE Activity concept > DISTNAME = kinfocenter-${VERSION} > +REVISION = 0 > > WANTLIB += ${COMPILER_LIBCXX} GL KF6AuthCore KF6ColorScheme KF6Completion > WANTLIB += KF6ConfigCore KF6ConfigGui KF6ConfigWidgets KF6CoreAddons > Index: patches/patch-Modules_about-distro_src_MemoryEntry_cpp > =================================================================== > RCS file: /cvs/ports/x11/kde-plasma/kinfocenter/patches/patch-Modules_about-distro_src_MemoryEntry_cpp,v > diff -u -p -u -p -r1.5 patch-Modules_about-distro_src_MemoryEntry_cpp > --- patches/patch-Modules_about-distro_src_MemoryEntry_cpp 4 Jul 2025 05:47:07 -0000 1.5 > +++ patches/patch-Modules_about-distro_src_MemoryEntry_cpp 28 Dec 2025 12:50:38 -0000 > @@ -12,15 +12,36 @@ Index: kcms/about-distro/src/MemoryEntry > #include > #include > // clang-format on > -@@ -58,6 +59,11 @@ std::optional MemoryEntry::calculateTotalRa > +@@ -58,6 +59,14 @@ std::optional MemoryEntry::calculateTotalRa > } > > return totalBytes; > +#elif defined(Q_OS_OPENBSD) > -+ long phys_pages = sysconf(_SC_PHYS_PAGES); > -+ long pagesize = sysconf(_SC_PAGESIZE); > -+ if (phys_pages != -1 && pagesize != -1) > -+ return ((uint64_t)phys_pages * (uint64_t)pagesize); > ++ int64_t memSize = 0; > ++ size_t sz = 0; > ++ int physmem_mib[] = {CTL_HW, HW_PHYSMEM64}; > ++ sz = sizeof(memSize); > ++ if (sysctl(physmem_mib, 2, &memSize, &sz, NULL, 0) == 0) { > ++ return memSize; > ++ } > #endif > > /* > +@@ -80,11 +89,12 @@ std::optional MemoryEntry::calculateAvailab > + return qlonglong(info.totalram) * info.mem_unit; > + } > + #elif defined(Q_OS_FREEBSD) > +- /* Stuff for sysctl */ > +- unsigned long memory; > +- size_t len = sizeof(memory); > +- if (sysctlbyname("hw.physmem", &memory, &len, NULL, 0) == 0) { > +- return memory; > ++ int64_t memSize = 0; > ++ size_t sz = 0; > ++ int usermem_mib[] = {CTL_HW, HW_USERMEM64}; > ++ sz = sizeof(memSize); > ++ if (sysctl(usermem_mib, 2, &memSize, &sz, NULL, 0) == 0) { > ++ return memSize; > + } > + #endif > + >