Skip to content

feat(fiber): implement fibers on linux - #48

Merged
boykopovar merged 2 commits into
boykopovar:mainfrom
oneandonlydean:feat/linux-fibers
Sep 28, 2026
Merged

boykopovar merged 2 commits into
boykopovar:mainfrom
oneandonlydean:feat/linux-fibers

Conversation

@oneandonlydean

Copy link
Copy Markdown
Collaborator

What

libSceFiber was only implemented on Windows; on Linux every function called NotImplemented. 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:

  • Aps5FiberSwitchStack saves the SysV callee-saved set (rbp rbx r12–r15, MXCSR and the x87 control word) instead of the Win64 set.
  • Aps5FiberTrampoline passes the fiber in rdi.
  • There is no TIB to update, so CurrentBounds/SetBounds do nothing on Linux.

The asm symbols and Aps5FiberMain are hidden, so they aren't exported or NID-patched.

Testing

New fiber test: run, switch, switching to self (STATE error), 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 each SceFiber object, because FiberObject in SceTypes.hpp is not the size the guest reserves.

@boykopovar

boykopovar commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

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

oneandonlydean and others added 2 commits September 28, 2026 19:46
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
…ith _nid_no_patch

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
@oneandonlydean

Copy link
Copy Markdown
Collaborator Author

Done — removed the attribute. The assembly entry points are now Aps5FiberSwitchStack_nid_no_patch, Aps5FiberTrampoline_nid_no_patch and Aps5FiberMain_nid_no_patch (Windows side renamed too for consistency), referenced by those names from the asm. Also rebased onto current main.

@boykopovar
boykopovar merged commit 34f0379 into boykopovar:main Sep 28, 2026
@oneandonlydean
oneandonlydean deleted the feat/linux-fibers branch September 29, 2026 03:44
Kikoarl pushed a commit to Kikoarl/AnyPS5 that referenced this pull request Nov 18, 2026
…er-timing

feat(kyty): time Vulkan compute pipeline creation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants