feat(libSceJxr): implement bit I/O through the pinned jxrlib #14916
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14916"
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 Noxy-HNR on 2026-11-02T01:16:22Z.
What
Sixteen libSceJxr bit reader/writer exports currently throw:
peekBit16,flushBit16,getBit16,getBool16,getBit16s,getBit32,flushToByte,putBit16z,putBit16,putBit32,fillToByte,getBit16_S,getSizeRead,getSizeWrite,getPosReadanddquantBits.They now call the non-ARM bit I/O in strcodec.c, built from
3rdparty/jxrlib, through a C bridge (src/NativeBitIo.c) on the existing guestJxr::BitIo/BitIOInfolayout (48 bytes). No jxrlib logic is copied intocore/.The C++ adapters reject bit counts over 16 (15 for
getBit16s, 32 forgetBit32/putBit32), aputBit16zvalue wider than its count, an odd read wrap mask, a write position of 16 bits or more, a write pointer not aligned for a 16-bit store, and a null state or current pointer.getBit16_SisgetBit16followed by the existingreadIS, as jxrlib'sreadIS_L1isreadIS.Review fix
369b743519defines the accepted boundaries that jxrlib leaves undefined in C. A zero-bit peek returns 0; zero-bitgetBit16/getBit32use the definedflushBit16(0)path and return 0. An empty store or byte fill at a word boundary leaves the state and buffer unchanged. Masked writes use unsigned masks and the dependency'sputBit16z, in 16-bit parts for a 32-bit write. The unmodifiedstrcodec.candsegdec.care built with jxrlib's existing aligned-load branch through a per-file_M_IA64definition. The implementation remains in the pinned submodule. Follow-up99a3aaaf67rejects odd byte write positions before changing state or memory; these otherwise reach an undefinedU16store in the dependency.That the console's module uses these prototypes is inferred from the export names; nothing is checked on a console. The debt file records these inferred contracts and the defined boundary behavior that still needs console verification. No title unblock is claimed.
Tested
Latest independent verification at
99a3aaaf67: Windows 11 x86-64, WinLibs GCC 15.2.0, Release. Rebuiltguest_jxr_bitio_tests,guest_jxr_stream_testsandguest_jxr_tests; 3/3 passed.Linux source-level sanitizer probe: Ubuntu 26.04, GCC 15.2.0,
-fsanitize=undefined -fno-sanitize-recover=all,UBSAN_OPTIONS=halt_on_error=1, using the exact adapter, C bridge and pinned native bit functions. Zero-bit reads, word-boundary stores, unsigned masking, 20/32-bit writes and 2-byte-aligned read positions pass without a sanitizer diagnostic. The same probe using the pre-fix adapter/bridge fromf3a9091e51stops on the native shift by 32. The expanded probe also detects an undefined odd-position store at369b743519;99a3aaaf67rejects that input without a sanitizer report. The Windows regression covers all four write/fill entry points at bit positions 0, 1, 8 and 15 and checks unchanged state and buffer after rejection. This is a focused source probe, not a full Linux guest-runtime run.Earlier reported validation:
New
guest_jxr_bitiotest:128 rounds of 2,000 random reads or writes on a 16 KiB-aligned ring buffer, run through the guest exports and through jxrlib directly. Each step compares the results, accumulator, bit count, wrap position, reference offset and the whole buffer.
dquantBitsfor all 256 inputs.A read wrapping at the ring end, and
getBit16_Swith and without a packet crossing.Every rejected argument.
Linux x86-64 (Ubuntu 24.04, GCC 13), Release, upstream
93dbd0f82a:ctest -R guest_jxr10/10 passed.Windows 11 x86-64, WinLibs MinGW GCC 15.2.0, Release:
ctest -R guest_jxr10/10 passed, including the_patchedlookup tests against the patchedlibSceJxr.prx.python tools/check_conventions.py --base upstream/main,git diff --checkandpython core/libs/tests/test_public_headers.py --audit-only(399 libraries, 26,813 exports): passed.python tools/pr_overlap.py --branch claude/jxr-bitio(1,859 open PRs): #14425, #14631 and #14905 touch neighbouring lines ofCMakeLists.txt,include/Api.hppand the debt file. None shares an export or a new file. Merge order is #14905, then this PR, then #14933. Their implementations are functionally independent, but the combined branches conflict in shared files; each later PR needs a rebase and focused tests after its prerequisites merge. The checklist records this integration order.No console or retail-title test.
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)