This commit is contained in:
Pavel 2022-10-31 11:41:23 +03:00
parent e3f6c2c752
commit a5ec2be201
2 changed files with 127 additions and 29 deletions

View File

@ -1228,8 +1228,12 @@ begin
lib^.set_proc($7E0C6731E4CD52D6,@ps4_sceKernelGetProcessTimeCounter); lib^.set_proc($7E0C6731E4CD52D6,@ps4_sceKernelGetProcessTimeCounter);
lib^.set_proc($C92F14D931827B50,@ps4_nanosleep); lib^.set_proc($C92F14D931827B50,@ps4_nanosleep);
lib^.set_proc($42FB19C689AF507B,@ps4_sceKernelNanosleep);
lib^.set_proc($41CB5E4706EC9D5D,@ps4_usleep); lib^.set_proc($41CB5E4706EC9D5D,@ps4_usleep);
lib^.set_proc($D637D72D15738AC7,@ps4_sceKernelUsleep); lib^.set_proc($D637D72D15738AC7,@ps4_sceKernelUsleep);
lib^.set_proc($D30BB7DE1BA735D1,@ps4_sleep);
lib^.set_proc($FD947E846EDA0C7C,@ps4_sceKernelSleep); lib^.set_proc($FD947E846EDA0C7C,@ps4_sceKernelSleep);
lib^.set_proc($FE8E6E103A4DFA86,@ps4_sceKernelConvertUtcToLocaltime); lib^.set_proc($FE8E6E103A4DFA86,@ps4_sceKernelConvertUtcToLocaltime);

View File

