sceKernelPollEventFlag

This commit is contained in:
red-prig 2022-12-10 18:50:08 +03:00
parent 5725cef328
commit 2deed58e69
2 changed files with 66 additions and 4 deletions

View File

@ -73,6 +73,12 @@ function ps4_sceKernelWaitEventFlag(
pResultPat:PQWORD;
pTimeout:PDWORD):Integer; SysV_ABI_CDecl;
function ps4_sceKernelPollEventFlag(
ef:SceKernelEventFlag;
bitPattern:QWORD;
waitMode:DWORD;
pResultPat:PQWORD):Integer; SysV_ABI_CDecl;
function ps4_sceKernelSetEventFlag(ef:SceKernelEventFlag;bitPattern:QWORD):Integer; SysV_ABI_CDecl;
function ps4_sceKernelClearEventFlag(ef:SceKernelEventFlag;bitPattern:QWORD):Integer; SysV_ABI_CDecl;
function ps4_sceKernelDeleteEventFlag(ef:SceKernelEventFlag):Integer; SysV_ABI_CDecl;
@ -457,6 +463,65 @@ begin
Result:=px2sce(Result);
end;
function _sceKernelPollEventFlag(
ef:SceKernelEventFlag;
bitPattern:QWORD;
waitMode:DWORD;
pResultPat:PQWORD):Integer;
begin
if (bitPattern=0) then Exit(EINVAL);
Case (waitMode and WOP_MODES) of
SCE_KERNEL_EVF_WAITMODE_AND:;
SCE_KERNEL_EVF_WAITMODE_OR :;
else
Exit(EINVAL);
end;
Result:=ef_enter(ef);
if (Result<>0) then Exit;
if _is_single(ef^.attr) then
begin
spin_lock(ef^.lock_list);
if not spin_trylock(ef^.lock_sing) then
begin
spin_unlock(ef^.lock_list);
ef_leave(ef);
Exit(EPERM);
end;
spin_unlock(ef^.lock_list);
end;
spin_lock(ef^.lock_list);
if _test_and_set(ef,bitPattern,waitMode,pResultPat) then
begin
Result:=0;
end else
begin
Result:=EBUSY;
end;
spin_unlock(ef^.lock_list);
ef_leave(ef);
end;
function ps4_sceKernelPollEventFlag(
ef:SceKernelEventFlag;
bitPattern:QWORD;
waitMode:DWORD;
pResultPat:PQWORD):Integer; SysV_ABI_CDecl;
begin
repeat
_sig_lock;
Result:=_sceKernelPollEventFlag(ef,bitPattern,waitMode,pResultPat);
_sig_unlock;
until (Result<>EINTR);
_set_errno(Result);
Result:=px2sce(Result);
end;
//
procedure _wakeup(node:pwef_node;ret:Integer);
@ -651,10 +716,6 @@ begin
Result:=px2sce(Result);
end;
{
int sceKernelPollEventFlag(SceKernelEventFlag ef, uint64_t bitPattern,
uint32_t waitMode, uint64_t *pResultPat);
}
end.

View File

@ -1134,6 +1134,7 @@ begin
lib^.set_proc($0691686E8509A195,@ps4_sceKernelCreateEventFlag);
lib^.set_proc($253BC17E58586B34,@ps4_sceKernelWaitEventFlag);
lib^.set_proc($F65BE3E438C76620,@ps4_sceKernelPollEventFlag);
lib^.set_proc($20E9D2BC7CEABBA0,@ps4_sceKernelSetEventFlag);
lib^.set_proc($EEE8411564404BAD,@ps4_sceKernelClearEventFlag);
lib^.set_proc($F26AA5F4E7109DDE,@ps4_sceKernelDeleteEventFlag);