feat(libkernel): implement sysctl and sysctlbyname for hw.ncpu #1685
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1685"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by overlordxrz-source on 2026-10-08T16:23:22Z.
What
ScreenTester5 (PPSA69420, Marice/ScreenTester5 01.000.000) stops at start-up on
mainwith, as reported in #1578:MhC53TKmjVAissysctlbyname(tools/nid_names.py). The title also importssysctl(DFmMT80xcNI). In the #1578 audit,sysctlis absent for 27 of the 34 catalog titles andsysctlbynamefor 14. The onlyhw./kern./vm.sysctl name string in PPSA69420'seboot.binishw.ncpu, which SDL2'sSDL_GetCPUCountreads withsysctlbyname.System/src/SystemConfiguration.cppnow exports both functions, but only forhw.ncpu(CTL_HW.HW_NCPU, MIB{6, 3}). It reports the same count assysconf(_SC_NPROCESSORS_ONLN). Every other name or MIB throws with the name or MIB in the message, so the next one a title needs shows up in its log. The rest follows FreeBSD'skern_sysctl.c:CTL_MAXNAME(24) givesEINVAL. A null name givesEFAULT.oldpstores the required size in*oldlenp.*oldlenpis set to the bytes copied, withENOMEM.hw.ncpuis read-only, so a non-nullnewpgivesEPERM.errnois left alone on success.Per review on #1405, nothing beyond what this title reaches is included. Other
hw.*/kern.*nodes, such ashw.physmem, wait until a title stops on them.Log
From #1578 (Windows,
main1081602d,relinker --windows):FAIL: unresolved ELF import MhC53TKmjVA from libkernel.prxfor PPSA69420.@LeandroLP23 ran the title with this PR (Windows 11, Radeon 860M, MinGW-w64 GCC 15.2.0, Release,
main4b6ab6bb, title relinked withrelinker --windows). Onmainit stops atMhC53TKmjVA(sysctlbyname). With this PR it gets past it and stops at the next import:KiJEPEWRyUYissigaction, which touches the signal masks #1431 is reworking, so it is left out of this PR.Tested
aarch64 Debian 13 host. The full project cannot be built here because it needs x86-64.
core/libs/tests/GuestSystemConfiguration.cppgainsCheckProcessorCountSysctl. It covers the size query, the read through both entry points, the partial copy withENOMEM,EPERM,EINVAL,EFAULT, an unchangederrnoon success, and the throw for an unknown name and an unknown MIB. Linked withSystemConfiguration.cpp, it passes natively against glibc.sysctl_nid_postfixandsysctlbyname_nid_postfixare undefined). Three mutants of the new code each make it abort: noENOMEMon a short buffer, noEPERMonnewp, and a wrong size query.SystemConfiguration.cppand the test compile for x86_64-linux-gnu and x86_64-windows-gnu with-Wall -Wextra(Zig 0.17 clang) without warnings.python3 tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T16:25:49Z.
Progress report (
4b005b2→1879862)📈 System libraries: 84.77% (+0.01%, +2 implemented functions)
✅ 2 implemented
sysctl_nid_postfixsysctlbyname_nid_postfixImported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-08T20:16:19Z.
Run with the title on Windows. ScreenTester5 (PPSA69420 01.000.000) on
mainstops atFAIL: unresolved ELF import MhC53TKmjVA from libkernel.prx(sysctlbyname). With this PR merged it gets past it and stops at the next import,FAIL: unresolved ELF import KiJEPEWRyUY from libkernel.prx(sigaction), which touches the signal masks #1431 is reworking.Windows 11, Radeon 860M, MinGW-w64 GCC 15.2.0, Release,
main4b6ab6bb; title relinked withrelinker --windowsand run with the patchedbuild/core/libs/libs/*.prx.Tested with AI assistance (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by overlordxrz-source on 2026-10-09T04:13:38Z.
@LeandroLP23 thanks for running it with the title. That's the stop line this PR was missing. I've added your run to the Log and Tested sections.
sigaction(KiJEPEWRyUY) is next, but it touches the signal masks #1431 is reworking, so I'm leaving it out of this PR.Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T10:03:58Z.
First Windows run, since the description says it wasn't tested on Windows.
Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Merged onto
mainb7218b3ctogether with nine other small libc/libkernel PRs: #1975, #1976, #1977, #1859, #1676, #1675, #1641, #1656, #1807.guest_system_configurationpasses.🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:20:10Z.
Checked on Linux (PR merged onto current
main): build + full ctest green,guest_system_configurationpasses and fails to link without the change. No overlap with open PRs (#2090 touches the same test file, merges cleanly). Error handling matches FreeBSDkern_sysctl.c; unmodelled names/MIBs throw. Windows run on a real title by @LeandroLP23 and ctest by @popcoder565 confirm the rest. Merging.