@ -50,10 +50,14 @@ function ps4_sceKernelGetProcessTime:QWORD; SysV_ABI_CDecl; //microseconds
function ps4_sceKernelGetProcessTimeCounterFrequency:QWORD; SysV_ABI_CDecl; //microseconds*10 function ps4_sceKernelGetProcessTimeCounterFrequency:QWORD; SysV_ABI_CDecl; //microseconds*10
function ps4_sceKernelGetProcessTimeCounter:QWORD; SysV_ABI_CDecl; //microseconds*10 function ps4_sceKernelGetProcessTimeCounter:QWORD; SysV_ABI_CDecl; //microseconds*10
function ps4_nanosleep(req,rem:Ptimespec):Integer; SysV_ABI_CDecl; function ps4_nanosleep(req,rem:Ptimespec):Integer; SysV_ABI_CDecl; //nanoseconds
function ps4_sceKernelNanosleep(req,rem:Ptimespec):Integer; SysV_ABI_CDecl; //nanoseconds
function ps4_usleep(usec:DWORD):Integer; SysV_ABI_CDecl; //microseconds function ps4_usleep(usec:DWORD):Integer; SysV_ABI_CDecl; //microseconds
function ps4_sceKernelUsleep(usec:DWORD):Integer; SysV_ABI_CDecl; //microseconds function ps4_sceKernelUsleep(usec:DWORD):Integer; SysV_ABI_CDecl; //microseconds
function ps4_sceKernelSleep(sec:Integer):Integer; SysV_ABI_CDecl;
function ps4_sleep(sec:DWORD):DWORD; SysV_ABI_CDecl; //second
function ps4_sceKernelSleep(sec:DWORD):DWORD; SysV_ABI_CDecl; //second
type type
ptimesec=^timesec; ptimesec=^timesec;
@ -398,12 +402,13 @@ end;
//lpUserTime/ 10 000 000 *1 000 000 //lpUserTime/ 10 000 000 *1 000 000
//lpUserTime/ 10 *1 //lpUserTime/ 10 *1
function ps4_nanosleep(req,rem:Ptimespec):Integer; SysV_ABI_CDecl; function _nanosleep(req,rem:Ptimespec):Integer;
var var
timeout:Int64; timeout:Int64;
passed :Int64; passed :Int64;
START:QWORD; START:QWORD;
begin begin
//test_cancel
if (req=nil) then Exit(EINVAL); if (req=nil) then Exit(EINVAL);
timeout:=_time_in_ns_from_timespec(req^); timeout:=_time_in_ns_from_timespec(req^);
@ -414,6 +419,7 @@ begin
timeout:=-((timeout+99) div 100); //in 100ns timeout:=-((timeout+99) div 100); //in 100ns
START:=0;
if (rem<>nil) then if (rem<>nil) then
begin begin
SwSaveTime(START); SwSaveTime(START);
@ -422,7 +428,7 @@ begin
Case SwDelayExecution(True,@timeout) of Case SwDelayExecution(True,@timeout) of
STATUS_USER_APC, STATUS_USER_APC,
STATUS_KERNEL_APC, STATUS_KERNEL_APC,
STATUS_ALERTED: STATUS_ALERTED: //signal interrupt
begin begin
if (rem<>nil) then if (rem<>nil) then
begin begin
@ -441,7 +447,7 @@ begin
end; end;
end; end;
Result:=_set_errno(EINVAL); Result:=EINTR;
end; end;
else else
begin begin
@ -453,44 +459,132 @@ begin
end; end;
end; end;
//test_cancel
end;
function ps4_nanosleep(req,rem:Ptimespec):Integer; SysV_ABI_CDecl; //nanoseconds
begin
Result:=_set_errno(_nanosleep(req,rem));
end;
function ps4_sceKernelNanosleep(req,rem:Ptimespec):Integer; SysV_ABI_CDecl; //nanoseconds
var
tmp:timespec;
begin
tmp:=Default(timespec);
repeat
Result:=_nanosleep(req,@tmp);
_set_errno(Result);
if (Result=0) then
begin
if (rem<>nil) then
begin
rem^:=tmp;
end;
Exit;
end;
req:=@tmp;
until (Result<>EINTR);
Result:=px2sce(Result);
end; end;
function ps4_usleep(usec:DWORD):Integer; SysV_ABI_CDecl; //microseconds function ps4_usleep(usec:DWORD):Integer; SysV_ABI_CDecl; //microseconds
var var
ft:TLargeInteger; time:timespec;
begin begin
//usec:=((usec+99999) div 100000)*100000; //test_cancel
// time.tv_sec :=usec div 1000000;
ft:=-(10*usec); //in 100ns time.tv_nsec:=((usec mod 1000000)*1000);
Case SwDelayExecution(True,@ft) of Result:=_set_errno(_nanosleep(@time,nil));
STATUS_USER_APC, //test_cancel
STATUS_KERNEL_APC, end;
STATUS_ALERTED:
function ps4_sceKernelUsleep(usec:DWORD):Integer; SysV_ABI_CDecl; //microseconds
var
req,rem:timespec;
begin
rem:=Default(timespec);
req.tv_sec :=usec div 1000000;
req.tv_nsec:=((usec mod 1000000)*1000);
repeat
Result:=_nanosleep(@req,@rem);
_set_errno(Result);
if (Result=0) then Exit;
req:=rem;
until (Result<>EINTR);
Result:=px2sce(Result);
end;
function _sleep(sec:DWORD):DWORD;
var
req,rem:timespec;
ret,rsec:DWORD;
begin
rem:=Default(timespec);
if (Integer(sec)<0) then
begin
req.tv_sec :=$7fffffff;
req.tv_nsec:=0;
ret:=_nanosleep(@req,@rem);
_set_errno(ret);
rsec:=0;
if (ret<>0) then
begin
if (ret=EINTR) then
begin begin
Result:=_set_errno(EINVAL); rsec:=(Integer(rem.tv_sec)+1)-DWORD(rem.tv_nsec=0);
end; end;
else end;
Result:=0;
Result:=sec+$80000001+rsec;
end else
begin
req.tv_sec :=sec;
req.tv_nsec:=0;
ret:=_nanosleep(@req,@rem);
_set_errno(ret);
Result:=0;
if (ret<>0) then
begin
Result:=sec;
if (ret=EINTR) then
begin
Result:=(Integer(rem.tv_sec)+1)-DWORD(rem.tv_nsec=0);
end;
end;
end; end;
end; end;
function ps4_sceKernelUsleep(usec:DWORD):Integer; SysV_ABI_CDecl; function ps4_sleep(sec:DWORD):DWORD; SysV_ABI_CDecl; //second
var
ft:TLargeInteger;
begin begin
//usec:=((usec+99999) div 100000)*100000; //test_cancel
// Result:=_sleep(sec);
ft:=-(10*usec); //in 100ns //test_cancel
SwDelayExecution(False,@ft);
Result:=0;
end; end;
function ps4_sceKernelSleep(sec:Integer):Integer; SysV_ABI_CDecl; function ps4_sceKernelSleep(sec:DWORD):DWORD; SysV_ABI_CDecl; //second
var
ft:TLargeInteger;
begin begin
ft:=-(10000000*sec); //in 100ns repeat
SwDelayExecution(False,@ft); //test_cancel
sec:=_sleep(sec);
//test_cancel
until (sec=0);
Result:=0; Result:=0;
end; end;