From 5c71314661d9501c6ca6de0d1f5643d4b73edc74 Mon Sep 17 00:00:00 2001 From: ParantezTech <12572227+par274@users.noreply.github.com> Date: Tue, 6 Oct 2026 13:44:48 +0300 Subject: [PATCH] [Kernel] Add scePthreadSemTimedwait Co-authored-by: Sekai <140012992+igettingit@users.noreply.github.com> --- .../Kernel/KernelSemaphoreCompatExports.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/SharpEmu.Libs/Kernel/KernelSemaphoreCompatExports.cs b/src/SharpEmu.Libs/Kernel/KernelSemaphoreCompatExports.cs index 584a057..c17f8c5 100644 --- a/src/SharpEmu.Libs/Kernel/KernelSemaphoreCompatExports.cs +++ b/src/SharpEmu.Libs/Kernel/KernelSemaphoreCompatExports.cs @@ -576,6 +576,35 @@ public static class KernelSemaphoreCompatExports : result; } + [SysAbiExport( + Nid = "fjN6NQHhK8k", + ExportName = "scePthreadSemTimedwait", + Target = Generation.Gen4 | Generation.Gen5, + LibraryName = "libKernel")] + public static int PthreadSemTimedWait(CpuContext ctx) + { + var timeoutUsec = unchecked((uint)ctx[CpuRegister.Rsi]); + if (!TryGetPosixSemaphoreHandle(ctx, ctx[CpuRegister.Rdi], out var handle)) + { + return SetReturn(ctx, OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT); + } + + if (!_semaphores.TryGetValue(handle, out var semaphore)) + { + return SetReturn(ctx, OrbisGen2Result.ORBIS_GEN2_ERROR_NOT_FOUND); + } + + return WaitSemaphoreCore( + ctx, + semaphore, + handle, + needCount: 1, + hasTimeout: true, + timeoutAddress: 0, + timeoutUsec, + "scePthreadSemTimedwait"); + } + [SysAbiExport( Nid = "w5IHyvahg-o", ExportName = "sem_timedwait",