From 193994c0a5d15daa08e771ee3363eddf0e9ae5f9 Mon Sep 17 00:00:00 2001
From: marco <marco@freepascal.org>
Date: Wed, 18 Dec 2002 16:49:02 +0000
Subject: [PATCH]  * New RTL. Linux system unit and baseunix operational.

---
 rtl/unix/bunxh.inc    | 115 ++++++++++++++++++++++++++++++++++++++++++
 rtl/unix/bunxovl.inc  | 111 ++++++++++++++++++++++++++++++++++++++++
 rtl/unix/bunxovlh.inc |  43 ++++++++++++++++
 3 files changed, 269 insertions(+)
 create mode 100644 rtl/unix/bunxh.inc
 create mode 100644 rtl/unix/bunxovl.inc
 create mode 100644 rtl/unix/bunxovlh.inc

diff --git a/rtl/unix/bunxh.inc b/rtl/unix/bunxh.inc
new file mode 100644
index 0000000000..8824192fd6
--- /dev/null
+++ b/rtl/unix/bunxh.inc
@@ -0,0 +1,115 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2002 by Marco van de Voort
+
+    The interface part of the baseunix unit.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+Type TGrpArr = Array [0..0] of TGid;		{ C style array workarounds}
+     pGrpArr = ^TGrpArr;
+     TFilDes = Array [0..1] of cInt;
+     pFilDes = ^TFilDes;
+
+    Function  FpsigEmptySet(var nset : TSigSet): cint;
+    Function  FpSigFillSet (var nset : TSigSet): cInt;
+    Function  FpSigAddSet  (var nset : TSigSet; signo : cInt): cInt;
+    Function  FpSigDelSet  (var nset : TSigSet; signo : cInt): cInt;
+    Function  FpSigIsMember(Const nset : TSigSet; signo : cInt): cInt;
+    Function  FpSigProcMask(how : cInt; nset : pSigSet; oset : pSigSet): cInt;
+   {$ifndef ver1_0}
+    Function  FpSigProcMask(how : cInt; Const nset : TSigSet; var oset : TSigSet): cInt;external name 'FPC_SYSC_SIGPROGMASK';
+   {$endif}
+    Function  FpSigPending (var nset : TSigSet): cInt;
+    Function  FpSigSuspend (Const sigmask : TSigSet): cInt;
+
+    Function  FpUmask	   (cmask : TMode): TMode;
+    Function  FpLink	   (existing : pChar; newone : pChar): cInt;
+    Function  FpMkfifo	   (path : pChar; Mode : TMode): cInt;
+    Function  FpChmod	   (path : pChar; Mode : TMode): cInt;
+    Function  FpChown	   (path : pChar; owner : TUid; group : TGid): cInt;
+    Function  FpUtime	   (path : pChar; times : putimbuf): cInt;
+    Function  FpPipe	   (var fildes : tfildes):cInt;
+    Function  FpDup	   (fildes : cInt): cInt;
+    Function  FpDup2	   (fildes, fildes2 : cInt): cInt;
+    Function  FpTimes	   (var buffer : tms): TClock;
+
+    Function  FpAlarm	   (seconds : cuint): cuint;
+    Function  FpPause : cInt;
+    Function  FpSleep      (seconds : cuint): cuint;
+
+    Function  FpGetpid  : TPid;
+    Function  FpGetppid : TPid;
+    Function  FpGetuid  : TUid;
+    Function  FpGeteuid : TUid;
+    Function  FpGetgid  : TGid;
+    Function  FpGetegid : TGid;
+    Function  FpSetuid 	   (uid : TUid): cInt;
+    Function  FpSetgid 	   (gid : TGid): cInt;
+    Function  FpGetgroups (gidsetsize : cInt; var grouplist : tgrparr): cInt;
+    Function  FpGetpgrp : TPid;
+    Function  FpSetsid  : TPid;
+    Function  FpFcntl	   (fildes : cInt; cmd : cInt): cInt;
+    Function  FpFcntl	   (fildes : cInt; cmd : cInt; arg : cInt): cInt;
+    Function  FpFcntl	   (fildes : cInt; cmd : cInt; var arg : flock): cInt;
+
+    Function  FpGetcwd	   (path:pChar; siz:TSize):pChar;
+    Function  FpFork : TPid;
+    Function  FpExecve	   (path : pChar; argv : ppChar; envp: ppChar): cInt;
+    Function  FpExecv	   (path : pChar; argv : ppChar): cInt;
+    Function  FpWaitpid	   (pid : TPid; var stat_loc : cInt; options: cInt): TPid;
+    Function  FpWait	   (var stat_loc : cInt): TPid;
+    Procedure FpExit	   (Status : cInt);
+    Function  FpKill	   (pid : TPid; sig: cInt): cInt;
+    Function  FpUname	   (var name: utsname): cInt;
+    Function  FpOpendir    (dirname : pChar): pDir;
+    Function  FpReaddir	   (var dirp : Dir) : pDirent;
+    Function  FpClosedir   (var dirp : Dir): cInt;
+    Function  FpChdir	   (path : pChar): cInt;
+    Function  FpOpen	   (path : pChar; flags : cInt; Mode: TMode):cInt;
+    Function  FpMkdir	   (path : pChar; Mode: TMode):cInt;
+    Function  FpUnlink	   (path : pChar): cInt;
+    Function  FpRmdir	   (path : pChar): cInt;
+    Function  FpRename	   (old  : pChar; newpath: pChar): cInt;
+    Function  FpFStat	   (fd : cInt; var sb : stat): cInt;
+    Function  FpStat	   (path: pChar; var buf : stat): cInt;
+    Function  FpAccess	   (pathname : pChar; aMode : cInt): cInt;
+    Function  FpClose	   (fd : cInt): cInt;
+    Function  FpRead	   (fd : cInt; buf: pChar; nbytes : TSize): TSsize;
+    Function  FpWrite	   (fd : cInt; buf:pChar; nbytes : TSize): TSsize;
+    Function  FpLseek	   (fd : cInt; offset : TOff; whence : cInt): TOff;
+    Function  FpTime	   (var tloc : TTime): TTime;
+    Function  FpFtruncate  (fd : cInt; flength : TOff): cInt;
+
+    Function  FpGetEnv	   (name : pChar): pChar;
+    Function  FpGetEnv	   (name : String): pChar;
+
+    Function  FPIsDir	   (m : TMode): Boolean;
+    Function  FPIsChr	   (m : TMode): Boolean;
+    Function  FPIsBlk	   (m : TMode): Boolean;
+    Function  FPIsReg	   (m : TMode): Boolean;
+    Function  FPIsFIFO	   (m : TMode): Boolean;
+
+    Function  wifexited    (Status : cInt): cInt;
+    Function  wexitStatus  (Status : cInt): cInt;
+    Function  wstopsig	   (Status : cInt): cInt;
+    Function  wifsignaled  (Status : cInt): cInt;
+    Function  wtermsig	   (Status : cInt): cInt;
+
+{$i bunxovlh.inc}	// overloads and/or redefs.
+
+{
+  $Log$
+  Revision 1.1  2002-12-18 16:49:02  marco
+   * New RTL. Linux system unit and baseunix operational.
+
+
+}
\ No newline at end of file
diff --git a/rtl/unix/bunxovl.inc b/rtl/unix/bunxovl.inc
new file mode 100644
index 0000000000..5f5674bc49
--- /dev/null
+++ b/rtl/unix/bunxovl.inc
@@ -0,0 +1,111 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2002 by Marco van de Voort
+
+    Some generic overloads for stringfunctions in the baseunix unit.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+Function  FpLink (existing : AnsiString; newone : AnsiString): cInt;
+Begin
+  FpLink:=FpLink(pchar(existing),pchar(newone));
+End;
+
+Function  FpMkfifo (path : AnsiString; Mode : TMode): cInt;
+Begin
+  FpMkfifo:=FpMkfifo(pchar(path),mode);
+End;
+
+Function  FpChmod (path : AnsiString; Mode : TMode): cInt;
+Begin
+  FpChmod:=FpChmod(pchar(path),mode);
+End;
+
+Function  FpChown (path : AnsiString; owner : TUid; group : TGid): cInt;
+Begin
+  FpChown:=FpChown(pchar(path),owner,group);
+End;
+
+Function  FpUtime (path : AnsiString; times : putimbuf): cInt;
+Begin
+  FpUtime:=FpUtime(pchar(path),times);
+End;
+
+Function  FpGetcwd (path:AnsiString; siz:TSize):AnsiString;
+Begin
+  FpGetcwd:=FpGetcwd(pchar(path),siz);
+End;
+
+Function  FpExecve (path : AnsiString; argv : ppchar; envp: ppchar): cInt;
+Begin
+  FpExecve:=FpExecve (pchar(path),argv,envp);
+End;
+
+Function  FpExecv (path : AnsiString; argv : ppchar): cInt;
+Begin
+  FpExecv:=FpExecv (pchar(path),argv);
+End;
+
+Function  FpOpendir (dirname : AnsiString): pDir;
+Begin
+  FpOpenDir:=FpOpenDir(dirname);
+End;
+
+Function  FpChdir (path : AnsiString): cInt;
+Begin
+ FpChDir:=FpChdir(pchar(Path));
+End;		   
+
+Function  FpOpen (path : AnsiString; flags : cInt; Mode: TMode):cInt;
+Begin
+  FpOpen:=FpOpen(pchar(Path),flags,mode);
+End;
+
+Function  FpMkdir (path : AnsiString; Mode: TMode):cInt;
+Begin
+  FpMkdir:=FpMkdir(pchar(Path),mode);
+End;
+
+Function  FpUnlink (path : AnsiString): cInt;
+Begin
+  FpUnlink:=FpUnlink(pchar(path));
+End;
+
+Function  FpRmdir (path : AnsiString): cInt;
+Begin
+  FpRmdir:=FpRmdir(pchar(path));
+End;
+
+Function  FpRename (old  : AnsiString;newpath: AnsiString): cInt;
+Begin
+  FpRename:=FpRename(pchar(old),pchar(newpath));
+End;
+
+Function  FpStat (path: AnsiString; var buf : stat): cInt;
+begin
+  FpStat:=FpStat(pchar(path),buf);
+End;
+
+Function FpAccess (pathname : AnsiString; aMode : cInt): cInt; 
+Begin
+  FpAccess:=FpAccess(pchar(pathname),amode);
+End;
+
+{
+ $Log$
+ Revision 1.1  2002-12-18 16:49:02  marco
+  * New RTL. Linux system unit and baseunix operational.
+
+
+}
+
+ 
\ No newline at end of file
diff --git a/rtl/unix/bunxovlh.inc b/rtl/unix/bunxovlh.inc
new file mode 100644
index 0000000000..8cc38700bc
--- /dev/null
+++ b/rtl/unix/bunxovlh.inc
@@ -0,0 +1,43 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2002 by Marco van de Voort
+
+    Some generic overloads for stringfunctions in the baseunix unit.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+Function  FpLink (existing : AnsiString; newone : AnsiString): cInt;
+Function  FpMkfifo (path : AnsiString; Mode : TMode): cInt;
+Function  FpChmod (path : AnsiString; Mode : TMode): cInt;
+Function  FpChown (path : AnsiString; owner : TUid; group : TGid): cInt;
+Function  FpUtime (path : AnsiString; times : putimbuf): cInt;
+Function  FpGetcwd (path:AnsiString; siz:TSize):AnsiString;
+Function  FpExecve (path : AnsiString; argv : ppchar; envp: ppchar): cInt;
+Function  FpExecv (path : AnsiString; argv : ppchar): cInt;
+Function  FpOpendir (dirname : AnsiString): pDir;
+Function  FpChdir (path : AnsiString): cInt;
+Function  FpOpen (path : AnsiString; flags : cInt; Mode: TMode):cInt;
+Function  FpMkdir (path : AnsiString; Mode: TMode):cInt;
+Function  FpUnlink (path : AnsiString): cInt;
+Function  FpRmdir (path : AnsiString): cInt;
+Function  FpRename (old  : AnsiString;newpath: AnsiString): cInt;
+Function  FpStat (path: AnsiString; var buf : stat): cInt;
+Function  FpAccess (pathname : AnsiString; aMode : cInt): cInt; 
+
+{
+ $Log$
+ Revision 1.1  2002-12-18 16:49:02  marco
+  * New RTL. Linux system unit and baseunix operational.
+
+
+}
+
+ 
\ No newline at end of file