feat(libSceLibreSsl3): implement sk_new, sk_push and sk_free #13088
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13088"
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 2Swagger on 2026-10-30T01:02:03Z.
What
Implements
sk_new,sk_pushandsk_freein libSceLibreSsl3, replacing their throwing placeholders from #12369's export inventory. They follow LibreSSL 4.0.0stack.c, the version libSceLibreSsl3's existing debt entries cite, and reuse libSceLibreSsl's 32-byte_STACKlayout (LibreSslStack), whichstack_local.hkeeps unchanged in 4.0.0.sk_new(compare): allocates the stack and a 4-entry element array (MIN_NODES) from the guest heap, clears the entries and stores the compare function. It returns null, releasing anything already allocated, if either allocation fails.sk_push(stack, element): appends the element and returns the new count, clearingsorted. Like LibreSSL it keeps one spare slot, so the array doubles when pushing the 4th, 8th, 16th... element, and an allocation failure returns 0 and leaves the stack as it was.sk_free(stack): releases the element array and the stack; null does nothing.Stacks come from the guest
malloc/reallocarrayand are released with the guestfree, the same heap the mergedsk_pop_free(#10373, forwarded to libSceLibreSsl3) uses, so a stack fromsk_newcan be inspected withsk_num/sk_valueand released withsk_pop_free. Where LibreSSL would fault or overflow,sk_pushthrows: a null stack, a negative element count, a null element array it does not regrow, or an array that cannot double without overflowingint. These are listed in the debt entry, and the declarations ininclude/Api.hppnow carry the real signatures. Nothing is checked on the console.Tested
guest_libressl3_stack, with a tracking guest heap: a new stack's layout and initial fields; push,sk_num,sk_valueandsk_popon it (including a null element andsortedbeing cleared); growth from 4 to 8 to 16 entries at the 4th and 8th pushes with every element kept;sk_pop_freeon a grown stack calling the free function once per element and releasing both blocks;sk_freereleasing both blocks andsk_free(NULL)releasing nothing; a failed stack or element-array allocation insk_newreturning null without leaking, and a failed growth insk_pushreturning 0 with the stack unchanged. Under 0.1 s.f79734a34onmain673fa865f. Windows 11 (WinLibs GCC 15.2.0, Release):guest_libressl3_stack,guest_libressl3_asn1,guest_libressl3_digest,guest_libressl3_key_reference,guest_crypto_memcmpandpublic_headerswith its compile batches pass, 70 of 70. Linux (Ubuntu 24.04 under WSL2, GCC 13.3.0, Release): the same set, 70 of 70.guest_libressl3_stackpassed 20 consecutive runs on both platforms (ctest --repeat until-fail:20).git merge-treeagainst the 15 open libSceLibreSsl3 PRs: the 4 that merge cleanly withmain(#10461, #10557, #10631, #10960) also merge cleanly with this one; the other 11 already conflict withmainin the inventory block #12369 added, and this PR adds no new conflict to them. Not tested on a console or a title.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)🤖 Generated with Claude Code