You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add the five missing stdc_count_zeros_{uc,us,ui,ul,ull} libc exports. They return the number of zero bits in their unsigned argument as uint32_t, using the existing C++20 std::popcount support in IntegerBuiltins.cpp. For example, zero returns the type's width and an all-ones argument returns zero. The guest ul argument stays 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 (SHA256 483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6), read from disassembly and run directly on a Windows host. The five functions are call-free leaves counting the complemented argument at its stated width. The signatures and zero-bit semantics also follow C23 draft N3220, section 7.18.11 and the LLVM libc stdbit declarations.
Export
NID
Input bits
Original RVA
stdc_count_zeros_uc
5DURS5C7Ops
8
0x30760
stdc_count_zeros_us
4GzA8wMtal8
16
0x30770
stdc_count_zeros_ui
TEzfCIqfppU
32
0x30780
stdc_count_zeros_ul
d+GiccCjl9o
64
0x30790
stdc_count_zeros_ull
7njNPBGm1V4
64
0x307a0
The implementation is written from this contract. No 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
Exact tested/published head: e5835d6866aa2303924a22eacdd5bd8e72a7ba00. Main base: cccdaa2734a71d27e6c907325c60fdf2d3baf0af (28 October 2026).
Windows 11 / WinLibs MinGW-w64 GCC 15.2.0 and Ubuntu 24.04 WSL / GCC 13.3.0, Release, existing full-project configurations: rebuilt production libc, guest_count_zeros_tests and guest_integer_builtins_tests. ctest --test-dir build -R "^(guest_count_zeros_(uc|us|ui|ul|ull)|guest_integer_builtins|public_headers)$" -V --output-on-failure passes 7/7 on each platform on this exact head. Windows also rebuilt the NID-patched production libc used below.
Each new case checks zero/all-ones, every single-bit and two-bit position and complements. The reference counts zeros bit by bit, independently of production. All 256 and 65,536 inputs are covered for 8 and 16 bits; each wider type also gets 100,000 deterministic random inputs and their complements. Guest errno is preserved. The five cases have separate 20-second timeouts.
Direct original-versus-production comparison on Windows: 269,763 input vectors, 1,348,815 original calls and 1,348,815 production calls, zero mismatches, also checked against an independent bit-by-bit reference. Production is reached through all five patched NIDs; those names were independently hashed and resolved in the original dynamic export table. Only the five original call-free leaves were executed from mapped load segments; no original initialization, relocation, other export or title execution was performed. This is host evidence, not a console measurement.
Baseline on the stated unmodified main: guest_integer_builtins and public_headers pass 2/2 on both platforms. Negative control during implementation: replacing all five new bodies with NotImplemented_nid_no_patch(__func__) makes all five Windows cases fail, and restoring production makes them pass with the identical executable (SHA256 ed2ab8e5028f1bd2cb70c29287077f95b44796025abedec8a30d2b34ae37efd3). The additions were then relocated to avoid overlap with count-ones, without changing any production body or test assertion; the full focused checks and native comparison were rerun on the final head above.
An initial concurrent Windows run passed all six runtime cases but timed out in public_headers at 90 seconds. After the overlap scan finished, the unchanged focused selection passed with the same 90-second header-test limit.
Conventions, PR whitespace and strict main synchronization pass: one commit ahead, zero behind the stated main. No new dependencies or comments in code.
This contribution and count-ones feat(libc): add C23 count-ones exports #11663 normalize onto the same main and merge without conflicts in both orders, producing the same content tree. Neither depends on the other. This is a content check; their combination was not runtime-tested.
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
Based on current main; no other open PR implements the same functions
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.
The reason will be displayed to describe this comment to others. Learn more.
I reviewed exact head e5835d6866aa2303924a22eacdd5bd8e72a7ba00. The five zero-count functions use the correct fixed-width unsigned inputs, with ul explicitly 64-bit for the PS5 ABI on Windows; the bit-count complement formula returns the input width for zero and zero for all ones. I independently recomputed all five NIDs with tools/nid_names.py, and the public-header audit passes (368 libraries, 12,989 exports). Both changed C++ files pass local GCC C++20 syntax-only compilation; conventions and git diff --check pass, and the current-main merge preview is clean. I also checked the interaction with open #12193: it introduces distinct leading/trailing-zero symbols, and the two branches combine cleanly. The PR’s exact-head report documents focused Linux and Windows test runs plus 1,348,815 original-versus-production calls with zero mismatches; hosted policy, relinker, register-context, write-watch and Windows jobs pass. Linux full build and the full CTest suite were not run in this review. I found no blocker in this revision.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add the five missing
stdc_count_zeros_{uc,us,ui,ul,ull}libc exports. They return the number of zero bits in their unsigned argument asuint32_t, using the existing C++20std::popcountsupport inIntegerBuiltins.cpp. For example, zero returns the type's width and an all-ones argument returns zero. The guestulargument stays 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. The five functions are call-free leaves counting the complemented argument at its stated width. The signatures and zero-bit semantics also follow C23 draft N3220, section 7.18.11 and the LLVM libc stdbit declarations.stdc_count_zeros_uc5DURS5C7Ops0x30760stdc_count_zeros_us4GzA8wMtal80x30770stdc_count_zeros_uiTEzfCIqfppU0x30780stdc_count_zeros_uld+GiccCjl9o0x30790stdc_count_zeros_ull7njNPBGm1V40x307a0The implementation is written from this contract. No 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
Exact tested/published head:
e5835d6866aa2303924a22eacdd5bd8e72a7ba00. Main base:cccdaa2734a71d27e6c907325c60fdf2d3baf0af(28 October 2026).guest_count_zeros_testsandguest_integer_builtins_tests.ctest --test-dir build -R "^(guest_count_zeros_(uc|us|ui|ul|ull)|guest_integer_builtins|public_headers)$" -V --output-on-failurepasses 7/7 on each platform on this exact head. Windows also rebuilt the NID-patched production libc used below.guest_integer_builtinsandpublic_headerspass 2/2 on both platforms. Negative control during implementation: replacing all five new bodies withNotImplemented_nid_no_patch(__func__)makes all five Windows cases fail, and restoring production makes them pass with the identical executable (SHA256ed2ab8e5028f1bd2cb70c29287077f95b44796025abedec8a30d2b34ae37efd3). The additions were then relocated to avoid overlap with count-ones, without changing any production body or test assertion; the full focused checks and native comparison were rerun on the final head above.public_headersat 90 seconds. After the overlap scan finished, the unchanged focused selection passed with the same 90-second header-test limit.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)