This commit is contained in:
red-prig 2023-02-27 00:27:19 +03:00
parent dab2625f02
commit 142137b203
3 changed files with 71 additions and 11 deletions

55
sys/errno.pas Normal file
View File

@ -0,0 +1,55 @@
unit errno;
{$mode ObjFPC}{$H+}
{$CALLING SysV_ABI_CDecl}
interface
{$I sce_errno.inc}
{$I errno.inc}
function px2sce(e:Integer):Integer;
function sce2px(e:Integer):Integer;
function _set_errno(r:Integer):Integer;
function _set_sce_errno(r:Integer):Integer;
implementation
uses
thr_error;
function px2sce(e:Integer):Integer;
begin
if (e=0) then
Result:=0
else
Result:=e-$7ffe0000;
end;
function sce2px(e:Integer):Integer;
begin
if (e=0) then
Result:=0
else
Result:=e+$7ffe0000;
end;
function _set_errno(r:Integer):Integer;
begin
Result:=0;
__error^:=r;
if (r<>0) then
begin
Result:=-1;
end;
end;
function _set_sce_errno(r:Integer):Integer;
begin
__error^:=sce2px(r);
Result:=r;
end;
end.

View File

@ -33,10 +33,6 @@
<Filename Value="..\sys_umtx.pas"/>
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
<Filename Value="..\kern_umtx.pas"/>
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
<Filename Value="..\_umtx.pas"/>
<IsPartOfProject Value="True"/>
@ -141,10 +137,6 @@
<Filename Value="..\sys_cpuset.pas"/>
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
<Filename Value="..\pthread_md.pas"/>
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
<Filename Value="..\..\kernel\libthr\thr_init.pas"/>
<IsPartOfProject Value="True"/>
@ -153,6 +145,18 @@
<Filename Value="..\..\kernel\libthr\thr_error.pas"/>
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
<Filename Value="..\kern\kern_umtx.pas"/>
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
<Filename Value="..\..\kernel\libthr\pthread_md.pas"/>
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
<Filename Value="..\errno.pas"/>
<IsPartOfProject Value="True"/>
</Unit>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -6,7 +6,6 @@ uses
signal,
ucontext,
_umtx,
kern_umtx,
sys_umtx,
time,
kern_time,
@ -18,10 +17,12 @@ uses
trap,
sys_sig,
md_psl,
pthread_md,
kern_umtx,
thr_init,
thr_error,
sysutils;
pthread_md,
sysutils,
errno;
var
mtx:umutex;