feat(libc): implement valloc #27565
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27565"
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 gnavarro24 on 2026-11-26T18:15:34Z.
What
Implements
valloc, a page-aligned allocation that follows FreeBSD 11.4'svalloc.cat the pinned commit: it callsposix_memalignwith the alignment fromgetpagesizeand returns null on failure. Adds a guest test (guest_libc_valloc) and a technical-debt fragment for the page size, which is not measured on the PS5.Tested
Not run on PS5 or in the guest test runner. On macOS the implementation and the test compile with
clang++ -std=c++20 -fsyntax-only; the guest testguest_libc_vallocruns in CI.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-26T18:22:37Z.
Review: COMMENTED
Actionable comments posted: 2
d1a539ca-1965-4828-8ad2-6027c2d5d3ebReviewing files that changed from the base of the PR and between
c136f2d58band9cea856796.core/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/include/Api.hppcore/libs/prx/libc/src/Valloc.cppcore/libs/prx/libc/tests/cmake/guest_libc_valloc.cmakecore/libs/tests/GuestLibcValloc.cppdocs/dev/debt/changes/feat-libc-valloc.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T18:24:13Z.
Review: APPROVED
Reviewed — looks good
The implementation follows the documented
vallocbehavior and its guest test checks alignment and usable memory; I found no verified blocking defect in the files reviewed.What I ran
Reviewed head
9cea856796f11b04ca9270df0d4071c2c4f7583d. Read the prepared description, commits, diff and manifest, all six changed files, plus the allocator and page-size implementations and libc test-fragment discovery. No build or tests were run in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The macOS syntax-only compile and CI guest test mentioned in the PR description were not run or independently confirmed. No PS5 execution was performed. All files listed as reviewed in
manifest.jsonwere read; no changed file was excluded.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T01:17:40Z.
Review: APPROVED
Reviewed — looks good
The implementation follows the described valloc behavior at the pinned head; I found no verified blocking defect in the files reviewed.
What I ran
Read the prepared diff and targeted source at head
6c436b9aeb899243f77c8a7dfd4aaeecc1e205f7. No build or test command was run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No build, guest test, or PS5 runtime check was run. All six changed files listed in the manifest were read; no changed files were excluded.
files.jsonwas not available through the reader.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-27T03:31:10Z.
Review: APPROVED
Checked head
6c436b9aeb, applied alone tomainad7582bad4. On Windows 11 with WinLibs GCC 15.2 (Release),tools/check_conventions.py --headandtools/debt_fold.py --checkpassed, the build succeeded, and all 4,931 CPU tests passed (I left out the GPU tests).guest_libc_vallocpassed.mainhas novalloc, so the test can't link without this change.FreeBSD 11.4's
vallocisposix_memalign(&ret, getpagesize(), size), returning null on error. This matches it with the page size fixed at 0x4000, the valuegetpagesize_nid_postfixreturns, so libc doesn't reach into libkernel, which fixes CodeRabbit's Major point. The licence notice and the pinned upstream link are at the top ofValloc.cpp. CodeRabbit'sBUILD_TESTINGpoint is still open. 22 fragments inlibc/tests/cmakeonmainskip the guard as well (for exampleguest_complex_trigandguest_tree_search), so this follows existing practice, and a guard is a separate cleanup.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T13:53:49Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the optional point below is for follow-up.
What I ran
Reviewed head
32ef7bbd96f063399d5baf0a94798ce8bad09347usingrepo_read.pyto inspect the prepared diff and source context. No build or tests were run. The description reports a macOS syntax-only compile and a guest test run in CI; those were not run as part of this review.Results
Findings
Blocking
None.
Non-blocking
vallocuses the same 16 KiB constant asgetpagesize; the debt note already records that the console page size has not been measured. Confirm that value against console behavior when suitable evidence becomes available.core/libs/prx/libc/src/Valloc.cpp:36Not verified
No commands, build, or tests were run. PS5 console behavior and the CI guest test result were not independently confirmed. All files listed as reviewed in the manifest were read:
core/libs/prx/libc/CMakeLists.txt,core/libs/prx/libc/include/Api.hpp,core/libs/prx/libc/src/Valloc.cpp,core/libs/prx/libc/tests/cmake/guest_libc_valloc.cmake,core/libs/tests/GuestLibcValloc.cpp, anddocs/dev/debt/changes/feat-libc-valloc.md.files.jsonand any files excluded from the prepared diff were not read.To get this to a good state
Nothing is required. Optional follow-up: verify the page-size constant against the console.
Imported from boykopovar/AnyPS5. Originally posted by GalaxyGamingFR on 2026-11-30T23:34:38Z.
Review: APPROVED
Verified on Linux (Ubuntu 26.04.1, GCC 15.2.0, Ninja, Release). I merged head
32ef7bbd96into currentmaintogether with #27565, #27243 and #27682 (no conflicts between them).ninja core/libs/prx/libc/all core/libs/prx/libSceLibcInternal/all) built cleanly.guest_environment_binding_unloadskipped as on main. The full libSceLibcInternal set passed, 134/134.guest_libc_vallocpassed. The allocation uses the guest's 16 KiB page (0x4000), consistent with the rest of the project's guest page size.No problems found.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T08:51:48Z.
Review: COMMENTED
The Linux
GuestLibcVallocfixture passed with an initialized guest heap. Both zero-size and multipage allocations met the guest page alignment, and the fixture wrote the full multipage allocation and released both throughfree_nid_postfix.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.