* Optimize posixtorunerror for size. Because inoutres is a threadvar, it

had an invisible code blowup.

git-svn-id: trunk@5006 -
This commit is contained in:
daniel 2006-10-22 21:03:48 +00:00
parent 9f5a2063a1
commit b89cff5980

View File

@ -79,43 +79,49 @@ end;
correct value if an error has occured, else leave it untouched correct value if an error has occured, else leave it untouched
} }
Function PosixToRunError (PosixErrno : longint) : longint; function PosixToRunError (PosixErrno : longint):word;
{ {
Convert ErrNo error to the correct Inoutres value Convert ErrNo error to the correct Inoutres value
} }
var r:word; {Inoutres is declared as word.}
begin begin
if PosixErrNo=0 then { Else it will go through all the cases } (*
if PosixErrNo=0 then {Else it will go through all the cases}
exit(0); exit(0);
Statement commented out. It will not go through all the cases. (DM)
*)
case PosixErrNo of case PosixErrNo of
ESysENFILE, ESysENFILE,
ESysEMFILE : Inoutres:=4; ESysEMFILE: r:=4;
ESysENOENT : Inoutres:=2; ESysENOENT: r:=2;
ESysEBADF : Inoutres:=6; ESysEBADF: r:=6;
ESysENOMEM, ESysENOMEM,
ESysEFAULT : Inoutres:=217; ESysEFAULT: r:=217;
ESysEINVAL : Inoutres:=218; ESysEINVAL: r:=218;
ESysEPIPE, ESysEPIPE,
ESysEINTR, ESysEINTR,
ESysEIO, ESysEIO,
ESysEAGAIN, ESysEAGAIN,
ESysENOSPC : Inoutres:=101; ESysENOSPC: r:=101;
ESysENAMETOOLONG : Inoutres := 3; ESysENAMETOOLONG: r:=3;
ESysEROFS, ESysEROFS,
ESysEEXIST, ESysEEXIST,
ESysENOTEMPTY, ESysENOTEMPTY,
ESysEACCES : Inoutres:=5; ESysEACCES: r:=5;
ESysEISDIR : InOutRes:=5; ESysEISDIR: r:=5;
else else
begin r:=PosixErrno;
InOutRes := Integer(PosixErrno);
end; end;
end; inoutres:=r;
PosixToRunError:=InOutRes; PosixToRunError:=r;
end; end;
Function Errno2InoutRes : longint; function Errno2InoutRes : word;
begin begin
Errno2InoutRes:=PosixToRunError(getErrno); Errno2InoutRes:=PosixToRunError(getErrno);
InoutRes:=Errno2InoutRes; InoutRes:=Errno2InoutRes;