feat(fiber): implement fibers on linux #48
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/48"
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 oneandonlydean on 2026-09-28T01:24:40Z.
What
libSceFiberwas only implemented on Windows; on Linux every function calledNotImplemented. This ports the Windows implementation.How
The state machine, the cross-thread resume handling and the entry trampoline are now shared between platforms. Only the context switch differs:
Aps5FiberSwitchStacksaves the SysV callee-saved set (rbp rbx r12–r15, MXCSR and the x87 control word) instead of the Win64 set.Aps5FiberTrampolinepasses the fiber inrdi.CurrentBounds/SetBoundsdo nothing on Linux.The asm symbols and
Aps5FiberMainare hidden, so they aren't exported or NID-patched.Testing
New
fibertest: run, switch, switching to self (STATEerror),ReturnToThread, resuming a suspended fiber on a different host thread, MXCSR kept per fiber and restored for the thread, and finalize. It uses 0x100-byte storage for eachSceFiberobject, becauseFiberObjectinSceTypes.hppis not the size the guest reserves.Imported from boykopovar/AnyPS5. Originally posted by boykopovar on 2026-09-28T05:49:28Z.
Can you remove attribute((visibility("hidden")))? We try to avoid using non-standard expressions where it is possible to do without them. The exported symbol will be patched and converted to nid. But if you add the _nid_no_patch_cut postfix, the postfix will be discarded. Or use _nid_no_patch and reference Aps5FiberTrampoline_nid_no_patch in the asm code.
Or just create a new macro for attribute((visibility("hidden"))) defined in prx/libc/include/general
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-09-28T07:05:34Z.
Done — removed the attribute. The assembly entry points are now
Aps5FiberSwitchStack_nid_no_patch,Aps5FiberTrampoline_nid_no_patchandAps5FiberMain_nid_no_patch(Windows side renamed too for consistency), referenced by those names from the asm. Also rebased onto current main.