Repository navigation
feat(libc): add libc++ string __grow_by, copy assignment and operator+ - #27578
kiansaeidnia wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Change: Feature Merge Risk:
|
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The change adds three basic_string<char> ABI exports and focused guest tests; I found no verified blocking defect in the changed code, but did not run the checks.
What I ran
Reviewed head 4c9b67c2b4c27298d3a7a67c40886c4f4cfebd07 using repo_read.py to inspect the prepared diff and targeted source context. No build, test, or merged-preview check was run. No commands were supplied as raw output.
Results
| Check | Result | Note |
|---|---|---|
| Changed code review | passed | Six changed files read |
| Build and tests | not run | No execution environment used |
| Merged preview | not run | No merge check performed |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author reports Windows 11/MinGW tests, a Linux syntax check, and a debt_fold.py --check pass; these were not independently run. Azahar core behavior and the firmware provider are unmeasured per the debt note. No files were excluded from this review: all six changed files listed by the review manifest were read. No separate files-exclusion listing was available in the review folder.
To get this to a good state
Nothing is required.
|
Reviewed I found no other defect. |
Plyxen
left a comment
There was a problem hiding this comment.
Checked head 4c9b67c2b4. I applied it to main ad7582bad4 together with #27581 and #27579, two other libc++ additions from tonight, which apply cleanly alongside it. On Windows 11 with WinLibs GCC 15.2 (Release), tools/check_conventions.py --head on each head and tools/debt_fold.py --check passed, the build succeeded, and all 4,932 CPU tests passed (I left out the GPU tests).
guest_libcxx_string_growth passed. The exports are new, so on main the test can't link without the change.
I compared the three bodies with LLVM libc++ 17.0.6. __grow_by uses max_size() = UINT64_MAX - 16, the same capacity choice, and copies the two segments. Like libc++, it leaves the size word alone for the caller to set. Copy assignment follows __assign_no_alias for both target forms, reusing the buffer when size < cap and growing through __grow_by_and_replace otherwise. operator+ builds through the __uninitialized_size_tag path, zeroing the short form. The invalid_argument throws for unreadable or inconsistent representations follow the merged LibcxxStringErase.cpp.
AI-assisted: yes (Claude Code)
Progress report (68f3c90 → 4c9b67c)📈 System libraries: 47.36% (+0.01%, +3 implemented functions) ✅ 3 implemented
Changed libraries (implemented exports)
|
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
ligmaSec
left a comment
There was a problem hiding this comment.
The Linux GuestLibcxxStringGrowth fixture passed with the exact implementation. It checks the libc++ representation for both short and heap-backed strings, the retained and newly allocated copy-assignment paths, and allocation cleanup through the guest heap.
AI-assisted: yes.
What
The RetroArch Azahar core (PPSA99169, import inventory on #5927) imports three libc++
basic_string<char>members that libc did not define. This PR adds them in the newLibcxxStringGrowth.cpp, on the 24-byte libc++ layout the other libc++ string exports use:__grow_by(old_cap, delta_cap, old_sz, n_copy, n_del, n_add);operator=(const basic_string&);operator+(const char*, const basic_string&).They follow LLVM libc++ 17.0.6
include/string:max_size()isUINT64_MAX - 16and__recommendroundss + 1up to 16, minus one.__recommend(max(old_cap + delta_cap, 2 * old_cap)), ormax_size() - 1onceold_capreachesmax_size() / 2 - 16.__grow_bycopies the firstn_copybytes and the tail aftern_del, frees the old buffer only when it was long, and leaves the size word alone, as libc++ 17 does.n < capacity, and otherwise grows the way__grow_by_and_replacedoes, with its- 1length check.operator+builds the result with the libc++ capacity for the total length.length_errorandbad_allocare thrown where libc++ throws them. Storage comes from the guestoperator newandoperator delete.Input that no libc++ caller passes, such as an
old_capthat does not match the string's capacity or counts beyond its size, throwsinvalid_argumentinstead of writing out of bounds, as the existingLibcxxStringErase.cppdoes. Thewchar_t__grow_byimport is left out, because its element width is not settled. The debt fragment records that and says the console provider is unmeasured.This does not touch the open libc++ string series (#25674, #25708, #25744, #25750, #25759, #25763): none of them defines these three names, and the shared files only get lines added at different places. #25674's
reserverejects sizes aboveUINT64_MAX - 17, one less than the 17.0.6max_size()this PR uses. That difference belongs to #25674.pr_overlapreported one conflict: #27016 (libc++to_string(float)) adds its declaration at the same place inApi.hpp. The declarations here now sit just above theerasedeclaration, so the two merge cleanly in either order (checked withgit merge-tree). It could not comparelibc/CMakeLists.txtorApi.hppwith #7447, #7715, #8150, #8965, #11831, #12682, #12688, #12700, #12717, #12849, #12965, #16791, #17557, #18135, #19181, #23395, #24322, #24910, #24917, #25289 and #26224, because those PRs conflict withmain. I searched their diffs, and none adds these names orLibcxxStringGrowth.cpp.Tested
Windows 11, MinGW-w64 GCC 16.2, Release. The new
guest_libcxx_string_growthpasses, and so doguest_libcxx_string_eraseandguest_libcxx_string_find.The new test checks:
__grow_byfrom short and long strings, with copied, deleted and added ranges and the exact capacity words;max_size() - 1capacity branch, using a hand-made long string near the limit that must givebad_allocwith the string unchanged. With that branch removed, the test aborts;length_errorpastmax_size()for all three members;operator+with short and long results and embedded NULs on the right;invalid_argumentfor inconsistent sizes, a null left operand and an invalid long string.LibcxxStringGrowth.cppand the test were syntax-checked with g++ 11 on Linux (WSL Ubuntu).debt_fold.py --checkpasses. Not tested in the Azahar core itself.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