feat(libSceJxr): implement the jxrlib SimpleBitIO reader #15148
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15148"
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 r614 on 2026-11-02T18:25:03Z.
What
Implements the five jxrlib
SimpleBitIOexports of libSceJxr, which threw before:attach_SB,getBit32_SB,flushToByte_SB,getByteRead_SBanddetach_SB.They follow pinned jxrlib strcodec.c on a new 24-byte
Jxr::SimpleBitIowithstatic_asserted offsets, matching jxrlib's LP64SimpleBitIO.getBit32_SBis written out rather than forwarded to native jxrlib, because it calls the stream'sReadcallback, which is guest code using the guest ABI. The call goes through the existingJxr::Streamcallback type, once per byte, with aGuestArena::HostWriteover the destination byte as inreadIS. Its result is ignored, as jxrlib ignores it.Where jxrlib reads through an invalid pointer, shifts by more than 31 or asserts, the export throws
std::invalid_argument, asreadIS/writeISdo: a null reader, a null stream or read callback when a byte is needed, more than 8 buffered bits, and buffered bits indetach_SB.Console prototypes and layouts are unverified, and that the module is built from jxrlib is inferred from the export names, as for the existing entries.
This complements #14916 (merged), which covers the
BitIOInfobit I/O.SimpleBitIo.cppcarries jxrlib's licence notice, likeAllocation.cppandExport.cpp.Tested
Windows 11, WinLibs GCC 15.2.0 (
x86_64-ucrt-posix-seh, r7), Release build. Linux and macOS were not built.guest_jxr_simple_bit_io:GuestJxrSimpleBitIoReference.c, the same pattern asGuestJxrLookupReference.c): 1,250 random operations over 4 KiB: 1,172 reads of 0 to 40 bits (230 wider than 32) and 78 flushes. The result, byte count, accumulator and buffered bit count are compared after every call. The guest callback returns an error to show it is ignored.main82fcf46d25:ctest -R guest_jxr13/13 passed, includingguest_jxr_bitio,guest_jxr_glue,guest_jxr_quantizerand the_patchedlookup tests.public_headerspasses.python3 tools/check_conventions.py --base origin/mainpasses.python3 tools/pr_overlap.py --branch feat/jxr-simple-bit-iofinds no other PR sharing an export or a new file. It could not compare #15645, #15646, #15684, #15771, #15772 and #15774, which conflict withmain; their diffs touch none of these exports.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)Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T20:28:02Z.
Review: APPROVED
Matches pinned jxrlib strcodec.c line for line:
attach_SBzeroes the three counters,getBit32_SBhas the same shift-and-refill loop (oneReadof one byte per refill, result ignored),flushToByte_SBclears the accumulator and bit count,getByteRead_SBreturnscbRead, anddetach_SBclears the stream where jxrlib assertscBitLeft == 0. The layout matches strcodec.h (pWS,U32 cbRead,U8 bAccumulator,U32 cBitLeft: offsets 0, 8, 12, 16 and 24 bytes on LP64).ERRislongin windowsmediaphoto.h, so thestd::int64_treturns fit.Tested on Windows 11, WinLibs GCC 15.2.0, with this head merged onto
main: all 10guest_jxr*tests pass, nothing skipped. Withmain'sExport.cppandApi.hpp, the new test doesn't build against the old stubs.Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-06T16:34:40Z.
Review: APPROVED
@r614 re-checked at
e4779042ae. My approval was on52e4f47616.git range-diff 52e4f47616~1..52e4f47616 e4779042ae~1..e4779042aelists two changes:main: the new source joinsmain's longerlibSceJxrsource list inCMakeLists.txt, and the removed stubs and declarations now sit betweenmain's newer neighbours inExport.cppandinclude/Api.hpp. The code ofsrc/SimpleBitIo.cppis the same as what I approved.src/SimpleBitIo.cpp:1-27now carries jxrlib's Microsoft copyright and BSD notice. That's the same blockmain'score/libs/prx/libSceJxr/src/Allocation.cppstarts with (its line 3 is the sameCopyright © Microsoft Corp.line), so it follows that file's precedent.The count is still right after the rebase. The debt line says "The 88 remaining additional stubs" (
docs/dev/debt/libSceJxr.md:41ate4779042ae). In the tree merged withmain23d549a9c7,Export.cpphas 88 throwing stubs (93 onmain).What I ran. This head merged onto
main23d549a9c7(mergec166002a8f, clean), Windows 11 Pro, WinLibs GCC, Release:^guest_jxr: 13 of 13 pass, none unbuilt.main'sExport.cppandinclude/Api.hppmakesJxrSimpleBitIo.cppfail to build against the old parameterless stubs, as before.src/SimpleBitIo.cppon the merge, each rebuilt and run; both failguest_jxr_simple_bit_io:++io->bytesReadingetBit32_SB;tools/pr_overlap.py --branchat this head: no other PR changes the same exports. The line conflicts arelibSceJxrneighbours: the source list, the stub declarations next to these five, and the debt count line everylibSceJxrPR edits. Seven PRs couldn't be compared (#15232, #15645, #15646, #15771, #15772, #15774, #16300); none of their GitHub patches has a changed line namingattach_SB,getBit32_SB,flushToByte_SB,getByteRead_SBordetach_SB.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-06T19:50:29Z.
Review: APPROVED
@r614 re-checked at
3150e49dae. My approval was one4779042ae.git range-diff e4779042ae~1..e4779042ae 3150e49dae~1..3150e49daeshows a rebase onto currentmainwith one change in the PR's own lines: the debt count line.mainnow has 92 throwinglibSceJxrstubs (93 when I approved), and the line now says "The 87 remaining additional stubs" (docs/dev/debt/libSceJxr.md:43at3150e49dae). I recounted from the files:Export.cpphas 92NotImplemented_nid_no_patchstubs onmainc9f43dfa1dand 87 at3150e49dae, so 87 is right.src/SimpleBitIo.cppand the test are unchanged.What I ran. This head merged onto
mainc9f43dfa1d(mergecbd5c97fd9, clean), Windows 11 Pro, WinLibs GCC, Release:^guest_jxr: 13 of 13 pass, none unbuilt.main'sExport.cppandinclude/Api.hppmakesJxrSimpleBitIo.cppfail to build against the old parameterless stubs, as before.src/SimpleBitIo.cpp, each rebuilt and run; both failguest_jxr_simple_bit_io:++io->bytesReadingetBit32_SB;tools/pr_overlap.py --branchat this head: 34libSceJxrPRs couldn't be compared because they conflict withmain. I read each one's GitHub patch: none has a changed line namingattach_SB,getBit32_SB,flushToByte_SB,getByteRead_SBordetach_SB. The shared files are the stub declarations, the source list and the debt count line that everylibSceJxrPR edits.tools/check_conventions.py --base upstream/mainat this head: all checks pass.AI-assisted: yes (Claude Code)