mirror of https://github.com/red-prig/fpPS4.git
Separate pthread_attr
This commit is contained in:
parent
a60e8a2126
commit
be570f1c63
|
@ -31,7 +31,7 @@
|
|||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="120">
|
||||
<Units Count="121">
|
||||
<Unit0>
|
||||
<Filename Value="fpPS4.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
|
@ -549,6 +549,10 @@
|
|||
<Filename Value="kernel\mm_adr_name.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit119>
|
||||
<Unit120>
|
||||
<Filename Value="kernel\ps4_pthread_attr.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit120>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
|
|
@ -11,6 +11,7 @@ uses
|
|||
ps4_map_mm,
|
||||
ps4_mspace_internal,
|
||||
ps4_pthread,
|
||||
ps4_pthread_attr,
|
||||
ps4_pthread_key,
|
||||
ps4_signal,
|
||||
ps4_mutex,
|
||||
|
|
|
@ -10,32 +10,6 @@ uses
|
|||
sys_pthread,
|
||||
sys_signal;
|
||||
|
||||
function ps4_pthread_set_defaultstacksize_np(size:QWORD):Integer; SysV_ABI_CDecl;
|
||||
function ps4_scePthreadSetDefaultstacksize(size:QWORD):Integer; SysV_ABI_CDecl;
|
||||
|
||||
function ps4_scePthreadAttrInit(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
function ps4_scePthreadAttrDestroy(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
function ps4_pthread_attr_init(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
function ps4_pthread_attr_destroy(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
function ps4_scePthreadAttrSetstacksize(pAttr:p_pthread_attr_t;size:size_t):Integer; SysV_ABI_CDecl;
|
||||
function ps4_pthread_attr_setstacksize(pAttr:p_pthread_attr_t;size:size_t):Integer; SysV_ABI_CDecl;
|
||||
function ps4_scePthreadAttrSetdetachstate(pAttr:p_pthread_attr_t;detachstate:Integer):Integer; SysV_ABI_CDecl;
|
||||
function ps4_pthread_attr_setdetachstate(pAttr:p_pthread_attr_t;detachstate:Integer):Integer; SysV_ABI_CDecl;
|
||||
function ps4_scePthreadAttrSetschedpolicy(pAttr:p_pthread_attr_t;policy:Integer):Integer; SysV_ABI_CDecl;
|
||||
function ps4_scePthreadAttrSetschedparam(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_setschedparam(pAttr:p_pthread_attr_t;param:PInteger):Integer; SysV_ABI_CDecl;
|
||||
function ps4_pthread_attr_getschedparam(pAttr:p_pthread_attr_t;param:PInteger):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;
|
||||
function ps4_scePthreadAttrGetstack(pAttr:p_pthread_attr_t;stackAddr:PPointer;stackSize:PQWORD):Integer; SysV_ABI_CDecl;
|
||||
function ps4_scePthreadAttrGetdetachstate(pAttr:p_pthread_attr_t;detachstate:Pinteger):Integer; SysV_ABI_CDecl;
|
||||
function ps4_pthread_attr_getdetachstate(pAttr:p_pthread_attr_t;detachstate:Pinteger):Integer; SysV_ABI_CDecl;
|
||||
|
||||
function ps4_scePthreadAttrGet(pid:pthread;pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
|
||||
function ps4_pthread_create_name_np(pthread:p_pthread;pAttr:p_pthread_attr_t;entry:Pointer;arg:Pointer;name:Pchar):Integer; SysV_ABI_CDecl;
|
||||
|
@ -113,254 +87,8 @@ uses
|
|||
ps4_mutex,
|
||||
ps4_map_mm,
|
||||
ps4_program,
|
||||
ps4_elf;
|
||||
|
||||
|
||||
const
|
||||
default_name:Pchar='main';
|
||||
|
||||
var
|
||||
default_main_stack:Integer=DefaultStackSize;
|
||||
default_stack_size:QWORD=$10000;
|
||||
|
||||
function ps4_pthread_set_defaultstacksize_np(size:QWORD):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=EINVAL;
|
||||
if (size>PTHREAD_STACK_MIN) then
|
||||
begin
|
||||
default_stack_size:=size;
|
||||
Result:=0;
|
||||
end;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadSetDefaultstacksize(size:QWORD):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=px2sce(ps4_pthread_set_defaultstacksize_np(size));
|
||||
end;
|
||||
|
||||
//struct pthread_attr _pthread_attr_default = {
|
||||
// .sched_policy = SCHED_OTHER,
|
||||
// .sched_inherit = PTHREAD_INHERIT_SCHED,
|
||||
// .prio = 0,
|
||||
// .suspend = THR_CREATE_RUNNING,
|
||||
// .flags = PTHREAD_SCOPE_SYSTEM,
|
||||
// .stackaddr_attr = NULL,
|
||||
// .stacksize_attr = THR_STACK_DEFAULT,
|
||||
// .guardsize_attr = 0,
|
||||
// .cpusetsize = 0,
|
||||
// .cpuset = NULL
|
||||
//};
|
||||
|
||||
function ps4_scePthreadAttrInit(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Writeln(SysLogPrefix, 'scePthreadAttrInit');
|
||||
if (pAttr=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
pAttr^:=SwAllocMem(SizeOf(tthread_attr_t));
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_ENOMEM);
|
||||
pAttr^^.stacksize_attr:=default_stack_size;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrDestroy(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Writeln(SysLogPrefix, 'scePthreadAttrDestroy');
|
||||
Result:=SCE_KERNEL_ERROR_EINVAL;
|
||||
if (pAttr=nil) then Exit;
|
||||
SwFreeMem(XCHG(pAttr^,nil));
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_pthread_attr_init(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Writeln(SysLogPrefix, 'pthread_attr_init');
|
||||
if (pAttr=nil) then Exit(EINVAL);
|
||||
pAttr^:=SwAllocMem(SizeOf(tthread_attr_t));
|
||||
if (pAttr^=nil) then Exit(ENOMEM);
|
||||
pAttr^^.stacksize_attr:=default_stack_size;
|
||||
Result:=0;
|
||||
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;
|
||||
SwFreeMem(XCHG(pAttr^,nil));
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrSetstacksize(pAttr:p_pthread_attr_t;size:size_t):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
if (pAttr=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
if (size<PTHREAD_STACK_MIN) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
pAttr^^.stacksize_attr:=size;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_pthread_attr_setstacksize(pAttr:p_pthread_attr_t;size:size_t):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
if (pAttr=nil) then Exit(EINVAL);
|
||||
if (pAttr^=nil) then Exit(EINVAL);
|
||||
if (size<PTHREAD_STACK_MIN) then Exit(EINVAL);
|
||||
pAttr^^.stacksize_attr:=size;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrSetdetachstate(pAttr:p_pthread_attr_t;detachstate:Integer):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=SCE_KERNEL_ERROR_EINVAL;
|
||||
if (pAttr=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
|
||||
Case detachstate of
|
||||
PTHREAD_CREATE_JOINABLE:;
|
||||
PTHREAD_CREATE_DETACHED:;
|
||||
else
|
||||
Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
end;
|
||||
|
||||
pAttr^^.flags:=detachstate;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_pthread_attr_setdetachstate(pAttr:p_pthread_attr_t;detachstate:Integer):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=EINVAL;
|
||||
if (pAttr=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
|
||||
Case detachstate of
|
||||
PTHREAD_CREATE_JOINABLE:;
|
||||
PTHREAD_CREATE_DETACHED:;
|
||||
else
|
||||
Exit(EINVAL);
|
||||
end;
|
||||
|
||||
pAttr^^.flags:=detachstate;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrSetschedpolicy(pAttr:p_pthread_attr_t;policy:Integer):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=SCE_KERNEL_ERROR_EINVAL;
|
||||
if (pAttr=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
pAttr^^.sched_policy:=policy;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrSetschedparam(pAttr:p_pthread_attr_t;param:PInteger):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=SCE_KERNEL_ERROR_EINVAL;
|
||||
if (pAttr=nil) or (param=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
pAttr^^.prio:=param^;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrGetschedparam(pAttr:p_pthread_attr_t;param:PInteger):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=SCE_KERNEL_ERROR_EINVAL;
|
||||
if (pAttr=nil) or (param=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
param^:=pAttr^^.prio;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_pthread_attr_setschedparam(pAttr:p_pthread_attr_t;param:PInteger):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=EINVAL;
|
||||
if (pAttr=nil) or (param=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
pAttr^^.prio:=param^;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_pthread_attr_getschedparam(pAttr:p_pthread_attr_t;param:PInteger):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=EINVAL;
|
||||
if (pAttr=nil) or (param=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
param^:=pAttr^^.prio;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrSetaffinity(pAttr:p_pthread_attr_t;mask:QWORD):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=SCE_KERNEL_ERROR_EINVAL;
|
||||
if (pAttr=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
pAttr^^.cpuset:=mask;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrGetaffinity(pAttr:p_pthread_attr_t;mask:PQWORD):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=SCE_KERNEL_ERROR_EINVAL;
|
||||
if (pAttr=nil) or (mask=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
mask^:=pAttr^^.cpuset;
|
||||
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);
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
guardSize^:=pAttr^^.guardsize_attr;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrGetstackaddr(pAttr:p_pthread_attr_t;stackAddr:PPointer):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
if (pAttr=nil) or (stackAddr=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
stackAddr^:=pAttr^^.stackaddr_attr;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrGetstacksize(pAttr:p_pthread_attr_t;stackSize:PQWORD):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
if (pAttr=nil) or (stackSize=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
stackSize^:=pAttr^^.stacksize_attr;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrGetstack(pAttr:p_pthread_attr_t;stackAddr:PPointer;stackSize:PQWORD):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
if (pAttr=nil) or (stackAddr=nil) or (stackSize=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
stackAddr^:=pAttr^^.stackaddr_attr;
|
||||
stackSize^:=pAttr^^.stacksize_attr;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrGetdetachstate(pAttr:p_pthread_attr_t;detachstate:Pinteger):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
if (pAttr=nil) or (detachstate=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
detachstate^:=pAttr^^.flags;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_pthread_attr_getdetachstate(pAttr:p_pthread_attr_t;detachstate:Pinteger):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
if (pAttr=nil) or (detachstate=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
detachstate^:=pAttr^^.flags;
|
||||
Result:=0;
|
||||
end;
|
||||
ps4_elf,
|
||||
ps4_pthread_attr;
|
||||
|
||||
procedure _free_pthread(data:pthread);
|
||||
begin
|
||||
|
|
|
@ -0,0 +1,287 @@
|
|||
unit ps4_pthread_attr;
|
||||
|
||||
{$mode ObjFPC}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
atomic,
|
||||
sys_kernel,
|
||||
sys_pthread;
|
||||
|
||||
const
|
||||
default_name:Pchar='main';
|
||||
|
||||
var
|
||||
default_main_stack:Integer=DefaultStackSize;
|
||||
default_stack_size:QWORD=$10000;
|
||||
|
||||
function ps4_pthread_set_defaultstacksize_np(size:QWORD):Integer; SysV_ABI_CDecl;
|
||||
function ps4_scePthreadSetDefaultstacksize(size:QWORD):Integer; SysV_ABI_CDecl;
|
||||
|
||||
function ps4_scePthreadAttrInit(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
function ps4_scePthreadAttrDestroy(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
function ps4_pthread_attr_init(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
function ps4_pthread_attr_destroy(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
function ps4_scePthreadAttrSetstacksize(pAttr:p_pthread_attr_t;size:size_t):Integer; SysV_ABI_CDecl;
|
||||
function ps4_pthread_attr_setstacksize(pAttr:p_pthread_attr_t;size:size_t):Integer; SysV_ABI_CDecl;
|
||||
function ps4_scePthreadAttrSetdetachstate(pAttr:p_pthread_attr_t;detachstate:Integer):Integer; SysV_ABI_CDecl;
|
||||
function ps4_pthread_attr_setdetachstate(pAttr:p_pthread_attr_t;detachstate:Integer):Integer; SysV_ABI_CDecl;
|
||||
function ps4_scePthreadAttrSetschedpolicy(pAttr:p_pthread_attr_t;policy:Integer):Integer; SysV_ABI_CDecl;
|
||||
function ps4_scePthreadAttrSetschedparam(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_setschedparam(pAttr:p_pthread_attr_t;param:PInteger):Integer; SysV_ABI_CDecl;
|
||||
function ps4_pthread_attr_getschedparam(pAttr:p_pthread_attr_t;param:PInteger):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;
|
||||
function ps4_scePthreadAttrGetstack(pAttr:p_pthread_attr_t;stackAddr:PPointer;stackSize:PQWORD):Integer; SysV_ABI_CDecl;
|
||||
function ps4_scePthreadAttrGetdetachstate(pAttr:p_pthread_attr_t;detachstate:Pinteger):Integer; SysV_ABI_CDecl;
|
||||
function ps4_pthread_attr_getdetachstate(pAttr:p_pthread_attr_t;detachstate:Pinteger):Integer; SysV_ABI_CDecl;
|
||||
|
||||
implementation
|
||||
|
||||
function ps4_pthread_set_defaultstacksize_np(size:QWORD):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=EINVAL;
|
||||
if (size>PTHREAD_STACK_MIN) then
|
||||
begin
|
||||
default_stack_size:=size;
|
||||
Result:=0;
|
||||
end;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadSetDefaultstacksize(size:QWORD):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=px2sce(ps4_pthread_set_defaultstacksize_np(size));
|
||||
end;
|
||||
|
||||
//struct pthread_attr _pthread_attr_default = {
|
||||
// .sched_policy = SCHED_OTHER,
|
||||
// .sched_inherit = PTHREAD_INHERIT_SCHED,
|
||||
// .prio = 0,
|
||||
// .suspend = THR_CREATE_RUNNING,
|
||||
// .flags = PTHREAD_SCOPE_SYSTEM,
|
||||
// .stackaddr_attr = NULL,
|
||||
// .stacksize_attr = THR_STACK_DEFAULT,
|
||||
// .guardsize_attr = 0,
|
||||
// .cpusetsize = 0,
|
||||
// .cpuset = NULL
|
||||
//};
|
||||
|
||||
function ps4_scePthreadAttrInit(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Writeln(SysLogPrefix, 'scePthreadAttrInit');
|
||||
if (pAttr=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
pAttr^:=SwAllocMem(SizeOf(tthread_attr_t));
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_ENOMEM);
|
||||
pAttr^^.stacksize_attr:=default_stack_size;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrDestroy(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Writeln(SysLogPrefix, 'scePthreadAttrDestroy');
|
||||
Result:=SCE_KERNEL_ERROR_EINVAL;
|
||||
if (pAttr=nil) then Exit;
|
||||
SwFreeMem(XCHG(pAttr^,nil));
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_pthread_attr_init(pAttr:p_pthread_attr_t):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Writeln(SysLogPrefix, 'pthread_attr_init');
|
||||
if (pAttr=nil) then Exit(EINVAL);
|
||||
pAttr^:=SwAllocMem(SizeOf(tthread_attr_t));
|
||||
if (pAttr^=nil) then Exit(ENOMEM);
|
||||
pAttr^^.stacksize_attr:=default_stack_size;
|
||||
Result:=0;
|
||||
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;
|
||||
SwFreeMem(XCHG(pAttr^,nil));
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrSetstacksize(pAttr:p_pthread_attr_t;size:size_t):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
if (pAttr=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
if (size<PTHREAD_STACK_MIN) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
pAttr^^.stacksize_attr:=size;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_pthread_attr_setstacksize(pAttr:p_pthread_attr_t;size:size_t):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
if (pAttr=nil) then Exit(EINVAL);
|
||||
if (pAttr^=nil) then Exit(EINVAL);
|
||||
if (size<PTHREAD_STACK_MIN) then Exit(EINVAL);
|
||||
pAttr^^.stacksize_attr:=size;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrSetdetachstate(pAttr:p_pthread_attr_t;detachstate:Integer):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=SCE_KERNEL_ERROR_EINVAL;
|
||||
if (pAttr=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
|
||||
Case detachstate of
|
||||
PTHREAD_CREATE_JOINABLE:;
|
||||
PTHREAD_CREATE_DETACHED:;
|
||||
else
|
||||
Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
end;
|
||||
|
||||
pAttr^^.flags:=detachstate;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_pthread_attr_setdetachstate(pAttr:p_pthread_attr_t;detachstate:Integer):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=EINVAL;
|
||||
if (pAttr=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
|
||||
Case detachstate of
|
||||
PTHREAD_CREATE_JOINABLE:;
|
||||
PTHREAD_CREATE_DETACHED:;
|
||||
else
|
||||
Exit(EINVAL);
|
||||
end;
|
||||
|
||||
pAttr^^.flags:=detachstate;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrSetschedpolicy(pAttr:p_pthread_attr_t;policy:Integer):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=SCE_KERNEL_ERROR_EINVAL;
|
||||
if (pAttr=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
pAttr^^.sched_policy:=policy;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrSetschedparam(pAttr:p_pthread_attr_t;param:PInteger):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=SCE_KERNEL_ERROR_EINVAL;
|
||||
if (pAttr=nil) or (param=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
pAttr^^.prio:=param^;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrGetschedparam(pAttr:p_pthread_attr_t;param:PInteger):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=SCE_KERNEL_ERROR_EINVAL;
|
||||
if (pAttr=nil) or (param=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
param^:=pAttr^^.prio;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_pthread_attr_setschedparam(pAttr:p_pthread_attr_t;param:PInteger):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=EINVAL;
|
||||
if (pAttr=nil) or (param=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
pAttr^^.prio:=param^;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_pthread_attr_getschedparam(pAttr:p_pthread_attr_t;param:PInteger):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=EINVAL;
|
||||
if (pAttr=nil) or (param=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
param^:=pAttr^^.prio;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrSetaffinity(pAttr:p_pthread_attr_t;mask:QWORD):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=SCE_KERNEL_ERROR_EINVAL;
|
||||
if (pAttr=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
pAttr^^.cpuset:=mask;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrGetaffinity(pAttr:p_pthread_attr_t;mask:PQWORD):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Result:=SCE_KERNEL_ERROR_EINVAL;
|
||||
if (pAttr=nil) or (mask=nil) then Exit;
|
||||
if (pAttr^=nil) then Exit;
|
||||
mask^:=pAttr^^.cpuset;
|
||||
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);
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
guardSize^:=pAttr^^.guardsize_attr;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrGetstackaddr(pAttr:p_pthread_attr_t;stackAddr:PPointer):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
if (pAttr=nil) or (stackAddr=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
stackAddr^:=pAttr^^.stackaddr_attr;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrGetstacksize(pAttr:p_pthread_attr_t;stackSize:PQWORD):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
if (pAttr=nil) or (stackSize=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
stackSize^:=pAttr^^.stacksize_attr;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrGetstack(pAttr:p_pthread_attr_t;stackAddr:PPointer;stackSize:PQWORD):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
if (pAttr=nil) or (stackAddr=nil) or (stackSize=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
stackAddr^:=pAttr^^.stackaddr_attr;
|
||||
stackSize^:=pAttr^^.stacksize_attr;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_scePthreadAttrGetdetachstate(pAttr:p_pthread_attr_t;detachstate:Pinteger):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
if (pAttr=nil) or (detachstate=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
detachstate^:=pAttr^^.flags;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function ps4_pthread_attr_getdetachstate(pAttr:p_pthread_attr_t;detachstate:Pinteger):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
if (pAttr=nil) or (detachstate=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
if (pAttr^=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
detachstate^:=pAttr^^.flags;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue