mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-22 16:09:17 +02:00
* more cleanup of unit unix (merge)
git-svn-id: trunk@7269 -
This commit is contained in:
parent
cb8e361672
commit
699e231223
127
rtl/unix/unix.pp
127
rtl/unix/unix.pp
@ -22,47 +22,47 @@ Uses BaseUnix,UnixType;
|
|||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
{$i aliasptp.inc}
|
{$i aliasptp.inc}
|
||||||
|
{$i unxconst.inc} { Get Types and Constants only exported in this unit }
|
||||||
|
|
||||||
{ Get Types and Constants only exported in this unit }
|
{** File handling **}
|
||||||
{$i unxconst.inc}
|
|
||||||
|
|
||||||
// We init to zero to be able to put timezone stuff under IFDEF, and still
|
|
||||||
// keep the code working.
|
|
||||||
// We can't do this hear, since unixutil functions access this.
|
|
||||||
|
|
||||||
// var
|
|
||||||
// Tzseconds : Longint = 0;
|
|
||||||
|
|
||||||
|
|
||||||
{********************
|
|
||||||
File
|
|
||||||
********************}
|
|
||||||
|
|
||||||
Const
|
Const
|
||||||
P_IN = 1; // pipes (?)
|
P_IN = 1; // pipes (?)
|
||||||
P_OUT = 2;
|
P_OUT = 2;
|
||||||
|
|
||||||
Const
|
|
||||||
LOCK_SH = 1; // flock constants ?
|
LOCK_SH = 1; // flock constants ?
|
||||||
LOCK_EX = 2;
|
LOCK_EX = 2;
|
||||||
LOCK_UN = 8;
|
LOCK_UN = 8;
|
||||||
LOCK_NB = 4;
|
LOCK_NB = 4;
|
||||||
|
|
||||||
|
// The portable MAP_* and PROT_ constants are exported from unit Unix for compability.
|
||||||
|
PROT_READ = baseunix.PROT_READ; { page can be read }
|
||||||
|
PROT_WRITE = baseunix.PROT_WRITE; { page can be written }
|
||||||
|
PROT_EXEC = baseunix.PROT_EXEC; { page can be executed }
|
||||||
|
PROT_NONE = baseunix.PROT_NONE; { page can not be accessed }
|
||||||
|
|
||||||
|
MAP_FAILED = baseunix.MAP_FAILED; { mmap() failed }
|
||||||
|
MAP_SHARED = baseunix.MAP_SHARED; { Share changes }
|
||||||
|
MAP_PRIVATE = baseunix.MAP_PRIVATE; { Changes are private }
|
||||||
|
MAP_TYPE = baseunix.MAP_TYPE; { Mask for type of mapping }
|
||||||
|
MAP_FIXED = baseunix.MAP_FIXED; { Interpret addr exactly }
|
||||||
|
|
||||||
|
{ Flags to `msync'. There is non msync() call in this unit? }
|
||||||
|
MS_ASYNC = 1; { Sync memory asynchronously. }
|
||||||
|
MS_SYNC = 4; { Synchronous memory sync. }
|
||||||
|
MS_INVALIDATE = 2; { Invalidate the caches. }
|
||||||
|
|
||||||
Type
|
Type
|
||||||
Tpipe = baseunix.tfildes; // compability.
|
Tpipe = baseunix.tfildes; // compability.
|
||||||
|
|
||||||
{******************************************************************************
|
{** Time/Date Handling **}
|
||||||
Procedure/Functions
|
|
||||||
******************************************************************************}
|
|
||||||
|
|
||||||
{**************************
|
|
||||||
Time/Date Handling
|
|
||||||
***************************}
|
|
||||||
|
|
||||||
var
|
var
|
||||||
tzdaylight : boolean;
|
tzdaylight : boolean;
|
||||||
tzname : array[boolean] of pchar;
|
tzname : array[boolean] of pchar;
|
||||||
|
|
||||||
|
{************ Procedure/Functions ************)
|
||||||
|
|
||||||
{$IFNDEF DONT_READ_TIMEZONE} // allows to disable linking in and trying for platforms
|
{$IFNDEF DONT_READ_TIMEZONE} // allows to disable linking in and trying for platforms
|
||||||
// it doesn't (yet) work for.
|
// it doesn't (yet) work for.
|
||||||
|
|
||||||
@ -73,13 +73,7 @@ procedure ReadTimezoneFile(fn:string);
|
|||||||
function GetTimezoneFile:string;
|
function GetTimezoneFile:string;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{**************************
|
{** Process Handling **}
|
||||||
Process Handling
|
|
||||||
***************************}
|
|
||||||
|
|
||||||
//
|
|
||||||
// These are much better, in nearly all ways.
|
|
||||||
//
|
|
||||||
|
|
||||||
function FpExecLE (Const PathName:AnsiString;const S:Array Of AnsiString;MyEnv:ppchar):cint;
|
function FpExecLE (Const PathName:AnsiString;const S:Array Of AnsiString;MyEnv:ppchar):cint;
|
||||||
function FpExecL (Const PathName:AnsiString;const S:Array Of AnsiString):cint;
|
function FpExecL (Const PathName:AnsiString;const S:Array Of AnsiString):cint;
|
||||||
@ -94,77 +88,48 @@ Function fpSystem(const Command:string):cint;
|
|||||||
Function fpSystem(const Command:AnsiString):cint;
|
Function fpSystem(const Command:AnsiString):cint;
|
||||||
|
|
||||||
Function WaitProcess (Pid:cint):cint;
|
Function WaitProcess (Pid:cint):cint;
|
||||||
{ like WaitPid(PID,@result,0) Handling of Signal interrupts (errno=EINTR), returning the Exitcode of Process (>=0) or -Status if terminated}
|
|
||||||
|
|
||||||
Function WIFSTOPPED (Status: Integer): Boolean;
|
Function WIFSTOPPED (Status: Integer): Boolean;
|
||||||
Function W_EXITCODE (ReturnCode, Signal: Integer): Integer;
|
Function W_EXITCODE (ReturnCode, Signal: Integer): Integer;
|
||||||
Function W_STOPCODE (Signal: Integer): Integer;
|
Function W_STOPCODE (Signal: Integer): Integer;
|
||||||
|
|
||||||
{**************************
|
{** File Handling **}
|
||||||
File Handling
|
|
||||||
***************************}
|
|
||||||
|
|
||||||
{$ifndef FPC_USE_LIBC} // defined using cdecl for libc.
|
{$ifndef FPC_USE_LIBC} // defined using cdecl for libc.
|
||||||
Function fsync (fd : cint) : cint;
|
// some of these are formally listed as deprecated, but specially statfs will remain for a while, no rush.
|
||||||
|
Function fsync (fd : cint) : cint; deprecated;
|
||||||
Function fpFlock (fd,mode : cint) : cint ;
|
Function fpFlock (fd,mode : cint) : cint ;
|
||||||
Function fStatFS (Fd: cint;Var Info:tstatfs):cint;
|
Function fStatFS (Fd: cint;Var Info:tstatfs):cint; deprecated;
|
||||||
Function StatFS (Path:pchar;Var Info:tstatfs):cint;
|
Function StatFS (Path:pchar;Var Info:tstatfs):cint; deprecated;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
Function fpfStatFS (Fd: cint; Info:pstatfs):cint;
|
||||||
|
Function fpStatFS (Path:pchar; Info:pstatfs):cint;
|
||||||
|
Function fpfsync (fd : cint) : cint;
|
||||||
|
|
||||||
Function fpFlock (var T : text;mode : cint) : cint;
|
Function fpFlock (var T : text;mode : cint) : cint;
|
||||||
Function fpFlock (var F : File;mode : cint) : cint;
|
Function fpFlock (var F : File;mode : cint) : cint;
|
||||||
|
|
||||||
Function SelectText (var T:Text;TimeOut :PTimeVal):cint; deprecated;
|
Function SelectText (var T:Text;TimeOut :PTimeVal):cint; deprecated;
|
||||||
Function SelectText (var T:Text;TimeOut :cint):cint; deprecated;
|
Function SelectText (var T:Text;TimeOut :cint):cint; deprecated;
|
||||||
|
|
||||||
{**************************
|
{** Directory Handling **}
|
||||||
Directory Handling
|
|
||||||
***************************}
|
|
||||||
|
|
||||||
procedure SeekDir(p:pdir;loc:clong);
|
procedure SeekDir(p:pdir;loc:clong);
|
||||||
function TellDir(p:pdir):TOff;
|
function TellDir(p:pdir):TOff;
|
||||||
|
|
||||||
{**************************
|
{** Pipe/Fifo/Stream **}
|
||||||
Pipe/Fifo/Stream
|
|
||||||
***************************}
|
|
||||||
|
|
||||||
Function AssignPipe (var pipe_in,pipe_out:cint):cint;
|
Function AssignPipe (var pipe_in,pipe_out:cint):cint;
|
||||||
Function AssignPipe (var pipe_in,pipe_out:text):cint;
|
Function AssignPipe (var pipe_in,pipe_out:text):cint;
|
||||||
Function AssignPipe (var pipe_in,pipe_out:file):cint;
|
Function AssignPipe (var pipe_in,pipe_out:file):cint;
|
||||||
//Function PClose (Var F:text) : cint;
|
|
||||||
//Function PClose (Var F:file) : cint;
|
|
||||||
Function POpen (var F:text;const Prog:Ansistring;rw:char):cint;
|
Function POpen (var F:text;const Prog:Ansistring;rw:char):cint;
|
||||||
Function POpen (var F:file;const Prog:Ansistring;rw:char):cint;
|
Function POpen (var F:file;const Prog:Ansistring;rw:char):cint;
|
||||||
Function AssignStream(Var StreamIn,Streamout:text;Const Prog:ansiString;const args : array of ansistring) : cint;
|
Function AssignStream(Var StreamIn,Streamout:text;Const Prog:ansiString;const args : array of ansistring) : cint;
|
||||||
Function AssignStream(Var StreamIn,Streamout,streamerr:text;Const Prog:ansiString;const args : array of ansistring) : cint;
|
Function AssignStream(Var StreamIn,Streamout,streamerr:text;Const Prog:ansiString;const args : array of ansistring) : cint;
|
||||||
|
Function GetDomainName:String; deprecated; // because linux only.
|
||||||
Function GetDomainName:String;
|
|
||||||
Function GetHostName:String;
|
Function GetHostName:String;
|
||||||
|
|
||||||
|
|
||||||
{**************************
|
|
||||||
Memory functions
|
|
||||||
***************************}
|
|
||||||
|
|
||||||
Const
|
|
||||||
// The portable MAP_* and PROT_ constants are exported from unit Unix for compability.
|
|
||||||
|
|
||||||
PROT_READ = baseunix.PROT_READ; { page can be read }
|
|
||||||
PROT_WRITE = baseunix.PROT_WRITE; { page can be written }
|
|
||||||
PROT_EXEC = baseunix.PROT_EXEC; { page can be executed }
|
|
||||||
PROT_NONE = baseunix.PROT_NONE; { page can not be accessed }
|
|
||||||
|
|
||||||
MAP_FAILED = baseunix.MAP_FAILED; { mmap() failed }
|
|
||||||
MAP_SHARED = baseunix.MAP_SHARED; { Share changes }
|
|
||||||
MAP_PRIVATE = baseunix.MAP_PRIVATE; { Changes are private }
|
|
||||||
MAP_TYPE = baseunix.MAP_TYPE; { Mask for type of mapping }
|
|
||||||
MAP_FIXED = baseunix.MAP_FIXED; { Interpret addr exactly }
|
|
||||||
|
|
||||||
{ Flags to `msync'. }
|
|
||||||
MS_ASYNC = 1; { Sync memory asynchronously. }
|
|
||||||
MS_SYNC = 4; { Synchronous memory sync. }
|
|
||||||
MS_INVALIDATE = 2; { Invalidate the caches. }
|
|
||||||
|
|
||||||
{**************************
|
{**************************
|
||||||
Utility functions
|
Utility functions
|
||||||
***************************}
|
***************************}
|
||||||
@ -177,7 +142,7 @@ Type
|
|||||||
Function FSearch (const path:AnsiString;dirlist:Ansistring;CurrentDirStrategy:TFSearchOption):AnsiString;
|
Function FSearch (const path:AnsiString;dirlist:Ansistring;CurrentDirStrategy:TFSearchOption):AnsiString;
|
||||||
Function FSearch (const path:AnsiString;dirlist:AnsiString):AnsiString;
|
Function FSearch (const path:AnsiString;dirlist:AnsiString):AnsiString;
|
||||||
|
|
||||||
procedure SigRaise (sig:integer);
|
procedure SigRaise (sig:integer); deprecated;
|
||||||
|
|
||||||
{$ifdef FPC_USE_LIBC}
|
{$ifdef FPC_USE_LIBC}
|
||||||
const clib = 'c';
|
const clib = 'c';
|
||||||
@ -1267,7 +1232,6 @@ begin
|
|||||||
fpKill(fpGetPid,Sig);
|
fpKill(fpGetPid,Sig);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{******************************************************************************
|
{******************************************************************************
|
||||||
Utility calls
|
Utility calls
|
||||||
******************************************************************************}
|
******************************************************************************}
|
||||||
@ -1336,9 +1300,22 @@ Begin
|
|||||||
FSearch:=FSearch(path,dirlist,CurrentDirectoryFirst);
|
FSearch:=FSearch(path,dirlist,CurrentDirectoryFirst);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
{--------------------------------
|
Function fpfStatFS (Fd: cint; Info:pstatfs):cint;
|
||||||
Stat.Mode Macro's
|
begin
|
||||||
--------------------------------}
|
fpfstatfs:=fstatfs(fd,info^);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function fpStatFS (Path:pchar; Info:pstatfs):cint;
|
||||||
|
|
||||||
|
begin
|
||||||
|
fpstatfs:=statfs(Path,info^);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function fpfsync (fd : cint) : cint;
|
||||||
|
|
||||||
|
begin
|
||||||
|
fpfsync:=fsync(fd);
|
||||||
|
end;
|
||||||
|
|
||||||
Initialization
|
Initialization
|
||||||
{$IFNDEF DONT_READ_TIMEZONE}
|
{$IFNDEF DONT_READ_TIMEZONE}
|
||||||
|
Loading…
Reference in New Issue
Block a user