2
This file is part of the Free Pascal run time library.
3
Copyright (c) 2001 by Free Pascal development team
5
This file implements all the base types and limits required
6
for a minimal POSIX compliant subset required to port the compiler
9
See the file COPYING.FPC, included in this distribution,
10
for details about the copyright.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
**********************************************************************}
23
function geterrnolocation: Plibcint; cdecl;external clib name '___errno';
25
function geterrno:libcint; [public, alias: 'FPC_SYS_GETERRNO'];
27
geterrno:=geterrnolocation^;
30
procedure seterrno(err:libcint); [public, alias: 'FPC_SYS_SETERRNO'];
32
geterrnolocation^:=err;
35
{ OS dependant parts }
37
{$I errno.inc} // error numbers
38
{$I ostypes.inc} // c-types, unix base types, unix base structures
44
{*****************************************************************************
46
*****************************************************************************}
48
Function PosixToRunError (PosixErrno : longint) : longint;
50
Convert ErrNo error to the correct Inoutres value
54
if PosixErrNo=0 then { Else it will go through all the cases }
58
ESysEMFILE : Inoutres:=4;
59
ESysENOENT : Inoutres:=2;
60
ESysEBADF : Inoutres:=6;
62
ESysEFAULT : Inoutres:=217;
63
ESysEINVAL : Inoutres:=218;
68
ESysENOSPC : Inoutres:=101;
69
ESysENAMETOOLONG : Inoutres := 3;
73
ESysEACCES : Inoutres:=5;
74
ESysEISDIR : InOutRes:=5;
77
InOutRes := Integer(PosixErrno);
80
PosixToRunError:=InOutRes;
83
Function Errno2InoutRes : longint;
86
Errno2InoutRes:=PosixToRunError(getErrno);
87
InoutRes:=Errno2InoutRes;
92
{*****************************************************************************
93
Low Level File Routines
94
*****************************************************************************}
96
function do_isdevice(handle:longint):boolean;
98
do_isdevice:= (handle=StdInputHandle) or
99
(handle=StdOutputHandle) or
100
(handle=StdErrorHandle);