Repository navigation
feat(libSceJxr): implement bit I/O through the pinned jxrlib - #14916
Conversation
Sixteen bit reader/writer exports (peekBit16, flushBit16, getBit16, getBool16, getBit16s, getBit32, flushToByte, putBit16z, putBit16, putBit32, fillToByte, getBit16_S, getSizeRead, getSizeWrite, getPosRead, dquantBits) now call strcodec.c from 3rdparty/jxrlib through a C bridge. The guest adapters only reject the arguments jxrlib asserts on; getBit16_S adds the existing readIS. A new test drives 256k random reads and writes on a ring buffer against jxrlib directly and covers the rejected arguments.
Progress report (e9247a9 → e2a2929)📈 System libraries: 27.33% (+0.04%, +16 implemented functions) ✅ 16 implemented
Changed libraries (implemented exports)
|
|
Hi Noxy-HNR, thanks for the bit I/O bridge; keeping the implementation in the pinned Please make the accepted zero-bit and alignment boundaries defined without copying the third-party algorithm into core, and add sanitizer coverage for those boundaries. Preserve the submodule policy when changing the dependency or bridge. Comparing the guest call against another execution of the same undefined native operation is not a reliable oracle. No console behavior or full decoder test is claimed by this check. A landing note: the description says this depends on #14905, but the two do not merge together (and #14933 conflicts with this one in |
…ined Return 0 from zero-bit reads, skip empty stores at a 16-bit word boundary, mask putBit16 and putBit32 values before calling putBit16z instead of jxrlib's negative left shift, reject write positions past the word, and build strcodec.c and segdec.c with jxrlib's 16-bit load path so stream loads stay aligned. The test checks these boundaries against explicit values and passes under UBSan.
|
Thanks, fixed in
On landing: I've changed the description to |
|
@oneandonlydean I independently rechecked
I also made the integration order explicit in the descriptions and checklists: #14905, then #14916, then #14933. These are merge-order prerequisites because the branches conflict in shared files; the features have no runtime dependency on one another. Each later branch will be rebased and retested after its prerequisites merge. |
|
@oneandonlydean follow-up All four write/fill entry points now reject a pointer that is not aligned for a 16-bit store before changing the state or buffer. The regression covers bit positions 0, 1, 8 and 15, including empty stores, masked/unmasked writes, 32-bit writes and byte fills. The debt entry records this divergence from undefined native behavior; console handling remains unverified. The submodule and native algorithm are unchanged. Windows 11, WinLibs GCC 15.2.0, Release: the rebuilt bit-I/O, stream and existing JXR tests pass, 3/3. The expanded Ubuntu 26.04/GCC 15.2 UBSan probe passes, including the odd-position rejection and previous zero-bit/alignment/masking cases. Conventions and whitespace checks pass, and the new head merges cleanly with main at |
|
Hi @Noxy-HNR, I merged |
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): feat(libSceJxr): implement PKAlloc #14425, feat(libSceJxr): implement WMPAlloc, WMPFree and the memory stream #14631 and feat(libSceJxr): implement the pixel format hash, image IID lookups, aligned allocation and IDPEmpty #14905 touch neighbouring lines ofCMakeLists.txt,include/Api.hppand the debt file. None shares an export or a new file. Merge order is feat(libSceJxr): implement the pixel format hash, image IID lookups, aligned allocation and IDPEmpty #14905, then this PR, then feat(libSceJxr): implement quantizer remapping, AC prediction mode and zigzag scan setup #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)