Repository navigation
feat(libc): add C23 leading and trailing zero counts - #12193
Conversation
Progress report (09d952f → 504111f)📈 System libraries: 46.6% (+0.04%, +10 implemented functions) ✅ 10 implemented
Changed libraries (implemented exports)
|
MarcZX10
left a comment
There was a problem hiding this comment.
Independent exact-head review of 504111f10c8bc83a8a9ae36a85bdd03c124528b5: the ten exports use the correct width-specific C++20 operations, zero-input widths and ul 64-bit PS5 ABI; all ten NIDs independently match tools/nid_names.py. The public-header audit passes (368 libraries, 12,994 exports), conventions and diff checks pass, the merge preview against current main is clean, and both changed C++ files pass GCC 12 C++20 syntax-only compilation. The official overlap scan found no confirmed duplicate or code-line overlap; its 39 historical-branch warnings are confined to shared/conflicted files. I checked the warned PR diffs for these ten names; #5021 exceeds GitHub’s 300-file diff limit, but its paginated changed-file list and relevant CMake/debt hunks do not touch the new declarations or implementations. Author-reported exhaustive fixed-width/random tests and original-binary comparisons are detailed in the PR. Hosted policy checks, Linux/Windows/macOS relinker and register-context jobs, and macOS write-watch jobs pass; the full Windows build is still pending, while Linux full build is skipped by path selection. I found no code blocker in the review completed so far; I’m leaving this as a comment until the Windows build finishes.
MarcZX10
left a comment
There was a problem hiding this comment.
The full Windows build has now completed successfully on the same reviewed head 504111f10c8bc83a8a9ae36a85bdd03c124528b5; the earlier Linux/macOS relinker, register-context, write-watch, and policy checks also passed. My exact-head review found no code blocker, and the independent NID, public-header, convention, syntax, merge-preview, and overlap checks are recorded in my earlier review comment. Linux full build was skipped by path selection. I approve this revision.
|
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.
|
What
Add the ten missing
stdc_leading_zeros_{uc,us,ui,ul,ull}andstdc_trailing_zeros_{uc,us,ui,ul,ull}libc exports. They return the zero-bit run before the highest set bit or after the lowest set bit, using C++20std::countl_zeroandstd::countr_zero. Zero returns the argument's width: 8, 16, 32, 64 or 64. The guestulargument is explicitly 64-bit on Windows. Each export has one public declaration and its own regression case.Contract evidence is PPSA03671 v01.001.005's bundled
libc.prx(SHA256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6), read from disassembly and run directly on a Windows host. All ten functions are call-free leaves. The signatures and semantics also follow C23 draft N3220, sections 7.18.3 and 7.18.5 and the LLVM libc stdbit declarations.stdc_leading_zeros_ucGEWnLZqp9Hk0x303f0stdc_leading_zeros_us7FB0t5y2r6A0x30400stdc_leading_zeros_uipkc1bZWixqw0x30410stdc_leading_zeros_ulbJLACmBx3bI0x30420stdc_leading_zeros_ullUO464WICdrU0x30430stdc_trailing_zeros_ucchy93WuEyPw0x30490stdc_trailing_zeros_usxRF+BzlARZo0x304a0stdc_trailing_zeros_uiXS0cqoqWgNY0x304b0stdc_trailing_zeros_uljMnJyLF8kPk0x304c0stdc_trailing_zeros_ulljqsveb-7TE40x304d0No original binary, byte dump, third-party source, investigation notes or logs are committed. The remaining console-verification gap is recorded in libc's debt file.
Tested
Runtime-tested head:
dc3999b2747bf068c0e229b0281cfc903dafaa0e, based on main61924d4637aaaeab35bc7ba3e4d3156f9ebd025d. Published head:504111f10c8bc83a8a9ae36a85bdd03c124528b5, based on main19f71094a71751d5026bc2452452bb539979b463(28 October 2026).After the runtime tests, main received other libraries' implementation changes, regression tests, documentation and the import-audit tool update. All libc production sources, headers, CMake and the focused regression sources are byte-identical between the runtime-tested and published heads. The runtime and native-comparison results below belong to the stated tested head. Conventions, whitespace, strict main synchronization and the overlap comparison were checked on the published head.
guest_zero_runs_testsandguest_integer_builtins_tests.ctest --test-dir build -R "^(guest_zero_runs_(leading|trailing)_(uc|us|ui|ul|ull)|guest_integer_builtins|public_headers)$" -V --output-on-failurepasses 12/12 on each platform on the runtime-tested head above. Windows also rebuilt the NID-patched production libc used below.NotImplemented_nid_no_patch(__func__), and pass after restoring production with the identical test executable (SHA2560f7038460d5712c81723c5abcce8331028894ec89448dae93875c12f591b8509). Production bodies and test assertions are byte-identical after the refresh; the complete focused selection and native comparison were rerun on the runtime-tested head above.cccdaa2734a71d27e6c907325c60fdf2d3baf0af:guest_integer_builtinsandpublic_headerspassed 2/2 on Windows and Ubuntu during the count-zeros investigation. That baseline evidence is reused, with no new baseline run claimed. Libc production, headers, CMake and the existing integer regression are byte-identical between that base and the current main; the focused checks and native comparison were rerun on the stated runtime-tested revision.The full CTest suite, all standalone-header compilation batches, macOS, console, title and GPU execution were not tested. No performance or title-unblock claim.
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)