pthread_attr_setinheritsched and etc

This commit is contained in:
red-prig 2023-01-04 22:51:10 +03:00
parent 6299a733da
commit a3b3bdb8f6
3 changed files with 50 additions and 21 deletions

View File

@ -1225,10 +1225,12 @@ begin
lib^.set_proc($AA593DA522EC5263,@ps4_pthread_attr_getschedparam);
lib^.set_proc($1573D61CD93C39FD,@ps4_scePthreadAttrGetschedparam);
lib^.set_proc($DEAC603387B31130,@ps4_scePthreadAttrSetaffinity);
lib^.set_proc($F3EB39073663C528,@ps4_scePthreadAttrGetaffinity)
;
lib^.set_proc($ED99406A411FD108,@ps4_pthread_attr_setinheritsched);
lib^.set_proc($7976D44A911A4EC0,@ps4_scePthreadAttrSetinheritsched);
lib^.set_proc($DEAC603387B31130,@ps4_scePthreadAttrSetaffinity);
lib^.set_proc($F3EB39073663C528,@ps4_scePthreadAttrGetaffinity);
lib^.set_proc($B711ED9E027E7B27,@ps4_scePthreadAttrGetguardsize);
lib^.set_proc($46EDFA7E24ED2730,@ps4_scePthreadAttrGetstackaddr);
lib^.set_proc($FDF03EED99460D0B,@ps4_scePthreadAttrGetstacksize);

View File

@ -51,10 +51,12 @@ function ps4_scePthreadAttrSetschedparam(pAttr:p_pthread_attr_t;param:PInteger)
function ps4_pthread_attr_getschedparam(pAttr:p_pthread_attr_t;param:PInteger):Integer; SysV_ABI_CDecl;
function ps4_scePthreadAttrGetschedparam(pAttr:p_pthread_attr_t;param:PInteger):Integer; SysV_ABI_CDecl;
function ps4_pthread_attr_setinheritsched(pAttr:p_pthread_attr_t;sched_inherit:Integer):Integer; SysV_ABI_CDecl;
function ps4_scePthreadAttrSetinheritsched(pAttr:p_pthread_attr_t;sched_inherit:Integer):Integer; SysV_ABI_CDecl;
function ps4_scePthreadAttrSetaffinity(pAttr:p_pthread_attr_t;mask:QWORD):Integer; SysV_ABI_CDecl;
function ps4_scePthreadAttrGetaffinity(pAttr:p_pthread_attr_t;mask:PQWORD):Integer; SysV_ABI_CDecl;
function ps4_scePthreadAttrSetinheritsched(pAttr:p_pthread_attr_t;inheritSched:Integer):Integer; SysV_ABI_CDecl;
function ps4_scePthreadAttrGetguardsize(pAttr:p_pthread_attr_t;guardSize:PQWORD):Integer; SysV_ABI_CDecl;
function ps4_scePthreadAttrGetstackaddr(pAttr:p_pthread_attr_t;stackAddr:PPointer):Integer; SysV_ABI_CDecl;
function ps4_scePthreadAttrGetstacksize(pAttr:p_pthread_attr_t;stackSize:PQWORD):Integer; SysV_ABI_CDecl;
@ -93,8 +95,8 @@ end;
function ps4_pthread_attr_destroy(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
begin
Writeln(SysLogPrefix, 'pthread_attr_destroy');
Result:=EINVAL;
if (pAttr=nil) then Exit;
if (pAttr=nil) then Exit(EINVAL);
if (pAttr^=nil) then Exit(EINVAL);
SwFreeMem(XCHG(pAttr^,nil));
Result:=0;
end;
@ -147,10 +149,11 @@ end;
function ps4_pthread_attr_setschedpolicy(pAttr:p_pthread_attr_t;policy:Integer):Integer; SysV_ABI_CDecl;
begin
Result:=EINVAL;
if (pAttr=nil) then Exit;
if (pAttr^=nil) then Exit;
if (pAttr=nil) then Exit(EINVAL);
if (pAttr^=nil) then Exit(EINVAL);
if (policy<SCHED_FIFO) or (policy>SCHED_RR) then Exit(ENOTSUP);
pAttr^^.sched_policy:=policy;
pAttr^^.prio:=SCE_KERNEL_PRIO_FIFO_DEFAULT;
Result:=0;
end;
@ -160,10 +163,19 @@ begin
end;
function ps4_pthread_attr_setschedparam(pAttr:p_pthread_attr_t;param:PInteger):Integer; SysV_ABI_CDecl;
var
policy:Integer;
begin
Result:=EINVAL;
if (pAttr=nil) or (param=nil) then Exit;
if (pAttr^=nil) then Exit;
if (pAttr=nil) then Exit(EINVAL);
if (pAttr^=nil) then Exit(EINVAL);
if (param=nil) then Exit(ENOTSUP);
policy:=pAttr^^.sched_policy;
if (policy=SCHED_FIFO) or (policy=SCHED_RR) then
begin
if (param^>767) or (param^<256) then Exit(ENOTSUP);
end;
pAttr^^.prio:=param^;
Result:=0;
end;
@ -187,6 +199,28 @@ begin
Result:=px2sce(ps4_pthread_attr_getschedparam(pAttr,param));
end;
function ps4_pthread_attr_setinheritsched(pAttr:p_pthread_attr_t;sched_inherit:Integer):Integer; SysV_ABI_CDecl;
begin
Result:=0;
if (pAttr=nil) then Exit(EINVAL);
if (pAttr^=nil) then Exit(EINVAL);
Case sched_inherit of
PTHREAD_INHERIT_SCHED :;
PTHREAD_EXPLICIT_SCHED:;
else
Exit(ENOTSUP);
end;
pAttr^^.sched_inherit:=sched_inherit;
end;
function ps4_scePthreadAttrSetinheritsched(pAttr:p_pthread_attr_t;sched_inherit:Integer):Integer; SysV_ABI_CDecl;
begin
Result:=px2sce(ps4_pthread_attr_setinheritsched(pAttr,sched_inherit));
end;
function ps4_scePthreadAttrSetaffinity(pAttr:p_pthread_attr_t;mask:QWORD):Integer; SysV_ABI_CDecl;
begin
Result:=SCE_KERNEL_ERROR_EINVAL;
@ -205,15 +239,6 @@ begin
Result:=0;
end;
function ps4_scePthreadAttrSetinheritsched(pAttr:p_pthread_attr_t;inheritSched:Integer):Integer; SysV_ABI_CDecl;
begin
Result:=SCE_KERNEL_ERROR_EINVAL;
if (pAttr=nil) then Exit;
if (pAttr^=nil) then Exit;
pAttr^^.sched_inherit:=inheritSched;
Result:=0;
end;
function ps4_scePthreadAttrGetguardsize(pAttr:p_pthread_attr_t;guardSize:PQWORD):Integer; SysV_ABI_CDecl;
begin
if (pAttr=nil) or (guardSize=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);

View File

@ -11,6 +11,8 @@ const
//Run-time invariant values:
PTHREAD_STACK_MIN=16384;
PTHREAD_EXPLICIT_SCHED=0;
PTHREAD_DETACHED =$1;
PTHREAD_SCOPE_SYSTEM =$2;
PTHREAD_INHERIT_SCHED=$4;