Browse Source

* Unix reform stage two. Remove all calls from Unix that exist in Baseunix.

marco 22 years ago
parent
commit
7efaf7dee2
57 changed files with 1374 additions and 2542 deletions
  1. 12 1
      rtl/bsd/baseunix.pp
  2. 18 9
      rtl/bsd/bunxfunc.inc
  3. 69 0
      rtl/bsd/bunxfunch.inc
  4. 9 6
      rtl/bsd/bunxmacr.inc
  5. 15 1
      rtl/bsd/bunxtype.inc
  6. 13 10
      rtl/bsd/i386/syscallh.inc
  7. 8 4
      rtl/bsd/ossysc.inc
  8. 7 3
      rtl/bsd/ossysch.inc
  9. 4 6
      rtl/bsd/ostypes.inc
  10. 99 0
      rtl/bsd/unxsysc.inc
  11. 9 0
      rtl/bsd/unxsysch.inc
  12. 63 0
      rtl/freebsd/i386/x86.inc
  13. 8 0
      rtl/freebsd/i386/x86h.inc
  14. 10 1
      rtl/freebsd/ptypes.inc
  15. 9 483
      rtl/freebsd/syscalls.inc
  16. 4 120
      rtl/freebsd/systypes.inc
  17. 6 587
      rtl/freebsd/unixsysc.inc
  18. 6 3
      rtl/inc/sockets.inc
  19. 1 2
      rtl/linux/Makefile
  20. 11 1
      rtl/linux/baseunix.pp
  21. 25 4
      rtl/linux/bunxfunc.inc
  22. 21 11
      rtl/linux/bunxtype.inc
  23. 18 19
      rtl/linux/i386/syscall.inc
  24. 9 10
      rtl/linux/i386/syscallh.inc
  25. 22 12
      rtl/linux/ossysc.inc
  26. 6 2
      rtl/linux/ossysch.inc
  27. 10 8
      rtl/linux/ostypes.inc
  28. 7 4
      rtl/linux/pthread.inc
  29. 13 1
      rtl/linux/ptypes.inc
  30. 5 8
      rtl/linux/signal.inc
  31. 10 5
      rtl/linux/syscallo.inc
  32. 4 287
      rtl/linux/syscalls.inc
  33. 5 1
      rtl/linux/system.pp
  34. 18 7
      rtl/linux/systypes.inc
  35. 8 7
      rtl/linux/unixsock.inc
  36. 53 78
      rtl/linux/unixsysc.inc
  37. 14 1
      rtl/unix/bunxh.inc
  38. 177 5
      rtl/unix/bunxovl.inc
  39. 42 21
      rtl/unix/bunxovlh.inc
  40. 24 21
      rtl/unix/crt.pp
  41. 34 35
      rtl/unix/dos.pp
  42. 6 3
      rtl/unix/genfuncs.inc
  43. 5 2
      rtl/unix/gpm.pp
  44. 5 2
      rtl/unix/graph.pp
  45. 13 10
      rtl/unix/ipc.pp
  46. 48 45
      rtl/unix/keyboard.pp
  47. 190 87
      rtl/unix/linux.pp
  48. 13 10
      rtl/unix/mouse.pp
  49. 14 11
      rtl/unix/printer.pp
  50. 20 17
      rtl/unix/serial.pp
  51. 5 3
      rtl/unix/sockets.pp
  52. 14 4
      rtl/unix/systhrds.pp
  53. 32 27
      rtl/unix/sysutils.pp
  54. 6 3
      rtl/unix/terminfo.pp
  55. 24 21
      rtl/unix/timezone.inc
  56. 57 500
      rtl/unix/unix.pp
  57. 16 13
      rtl/unix/video.pp

+ 12 - 1
rtl/bsd/baseunix.pp

@@ -28,16 +28,27 @@ Interface
 {$i bunxtype.inc}	{ Types }
 {$i bunxtype.inc}	{ Types }
 {$i bunxh.inc}		{ Functions}
 {$i bunxh.inc}		{ Functions}
 
 
+function fpgeterrno:longint; 
+procedure fpseterrno(err:longint); 
+
+
 implementation
 implementation
 
 
+
 {$i bunxmain.inc}	{ implementation}
 {$i bunxmain.inc}	{ implementation}
 {$i bunxovl.inc}	{ redefs and overloads implementation}
 {$i bunxovl.inc}	{ redefs and overloads implementation}
 
 
+function fpgeterrno:longint; external name 'FPC_SYS_GETERRNO';
+procedure fpseterrno(err:longint); external name 'FPC_SYS_SETERRNO';
+
 end.
 end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2003-06-03 14:23:45  marco
+  Revision 1.3  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.2  2003/06/03 14:23:45  marco
    * Moved prototypes outside of baseunix. And shared with linux for now
    * Moved prototypes outside of baseunix. And shared with linux for now
 
 
   Revision 1.1  2003/01/05 19:01:28  marco
   Revision 1.1  2003/01/05 19:01:28  marco

+ 18 - 9
rtl/bsd/bunxfunc.inc

@@ -21,17 +21,12 @@
 {$i ossysch.inc}	// external interface to syscalls in system unit.
 {$i ossysch.inc}	// external interface to syscalls in system unit.
 {$i genfuncs.inc}	// generic calls. (like getenv)
 {$i genfuncs.inc}	// generic calls. (like getenv)
 
 
-Const 			// OS specific parameters for general sigset behaviour
-   SIG_MAXSIG      = 128;	// highest signal version
-   wordsinsigset   = 4;		// words in sigset_t
-   ln2bitsinword   = 5;         { 32bit : ln(32)/ln(2)=5 } 
-
-   ln2bitmask	   = 2 shl ln2bitsinword - 1;
 
 
 {$I gensigset.inc}     // general sigset funcs implementation. 
 {$I gensigset.inc}     // general sigset funcs implementation. 
+{$I genfdset.inc}      // general fdset funcs.
 
 
 {  $ ifndef ver1_0}
 {  $ ifndef ver1_0}
-Function  FpSigProcMask(how : cInt; Const nset : TSigSet; var oset : TSigSet): cInt; external name 'FPC_SYSC_SIGPROGMASK';
+Function  FpSigProcMask(how : cInt; Const nset : TSigSet; var oset : TSigSet): cInt; external name 'FPC_SYSC_SIGPROCMASK';
 {   $ endif}
 {   $ endif}
 
 
 Function FPKill(Pid:pid_t;Sig:cint):cint;
 Function FPKill(Pid:pid_t;Sig:cint):cint;
@@ -50,7 +45,8 @@ begin
 //  Kill:=0;
 //  Kill:=0;
 end;
 end;
 
 
-function FPSigProcMask(how:cint;nset : psigset;oset : psigset):cint; [public, alias: 'FPC_SYSC_SIGPROCMASK'];
+function FPSigProcMask(how:cint;nset : psigset;oset : psigset):cint; [public, alias : 'FPC_SYSC_SIGPROCMASK'];
+
 {
 {
   Change the list of currently blocked signals.
   Change the list of currently blocked signals.
   How determines which signals will be blocked :
   How determines which signals will be blocked :
@@ -460,10 +456,23 @@ begin
 	FPtimes:=clock_t(CONVTCK(t));
 	FPtimes:=clock_t(CONVTCK(t));
 end;
 end;
 
 
+Function fpSelect(N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint;
+{
+  Select checks whether the file descriptor sets in readfs/writefs/exceptfs
+  have changed.
+}
+
+begin
+ fpSelect:=do_syscall(syscall_nr_select,n,longint(readfds),longint(writefds),longint(exceptfds),longint(timeout));
+end;
+
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.2  2003-01-05 19:10:05  marco
+ Revision 1.3  2003-09-14 20:15:01  marco
+  * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+ Revision 1.2  2003/01/05 19:10:05  marco
   * Small sigprocmask fix
   * Small sigprocmask fix
 
 
  Revision 1.1  2003/01/05 19:01:28  marco
  Revision 1.1  2003/01/05 19:01:28  marco

+ 69 - 0
rtl/bsd/bunxfunch.inc

@@ -0,0 +1,69 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2002 by Marco van de Voort
+
+    Headerfile  of bunxfunc.inc (which should be calls needed for the
+    Baseunix unit, but not for system)
+
+    Some calls that can be used for both Linux and *BSD will be
+    moved to a /unix/ includedfile later.
+
+    Note: calls named in bunxh.inc aren't listed here.
+
+    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  FpSigProcMask(how : cInt; Const nset : TSigSet; var oset : TSigSet): cInt;
+//Function FPKill(Pid:pid_t;Sig:cint):cint;
+//function FPSigProcMask(how:cint;nset : psigset;oset : psigset):cint; 
+//Function FPSigPending(var nset: sigset_t):cint;
+//function FPsigsuspend(const sigmask:sigset_t):cint;
+Function SetITimer(Which : Longint;Const value : ItimerVal; var VarOValue:ItimerVal):Longint;
+Function GetITimer(Which : Longint;Var value : ItimerVal):Longint;
+//Function FPalarm(Seconds: cuint):cuint;
+//function sigblock(mask:cuint):cint;
+//function sigpause(sigmask:cint):cint;
+//function FPpause:cint;
+//function FPsleep(seconds:cuint):cuint;
+//function FPuname(var name:utsname):cint; 
+//function FPwait(var stat_loc:cint): pid_t;
+//function FPgetpid : pid_t;
+//function FPgetppid : pid_t;
+//function FPgetuid : uid_t;
+//function FPgeteuid : uid_t;
+//function FPgetgid : gid_t;
+//function FPgetegid : gid_t;
+//function FPsetuid(uid : uid_t): cint;
+//function FPsetgid(gid : gid_t): cint;
+//function FPgetgroups(gidsetsize : cint; var grouplist:tgrparr): cint;
+//function FPgetpgrp : pid_t;
+//function FPsetsid : pid_t;
+//Function FPumask(cmask:mode_t):mode_t;
+//Function FPlink(existing:pchar;newone:pchar):cint;
+//Function FPmkfifo(path:pchar;mode:mode_t):cint;
+//Function FPchmod(path:pchar;mode:mode_t):cint;
+//Function FPchown(path:pchar;owner:uid_t;group:gid_t):cint;
+//Function FPUtime(path:pchar;times:putimbuf):cint;
+//Function FPpipe(var fildes : tfildes):cint;
+//function FPfcntl(fildes:cint;Cmd:cint;Arg:cint):cint;
+//function FPfcntl(fildes:cint;Cmd:cint;var Arg:flock):cint;
+//function FPfcntl(fildes:cint;Cmd:cint):cint;
+//function FPexecve(path:pchar;argv:ppchar;envp:ppchar):cint;
+//function FPexecv(path:pchar;argv:ppchar):cint;
+function FPgetrusage(who:cint;var ru : rusage):cint;
+//function FPtimes(var buffer : tms):clock_t;
+
+{
+ $Log$
+ Revision 1.1  2003-09-14 20:15:01  marco
+  * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+
+}

+ 9 - 6
rtl/bsd/bunxmacr.inc

@@ -23,28 +23,28 @@
  ****************************************************************************
  ****************************************************************************
 }
 }
 
 
-function FPISDIR(m : mode_t): boolean;
+function FPISDIR(m : TMode): boolean;
 
 
 begin
 begin
  FPISDIR:=((m and %001111000000000000) = %100000000000000);
  FPISDIR:=((m and %001111000000000000) = %100000000000000);
 end;
 end;
 
 
-function FPISCHR(m : mode_t): boolean;
+function FPISCHR(m : TMode): boolean;
 begin
 begin
  FPISCHR:=((m and %001111000000000000) = %10000000000000);
  FPISCHR:=((m and %001111000000000000) = %10000000000000);
 end;
 end;
 
 
-function FPISBLK(m : mode_t): boolean;
+function FPISBLK(m : TMode): boolean;
 begin
 begin
  FPISBLK:=((m and %001111000000000000) = %110000000000000);
  FPISBLK:=((m and %001111000000000000) = %110000000000000);
 end;
 end;
 
 
-function FPISREG(m : mode_t): boolean;
+function FPISREG(m : TMode): boolean;
 begin
 begin
  FPISREG:=((m and %001111000000000000) = %1000000000000000);
  FPISREG:=((m and %001111000000000000) = %1000000000000000);
 end;
 end;
 
 
-function FPISFIFO(m : mode_t): boolean;
+function FPISFIFO(m : TMode): boolean;
 begin
 begin
  FPISFIFO:=((m and %001111000000000000) = %1000000000000);
  FPISFIFO:=((m and %001111000000000000) = %1000000000000);
 end;
 end;
@@ -79,7 +79,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2003-01-21 15:34:59  marco
+  Revision 1.3  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.2  2003/01/21 15:34:59  marco
    * fix octal that broke 1.0.x
    * fix octal that broke 1.0.x
 
 
   Revision 1.1  2003/01/05 19:01:28  marco
   Revision 1.1  2003/01/05 19:01:28  marco

+ 15 - 1
rtl/bsd/bunxtype.inc

@@ -36,6 +36,13 @@
 //    _UTSNAME_LENGTH = ;
 //    _UTSNAME_LENGTH = ;
 //    _UTSNAME_NODENAME_LENGTH = ;
 //    _UTSNAME_NODENAME_LENGTH = ;
 
 
+CONST                		// OS specific parameters for general<fd,sig>set behaviour
+   SIG_MAXSIG      = 128;	// highest signal version
+   FD_MAXFDSET	   = 1024;
+   wordsinsigset   = 4;		// words in sigset_t
+   ln2bitsinword   = 5;         { 32bit : ln(32)/ln(2)=5 } 
+   ln2bitmask	   = 2 shl ln2bitsinword - 1;
+
 TYPE
 TYPE
    { system information services }
    { system information services }
    utsname = record
    utsname = record
@@ -137,6 +144,9 @@ TYPE
  TTms= tms;
  TTms= tms;
  pTms= ^tms;
  pTms= ^tms;
 
 
+ TFDSet    = ARRAY[0..(FD_MAXFDSET div 32)-1] of Cardinal;
+ pFDSet    = ^TFDSet;
+
 {***********************************************************************}
 {***********************************************************************}
 {                  POSIX CONSTANT ROUTINE DEFINITIONS                   }
 {                  POSIX CONSTANT ROUTINE DEFINITIONS                   }
 {***********************************************************************}
 {***********************************************************************}
@@ -180,6 +190,7 @@ CONST
     WUNTRACED =          2;     { report status of stopped children }
     WUNTRACED =          2;     { report status of stopped children }
 
 
 
 
+
     {*************************************************************************}
     {*************************************************************************}
     {                               SIGNALS                                   }
     {                               SIGNALS                                   }
     {*************************************************************************}
     {*************************************************************************}
@@ -191,7 +202,10 @@ CONST
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2003-08-21 22:23:34  olle
+  Revision 1.4  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.3  2003/08/21 22:23:34  olle
     - removed parameter from fpc_iocheck
     - removed parameter from fpc_iocheck
 
 
   Revision 1.2  2003/06/01 16:35:27  marco
   Revision 1.2  2003/06/01 16:35:27  marco

+ 13 - 10
rtl/bsd/i386/syscallh.inc

@@ -34,19 +34,22 @@ Type
 
 
   TSysParam  = Longint;
   TSysParam  = Longint;
 
 
-function Do_SysCall(sysnr:TSysParam):TSysResult;  external name 'FPC_DOSYS0';
-function Do_SysCall(sysnr,param1:TSysParam):TSysResult; external name 'FPC_DOSYS1';
-//function Do_SysCall(sysnr,param1:integer):TSysResult; external name 'FPC_DOSYS1w';
-function Do_SysCall(sysnr,param1,param2:TSysParam):TSysResult;  external name 'FPC_DOSYS2';
-function Do_SysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; external name 'FPC_DOSYS3';
-function Do_SysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; external name 'FPC_DOSYS4';
-function Do_SysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult;  external name 'FPC_DOSYS5';
-function Do_SysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):int64;  external name 'FPC_DOSYS6';
-function Do_SysCall(sysnr,param1,param2,param3,param4,param5,param6,param7:TSysParam):int64;   external name 'FPC_DOSYS7';
+function do_sysCall(sysnr:TSysParam):TSysResult;  external name 'FPC_DOSYS0';
+function do_sysCall(sysnr,param1:TSysParam):TSysResult; external name 'FPC_DOSYS1';
+//function do_sysCall(sysnr,param1:integer):TSysResult; external name 'FPC_DOSYS1w';
+function do_sysCall(sysnr,param1,param2:TSysParam):TSysResult;  external name 'FPC_DOSYS2';
+function do_sysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; external name 'FPC_DOSYS3';
+function do_sysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; external name 'FPC_DOSYS4';
+function do_sysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult;  external name 'FPC_DOSYS5';
+function do_sysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):int64;  external name 'FPC_DOSYS6';
+function do_sysCall(sysnr,param1,param2,param3,param4,param5,param6,param7:TSysParam):int64;   external name 'FPC_DOSYS7';
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2003-05-30 19:58:40  marco
+  Revision 1.7  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.6  2003/05/30 19:58:40  marco
    * Getting NetBSD/i386 to compile.
    * Getting NetBSD/i386 to compile.
 
 
   Revision 1.5  2003/01/05 19:01:28  marco
   Revision 1.5  2003/01/05 19:01:28  marco

+ 8 - 4
rtl/bsd/ossysc.inc

@@ -492,7 +492,8 @@ end;
   Data points to data needed for the Ndx function. The structure of this
   Data points to data needed for the Ndx function. The structure of this
   data is function-dependent.
   data is function-dependent.
 }
 }
-Function FpIOCtl(Handle,Ndx: Longint;Data: Pointer):LongInt;  [public, alias : 'FPC_SYSC_IOCTL'];
+
+Function FpIOCtl(Handle:cint;Ndx: culong;Data: Pointer):cint; [public, alias : 'FPC_SYSC_IOCTL'];
 // This was missing here, instead hardcoded in Do_IsDevice
 // This was missing here, instead hardcoded in Do_IsDevice
 begin
 begin
   FpIOCtl:=do_SysCall(syscall_nr_ioctl,handle,Ndx,TSysParam(data));
   FpIOCtl:=do_SysCall(syscall_nr_ioctl,handle,Ndx,TSysParam(data));
@@ -524,10 +525,10 @@ begin
  FpGetPID:=do_syscall(syscall_nr_getpid);
  FpGetPID:=do_syscall(syscall_nr_getpid);
 end;
 end;
 
 
-Function FpReadLink(name,linkname:pchar;maxlen:longint):longint;  [public, alias : 'FPC_SYSC_READLINK'];
+function gettimeofday(tp: ptimeval;tzp:ptimezone):cint; [public, alias: 'FPC_SYSC_GETTIMEOFDAY'];
 
 
 begin
 begin
-  Fpreadlink:=do_syscall(syscall_nr_readlink, TSysParam(name),TSysParam(linkname),maxlen);
+ gettimeofday:=do_syscall(syscall_nr_gettimeofday,TSysParam(tp),TSysParam(tzp));
 end;
 end;
 
 
 Function FpNanoSleep(const req : timespec;var rem : timespec) : longint; [public, alias : 'FPC_SYSC_NANOSLEEP'];
 Function FpNanoSleep(const req : timespec;var rem : timespec) : longint; [public, alias : 'FPC_SYSC_NANOSLEEP'];
@@ -597,7 +598,10 @@ end;
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.5  2003-08-21 22:23:34  olle
+ Revision 1.6  2003-09-14 20:15:01  marco
+  * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+ Revision 1.5  2003/08/21 22:23:34  olle
    - removed parameter from fpc_iocheck
    - removed parameter from fpc_iocheck
 
 
  Revision 1.4  2003/05/29 21:45:23  marco
  Revision 1.4  2003/05/29 21:45:23  marco

+ 7 - 3
rtl/bsd/ossysch.inc

@@ -17,10 +17,11 @@
 
 
 Function Fpmmap(adr,len,prot,flags,fdes,off:longint):longint;  external name  'FPC_SYSC_MMAP';
 Function Fpmmap(adr,len,prot,flags,fdes,off:longint):longint;  external name  'FPC_SYSC_MMAP';
 Function Fpmunmap(adr:longint;len:size_t):longint;  external name 'FPC_SYSC_MUNMAP';
 Function Fpmunmap(adr:longint;len:size_t):longint;  external name 'FPC_SYSC_MUNMAP';
-Function FpIOCtl(Handle,Ndx: Longint;Data: Pointer):LongInt;  external name  'FPC_SYSC_IOCTL';
+Function FpIOCtl(Handle:cint;Ndx: culong;Data: Pointer):cint;  external name  'FPC_SYSC_IOCTL';
 Function FpGetPid:LongInt;   external name  'FPC_SYSC_GETPID';
 Function FpGetPid:LongInt;   external name  'FPC_SYSC_GETPID';
-Function FpReadLink(name,linkname:pchar;maxlen:longint):longint;  external name  'FPC_SYSC_READLINK';
+//Function FpReadLink(name,linkname:pchar;maxlen:longint):longint;  external name  'FPC_SYSC_READLINK';
 
 
+function gettimeofday(tp: ptimeval;tzp:ptimezone):cint; external name 'FPC_SYSC_GETTIMEOFDAY';
 { Needed in both POSIX (for implementation of sleep()) as POSIX realtime extensions or  Unix/freebsd}
 { Needed in both POSIX (for implementation of sleep()) as POSIX realtime extensions or  Unix/freebsd}
 Function FpNanoSleep (const req : timespec;var rem : timespec) : longint; external name 'FPC_SYSC_NANOSLEEP';
 Function FpNanoSleep (const req : timespec;var rem : timespec) : longint; external name 'FPC_SYSC_NANOSLEEP';
 
 
@@ -29,7 +30,10 @@ Function Fpgetcwd (path:pchar; siz:size_t):pchar; external name 'FPC_SYSC_GETCWD
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2003-01-05 19:01:28  marco
+  Revision 1.2  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.1  2003/01/05 19:01:28  marco
    * FreeBSD compiles now with baseunix mods.
    * FreeBSD compiles now with baseunix mods.
 
 
   Revision 1.4  2002/10/27 11:58:29  marco
   Revision 1.4  2002/10/27 11:58:29  marco

+ 4 - 6
rtl/bsd/ostypes.inc

@@ -22,11 +22,6 @@
 }
 }
 
 
 Type
 Type
-  timeval  = packed record
-    tv_sec,tv_usec:clong;
-  end;
-  ptimeval = ^timeval;
-  TTimeVal = timeval;
 
 
   timespec = packed record
   timespec = packed record
     tv_sec   : time_t;
     tv_sec   : time_t;
@@ -63,7 +58,10 @@ Type
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.1  2003-01-05 19:01:28  marco
+ Revision 1.2  2003-09-14 20:15:01  marco
+  * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+ Revision 1.1  2003/01/05 19:01:28  marco
   * FreeBSD compiles now with baseunix mods.
   * FreeBSD compiles now with baseunix mods.
 
 
  Revision 1.4  2002/10/27 17:21:29  marco
  Revision 1.4  2002/10/27 17:21:29  marco

+ 99 - 0
rtl/bsd/unxsysc.inc

@@ -0,0 +1,99 @@
+
+function fpNice(N:cint):cint;
+{
+  Set process priority. A positive N means a lower priority.
+  A negative N decreases priority.
+
+Doesn't exist in BSD. Linux emu uses setpriority in a construct as below:
+}
+
+begin
+  fpNice:=fpSetPriority(Prio_Process,0,N);
+end;
+
+Function fpGetPriority(Which,Who:cint):cint;
+{
+  Get Priority of process, process group, or user.
+   Which : selects what kind of priority is used.
+           can be one of the following predefined Constants :
+              Prio_User.
+              Prio_PGrp.
+              Prio_Process.
+   Who : depending on which, this is , respectively :
+              Uid
+              Pid
+              Process Group id
+   Errors are reported in linuxerror _only_. (priority can be negative)
+}
+begin
+  if (which<prio_process) or (which>prio_user) then
+   begin
+     { We can save an interrupt here }
+     fpgetpriority:=0;
+     linuxerror:=ESysEinval;
+   end
+  else
+   begin
+     fpGetPriority:=do_syscall(syscall_nr_GetPriority,which,who);
+   end;
+end;
+
+Function fpSetPriority(Which,Who,What:cint):cint;
+{
+ Set Priority of process, process group, or user.
+   Which : selects what kind of priority is used.
+           can be one of the following predefined Constants :
+              Prio_User.
+              Prio_PGrp.
+              Prio_Process.
+   Who : depending on value of which, this is, respectively :
+              Uid
+              Pid
+              Process Group id
+   what : A number between -20 and 20. -20 is most favorable, 20 least.
+          0 is the default.
+}
+begin
+  if ((which<prio_process) or (which>prio_user)) or ((what<-20) or (what>20)) then
+   fpseterrno(ESyseinval)  { We can save an interrupt here }
+  else
+   begin
+     fpSetPriority:=do_syscall(Syscall_nr_Setpriority,which,who,what);
+   end;
+end;
+
+Function fpLstat(path:pchar;Info:pstat):cint;
+{
+  Get all information on a link (the link itself), and return it in info.
+}
+
+begin
+ fpLStat:=do_syscall(syscall_nr_lstat,TSysParam(path),TSysParam(info));
+end;
+
+Function fpLstat(Filename: PathStr;Info:pstat):cint;
+{
+  Get all information on a link (the link itself), and return it in info.
+}
+
+begin
+ FileName:=FileName+#0;
+ fpLStat:=do_syscall(syscall_nr_lstat,TSysParam(@filename[1]),TSysParam(info));
+end;
+
+Function fpSymlink(oldname,newname:pchar):cint;
+{
+  We need this for erase
+}
+
+begin
+ fpsymlink:=do_syscall(syscall_nr_symlink,TSysParam(oldname),TSysParam(newname));
+end;
+
+Function fpReadLink(name,linkname:pchar;maxlen:cint):cint;
+
+begin
+  fpreadlink:=do_syscall(syscall_nr_readlink, TSysParam(name),TSysParam(linkname),maxlen);
+end;
+
+

+ 9 - 0
rtl/bsd/unxsysch.inc

@@ -0,0 +1,9 @@
+
+function fpNice(N:cint):cint;
+Function fpGetPriority(Which,Who:cint):cint;
+Function fpSetPriority(Which,Who,What:cint):cint;
+Function fpLstat(path:pchar;Info:pstat):cint;
+Function fpLstat(Filename: PathStr;Info:pstat):cint;
+Function fpSymlink(oldname,newname:pchar):cint;
+Function fpReadLink(name,linkname:pchar;maxlen:cint):cint;
+

+ 63 - 0
rtl/freebsd/i386/x86.inc

@@ -0,0 +1,63 @@
+{$packrecords C}
+
+TYPE uint=CARDINAL;
+
+CONST
+        I386_GET_LDT    =0;
+        I386_SET_LDT    =1;
+                                { I386_IOPL }
+        I386_GET_IOPERM =3;
+        I386_SET_IOPERM =4;
+                                { xxxxx }
+        I386_VM86       =6;
+
+{
+type i386_ldt_args = record
+        int     start : longint;
+        union   descriptor *descs;
+        int     num;
+        end;
+}
+type
+ i386_ioperm_args = record
+        start    : uint;
+        length   : uint;
+        enable   : longint;
+        end;
+
+
+    i386_vm86_args = record
+        sub_op   : longint;             { sub-operation to perform }
+        sub_args : pchar;               { args }
+        end;
+
+   sysarch_args     = record
+                        op    : longint;
+                        parms : pchar;
+                       end;
+
+{
+int i386_get_ldt __P((int, union descriptor *, int));
+int i386_set_ldt __P((int, union descriptor *, int));
+int i386_get_ioperm __P((unsigned int, unsigned int *, int *));
+int i386_set_ioperm __P((unsigned int, unsigned int, int));
+int i386_vm86 __P((int, void *));
+int i386_set_watch __P((int watchnum, unsigned int watchaddr, int size,
+                        int access, struct dbreg * d));
+int i386_clr_watch __P((int watchnum, struct dbreg * d));
+}
+
+Function IOPerm(From,Num:CARDINAL;Value:Longint):boolean;
+
+var sg : i386_ioperm_args;
+    sa : sysarch_args;
+
+begin
+  sg.start:=From;
+  sg.length:=Num;
+  sg.enable:=value;
+  sa.op:=i386_SET_IOPERM;
+  sa.parms:=@sg;
+  IOPerm:=do_syscall(syscall_nr_sysarch,longint(@sa))=0;
+  LinuxError:=ErrNo;
+end;

+ 8 - 0
rtl/freebsd/i386/x86h.inc

@@ -0,0 +1,8 @@
+{**************************
+     Port IO functions
+***************************}
+
+Function  IOperm (From,Num : Cardinal; Value : Longint) : boolean;
+{$ifndef BSD}
+Function  IoPL(Level : longint) : Boolean;
+{$endif}

+ 10 - 1
rtl/freebsd/ptypes.inc

@@ -76,6 +76,12 @@ type
     TSocklen = socklen_t;
     TSocklen = socklen_t;
     pSocklen = ^socklen_t;
     pSocklen = ^socklen_t;
 
 
+  timeval  = packed record
+    tv_sec,tv_usec:clong;
+  end;
+  ptimeval = ^timeval;
+  TTimeVal = timeval;
+
 CONST
 CONST
    { System limits, POSIX value in parentheses, used for buffer and stack allocation }
    { System limits, POSIX value in parentheses, used for buffer and stack allocation }
     ARG_MAX  = 65536;   {4096}  { Maximum number of argument size     }
     ARG_MAX  = 65536;   {4096}  { Maximum number of argument size     }
@@ -86,7 +92,10 @@ CONST
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2003-01-03 13:11:32  marco
+  Revision 1.6  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.5  2003/01/03 13:11:32  marco
    * split into ptypes and ctypes
    * split into ptypes and ctypes
 
 
 
 

+ 9 - 483
rtl/freebsd/syscalls.inc

@@ -24,497 +24,23 @@
                      --- Main:The System Call Self ---
                      --- Main:The System Call Self ---
 *****************************************************************************}
 *****************************************************************************}
 
 
-{ The system designed for Linux can't be used for FreeBSD so easily, since
-  FreeBSD pushes arguments, instead of loading them to registers.
 
 
-For now I do them in assembler, which makes it easier to test them (copy and
-paste to and AS source). Ultimately I hope to design something like this}
-
-{actualsyscall:
-  _actualsyscall : int $0x80
-                   jb someerror
-                   ret
-      someerror:   storeerrorsomewhere
-                   ret
-}
-
-{
-procedure actualsyscall; cdecl; EXTERNAL NAME '_actualsyscall';
-}
-
-procedure actualsyscall; assembler; {inline requires a dummy push IIRC}
-    asm
-         int $0x80
-         jb .LErrorcode
-         xor %ebx,%ebx
-         ret
-.LErrorcode:
-         mov %eax,%ebx
-         mov $-1,%eax
-   end;
-
-function Do_SysCall(sysnr:LONGINT):longint; assembler;
-
-asm
-  movl  sysnr,%eax
-  call  actualsyscall
-  movw  %bx,Errno
-end;
-
-function Do_SysCall(sysnr,param1:longint):longint; assembler;
-
- asm
-  movl  sysnr,%eax
-  pushl Param1
-  call  actualsyscall
-  addl  $4,%esp
-  movw  %bx,Errno
- end;
-
-{function Do_SysCall(sysnr,param1:integer):longint; assembler;
-
- asm
-  movl  sysnr,%eax
-  pushw Param1
-  call  actualsyscall
-  add   $2,%esp
-  movw  %bx,Errno
- end;
-}
-
-function Do_SysCall(sysnr,param1,param2:LONGINT):longint; assembler;
-
- asm
-   movl  sysnr,%eax
-   pushl param2
-   pushl Param1
-   call  actualsyscall
-   addl  $8,%esp
-   movw  %bx,Errno
- end;
-
-function Do_SysCall(sysnr,param1,param2,param3:LONGINT):longint; assembler;
-
- asm
-   movl  sysnr,%eax
-   pushl param3
-   pushl param2
-   pushl Param1
-   call  actualsyscall
-   addl  $12,%esp
-   movw  %bx,Errno
- end;
-
-function Do_SysCall(sysnr,param1,param2,param3,param4:LONGINT):longint; assembler;
-
-asm
-   movl  sysnr,%eax
-   pushl param4
-   pushl param3
-   pushl param2
-   pushl Param1
-   call  actualsyscall
-   addl  $16,%esp
-   movw  %bx,Errno
-end;
-
-
-function Do_SysCall(sysnr,param1,param2,param3,param4,param5:LONGINT):longint;  assembler;
-
- asm
-   movl  sysnr,%eax
-   pushl param5
-   pushl param4
-   pushl param3
-   pushl param2
-   pushl Param1
-   call  actualsyscall
-   addl  $20,%esp
-   movw  %bx,Errno
- end;
-
-function Do_SysCall(sysnr,param1,param2,param3,param4,param5,param6:LONGINT):int64;  assembler;
-
-asm
-   movl  sysnr,%eax
-   pushl param6
-   pushl param5
-   pushl param4
-   pushl param3
-   pushl param2
-   pushl Param1
-   call  actualsyscall
-   addl  $24,%esp
-   movw  %bx,Errno
-end;
-
-
-function Do_SysCall(sysnr,param1,param2,param3,param4,param5,param6,param7:LONGINT):int64;  assembler;
-
-asm
-   movl  sysnr,%eax
-   pushl param7
-   pushl param6
-   pushl param5
-   pushl param4
-   pushl param3
-   pushl param2
-   pushl Param1
-   call  actualsyscall
-   addl  $28,%esp
-   movw  %bx,Errno
-end;
-
-Function Sys_Time:longint;
-
-VAR tv     : timeval;
-    tz     : timezone;
-    retval : longint;
-
-begin
-  Retval:=do_syscall(116,longint(@tv),longint(@tz));
-  If retval=-1 then
-   sys_time:=-1
-  else
-   sys_time:=tv.sec;
-end;
-
-{*****************************************************************************
-               --- File:File handling related calls ---
-*****************************************************************************}
-
-
-Function Sys_Open(f:pchar;flags:longint;mode:integer):longint;
-
-Begin
- sys_open:=do_syscall(syscall_nr_open,longint(f),flags,mode);
-End;
-
-Function Sys_Close(f:longint):longint;
-
-begin
- sys_close:=do_syscall(syscall_nr_close,f);
-end;
-
-{
-Function Sys_Lseek(F:longint;Off:longint;Whence:longint):longint;
-
-var returnvalue64 : array[0..1] of longint;
-
-begin
- {Lseek's offset is 64-bit, the highword  is the 0}
- do_syscall(syscall_nr_lseek,longint(@returnvalue64),F,Off,0,Whence);
- sys_lseek:=returnvalue64[0];
-end;
-
-}
-
-Function Sys_Lseek(F:longint;Off:longint;Whence:longint):longint; assembler;
-
-{this one is special for the return value being 64-bit..}
-
- asm
-  pushl Whence
-  pushl $0      // high dword
-  pushl Off
-  pushl $0
-  pushl F
-  pushl $0      // Your guess is as good as mine.
-  pushl $0xc7   // Actual lseek syscall number.
-  movl  $0xc6,%eax
-  call  actualsyscall
-  addl  $28,%esp
-  mov   %ebx,Errno
- end;
-
-Function Sys_Read(f:longint;buffer:pchar;count:longint):longint;
-
-begin
-  sys_read:=do_syscall(syscall_nr_read,F,longint(buffer),count);
-end;
-
-Function Sys_Write(f:longint;buffer:pchar;count:longint):longint;
-
-begin
- sys_write:=do_syscall(syscall_nr_write,F,longint(buffer),count);
-end;
-
-Function Sys_Unlink(Filename:pchar):longint;
-
-begin
-  sys_unlink:=do_syscall(syscall_nr_unlink,longint(Filename));
-end;
-
-Function Sys_Rename(Oldname,Newname:pchar):longint;
-
-begin
-  sys_rename:=do_syscall(syscall_nr_rename,longint(oldname),longint(newname));
-end;
-
-Function Sys_Stat(Filename:pchar;var Buffer: stat):longint;
-{
-   We need this for getcwd
-}
-
-begin
- sys_stat:=do_syscall(syscall_nr_stat,longint(filename),longint(@buffer));
-end;
-
-Function Sys_Symlink(oldname,newname:pchar):longint;
-{
-  We need this for erase
-}
-
-begin
- sys_symlink:=do_syscall(syscall_nr_symlink,longint(oldname),longint(newname));
-end;
-
-
-Function Sys_ReadLink(name,linkname:pchar;maxlen:longint):longint;
-
-begin
-  sys_readlink:=do_syscall(syscall_nr_readlink, longint(name),longint(linkname),maxlen);
-end;
-
-
-
-{*****************************************************************************
-               --- Directory:Directory related calls ---
-*****************************************************************************}
-
-Function Sys_Chdir(Filename:pchar):longint;
-
-begin
- sys_chdir:=do_syscall(syscall_nr_chdir,longint(filename));
-end;
-
-Function Sys_Mkdir(Filename:pchar;mode:longint):longint;
-
-begin {Mode is 16-bit on F-BSD}
-  sys_mkdir:=do_syscall(syscall_nr_mkdir,longint(filename),mode);
-end;
-
-Function Sys_Rmdir(Filename:pchar):longint;
-
-begin
- sys_rmdir:=do_syscall(syscall_nr_rmdir,longint(filename));
-end;
-
-{$ifndef NewReaddir}
-
-const DIRBLKSIZ=1024;
-
-
-{ we need this for getcwd, NOT touched for BSD version }
-Function OpenDir(f:pchar):pdir;
-
-var
-  fd:longint;
-  st:stat;
-  ptr:pdir;
-begin
-  opendir:=nil;
-  if sys_stat(f,st)<0 then
-   exit;
-{ Is it a dir ? }
-  if not((st.mode and $f000)=$4000)then
-   begin
-     errno:=Esysenotdir;
-     exit
-   end;
-{ Open it}
-  fd:=sys_open(f,OPEN_RDONLY,438);
-  if fd<0 then
-   exit;
-  new(ptr);
-  if ptr=nil then
-   exit;
-  Getmem(ptr^.buf,2*DIRBLKSIZ);
-  if ptr^.buf=nil then
-   exit;
-  ptr^.fd:=fd;
-  ptr^.loc:=-1;
-  ptr^.rewind:=longint(ptr^.buf);
-  ptr^.size:=0;
-//  ptr^.dd_max:=sizeof(ptr^.buf^);
-  opendir:=ptr;
-end;
-
-function CloseDir(p:pdir):integer;
-begin
-  closedir:=sys_close(p^.fd);
-  Freemem(p^.buf);
-  dispose(p);
-end;
-
-
-Function Sys_ReadDir(p:pdir):pdirent;
-{Different from Linux, Readdir on BSD is based on Getdents, due to the
-missing of the readdir syscall.
-Getdents requires the buffer to be larger than the blocksize.
-This usually the sectorsize =512 bytes, but maybe tapedrives and harddisks
-with blockmode have this higher?}
-
-function readbuffer:longint;
-
-var retval :longint;
-
-begin
-   retval:=do_syscall(syscall_nr_getdents,longint(p^.fd),longint(@p^.buf^),DIRBLKSIZ {sizeof(getdentsbuffer)});
-   p^.rewind:=longint(p^.buf);
-   if retval=0 then
-    begin
-     p^.rewind:=0;
-     p^.loc:=0;
-    end
-   else
-    P^.loc:=retval;
- readbuffer:=retval;
-end;
-
-var
-    FinalEntry     : pdirent;
-    novalid        : boolean;
-    Reclen         : Longint;
-    CurEntry       : PDirent;
+Function fpmmap(adr:pointer;len:TSize;prot:cint;flags:cint;fdes:cint;off:TOff):cint;  // moved from sysunix.inc, used in sbrk
 begin
 begin
- if (p^.buf=nil) or (p^.loc=0) THEN
-  exit(nil);
- if (p^.loc=-1)   OR     {First readdir on this pdir. Initial fill of buffer}
-   (p^.rewind>=(longint(p^.buf)+dirblksiz)) then  {no more entries left?}
-  Begin
-    if readbuffer=0 then        {succesful read?}
-     Exit(NIL);                 {No more data}
-  End;
- FinalEntry:=NIL;
- CurEntry:=nil;
- repeat
-  novalid:=false;
-  CurEntry:=pdirent(p^.rewind);
-  RecLen:=CurEntry^.reclen;
-  if RecLen<>0 Then
-   begin {valid direntry?}
-    if CurEntry^.ino<>0 then
-     FinalEntry:=CurEntry;
-    inc(p^.rewind,Reclen);
-   end
-  else
-   begin {block entirely searched or reclen=0}
-    Novalid:=True;
-    if p^.loc<>0 THEN             {blocks left?}
-     if readbuffer()<>0 then        {succesful read?}
-      novalid:=false;
-   end;
- until (FinalEntry<>nil) or novalid;
- If novalid then
-  FinalEntry:=nil;
- Sys_ReadDir:=FinalEntry;
-end;
-
-{$endif}
-
-
-{*****************************************************************************
-        --- Process:Process & program handling - related calls ---
-*****************************************************************************}
-
-
-Function sys_GetPid:LongInt;
-{
-  Get Process ID.
-}
-
-begin
- sys_GetPID:=do_syscall(syscall_nr_getpid);
-end;
-
-Procedure Sys_Exit(ExitCode:longint);
-
-begin
-  do_syscall(syscall_nr_exit,exitcode);
-end;
-
-{
-  Change action of process upon receipt of a signal.
-  Signum specifies the signal (all except SigKill and SigStop).
-  If Act is non-nil, it is used to specify the new action.
-  If OldAct is non-nil the previous action is saved there.
-}
-
-
-
-Procedure SigAction(Signum:longint;Act,OldAct:PSigActionRec );
-{
-  Change action of process upon receipt of a signal.
-  Signum specifies the signal (all except SigKill and SigStop).
-  If Act is non-nil, it is used to specify the new action.
-  If OldAct is non-nil the previous action is saved there.
-}
-
-begin
-  do_syscall(syscall_nr_sigaction,longint(signum),longint(act),longint(oldact));
- {$ifdef linuxunit}
-  LinuxError:=Errno;
+ {$ifdef LITTLE_ENDIAN}
+  fpmmap:=do_syscall(syscall_nr_mmap,Adr,Len,Prot,Flags,fdes,lo(off),0);
+ {$else}
+  fpmmap:=do_syscall(syscall_nr_mmap,TSysParam(Adr),TSysParam(Len),Prot,Flags,fdes,0,lo(off));
  {$endif}
  {$endif}
 end;
 end;
 
 
-(*=================== MOVED from syslinux.inc ========================*)
-{
-Function Sys_FTruncate(Handle,Pos:longint):longint;  //moved from sysunix.inc Do_Truncate
-begin
-  Sys_FTruncate:=do_syscall(syscall_nr_ftruncate,handle,pos,0);
-end;
-}
-
-Function Sys_ftruncate(handle,pos:longint):longint; assembler;
-
-{this one is special for the return value being 64-bit..}
-
- asm
-  pushl $0
-  pushl pos
-  pushl $0      // Your guess is as good as mine.
-  pushl handle
-  pushl $0
-  pushl $0xc9   // Actual lseek syscall number.
-  movl  $0xc6,%eax
-  call  actualsyscall
-  addl  $24,%esp
-  mov   %ebx,Errno
- end;
-
-
-Function Sys_fstat(fd : longint;var Info:stat):Longint; // This was missing here, instead an fstat call was included in Do_FileSize
-begin
-  Sys_FStat:=do_SysCall(syscall_nr_fstat,fd,longint(@info));
-end;
-
-{$ifdef NewReaddir}
-{$I readdir.inc}
-{$endif}
-
-
-{
-  Interface to Unix ioctl call.
-  Performs various operations on the filedescriptor Handle.
-  Ndx describes the operation to perform.
-  Data points to data needed for the Ndx function. The structure of this
-  data is function-dependent.
-}
-Function Sys_IOCtl(Handle,Ndx: Longint;Data: Pointer):LongInt;  // This was missing here, instead hardcoded in Do_IsDevice
-begin
-  Sys_IOCtl:=do_SysCall(syscall_nr_ioctl,handle,Ndx,longint(data));
-end;
-
-Function Sys_mmap(adr,len,prot,flags,fdes,off:longint):longint; // moved from sysunix.inc, used in sbrk
-begin
-  Sys_mmap:=do_syscall(syscall_nr_mmap,Adr,Len,Prot,Flags,fdes,off,0);
-end;
-
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.11  2003-06-01 16:35:28  marco
+  Revision 1.12  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.11  2003/06/01 16:35:28  marco
    * Several small fixes to harmonize the *BSD rtls and Linux.
    * Several small fixes to harmonize the *BSD rtls and Linux.
 
 
   Revision 1.10  2003/01/05 19:02:29  marco
   Revision 1.10  2003/01/05 19:02:29  marco

+ 4 - 120
rtl/freebsd/systypes.inc

@@ -14,94 +14,6 @@
  **********************************************************************}
  **********************************************************************}
 type
 type
 
 
-{
- Linux system calls take arguments as follows :
-
-   i386/m68k:
-
-   %eax/%d0 : System call number
-   %ebx/%d1 : first argument
-   %ecx/%d2 : second argument
-   %edx/%d3 : third argumens
-   %esi/%d3 : fourth argument
-   %edi/%d4 : fifth argument
-
-  That is why we define a special type, with only these arguments
-  To make it processor independent, we don't give any system dependent
-  names, but the rather abstract reg1,reg2 etc;
-
-  SysCallRegs=record
-    reg1,reg2,reg3,reg4,reg5,reg6 : longint;
-  end;
-  PSysCallRegs=^SysCallRegs;
-  TSysCallRegs=SysCallRegs;
-}
-{ The following are records for system calls BSD updated }
-  dirent = packed record
-    ino    : cardinal;          { This is not inode number, but "a number
-                                  unique for each file on a filesystem"}
-    reclen : word;
-    d_type,
-    namlen : byte;
-    name   : array [0..255] of char;
-  end;
-
-  pdirent =^dirent;
-  TDirEnt = dirent;
-
-    TDir= packed record {BSD libc record.}
-            fd    : longint;    { file descriptor associated with directory }
-            loc,                { offset in current buffer }
-            size  : cardinal;   { amount of data returned by getdirentries}
-            buf   : pdirent;    { data buffer, actually a pchar}
-            len   : longint;    { size of data buffer   }
-            seek,               { magic cookie returned by getdirentries}
-            rewind: cardinal;   { magic cookie for rewinding}
-            flags : longint;    { flags for readdir }
-            end;
-
-{ Linux kernel record
-    TDir = packed record
-            fd     : longint;
-            loc    : longint;
-            size   : integer;
-            buf    : pdirent;
-   {The following are used in libc, but NOT in the linux kernel sources ??}
-            nextoff: longint;
-            dd_max : integer; {size of buf. Irrelevant, as buf is of type dirent}
-            lock   : pointer;
-            dummy  : array[0..1023] of char;
-            end;}
-
-  PDir =^TDir;
- dev_t  = CARDINAL;
-{$packrecords C}
- Stat =record {BSD version}
-        dev        :  dev_t;            { inode's device }
-        ino        :  cardinal;         { inode's number }
-        mode,                           { inode protection mode }
-        nlink      :  word;             { number of hard links }
-        uid,                            { user ID of the file's owner }
-        gid,                            { group ID of the file's group }
-        dev_t      :  cardinal;         { device type }
-        atime,                          { time of last access }
-        atime_nsec,                     { nsec of last access }
-        mtime,                          { time of last data modification }
-        mtime_nsec,                     { nsec of last data modification }
-        ctime,                          { time of last file status change }
-        ctime_nsec : longint;           { nsec of last file status change }
-        size,                           { file size, in bytes }
-        blocks     : Int64;             { blocks allocated for file }
-        blksze,                         { optimal blocksize for I/O }
-        flags,                          { user defined flags for file }
-        filegen    : cardinal;          { file generation number }
-        lspare     : longint;
-        qspare     : array[0..1] of int64;
-       end;
-
-  PStat=^Stat;
-  TStat=Stat;
-
   TStatfs = packed record
   TStatfs = packed record
     spare2,            { place holder}
     spare2,            { place holder}
     bsize,             { fundamental block size}
     bsize,             { fundamental block size}
@@ -122,37 +34,6 @@ type
   end;
   end;
   PStatFS=^TStatFS;
   PStatFS=^TStatFS;
 
 
-  fdSet=array[0..7] of longint;{=256 bits}
-  pfdset=^fdset;
-  TFDSet=fdset;
-
-  timeval = packed record
-    sec,usec:longint;
-  end;
-  ptimeval=^timeval;
-  TTimeVal=timeval;
-
-  timespec = packed record
-    tv_sec,tv_nsec:{longint or int64 ?}longint;
-  end;
-
-  timezone = packed record
-    minuteswest,dsttime:longint;
-  end;
-  ptimezone =^timezone;
-  TTimeZone = timezone;
-
-  utsname = packed record
-    sysname,
-    nodename,
-    release,
-    version,
-    machine,
-    domainname : Array[0..64] of char;
-  end;
-  PUTSName=^UTSName;
-  TUTSName=UTSName;
-
   ITimerVal= Record
   ITimerVal= Record
               It_Interval,
               It_Interval,
               It_Value      : TimeVal;
               It_Value      : TimeVal;
@@ -160,7 +41,10 @@ type
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.9  2002-09-07 16:01:18  peter
+  Revision 1.10  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.9  2002/09/07 16:01:18  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
   Revision 1.8  2002/05/06 10:49:59  marco
   Revision 1.8  2002/05/06 10:49:59  marco

+ 6 - 587
rtl/freebsd/unixsysc.inc

@@ -13,21 +13,6 @@
 
 
 **********************************************************************}
 **********************************************************************}
 
 
-Function Fork:longint;
-{
-  This function issues the 'fork' System call. the program is duplicated in memory
-  and Execution continues in parent and child process.
-  In the parent process, fork returns the PID of the child. In the child process,
-  zero is returned.
-  A negative value indicates that an error has occurred, the error is returned in
-  LinuxError.
-}
-
-Begin
- fork:=Do_syscall(SysCall_nr_fork);
- LinuxError:=ErrNo;
-End;
-
 {
 {
 function clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint;
 function clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint;
 {NOT IMPLEMENTED YET UNDER BSD}
 {NOT IMPLEMENTED YET UNDER BSD}
@@ -77,198 +62,7 @@ END;
 end;
 end;
 }
 }
 
 
-Procedure Execve(path:pathstr;args:ppchar;ep:ppchar);
-{
-  Replaces the current program by the program specified in path,
-  arguments in args are passed to Execve.
-  environment specified in ep is passed on.
-}
-
-Begin
-  path:=path+#0;
-  do_syscall(syscall_nr_Execve,longint(@path[1]),longint(Args),longint(ep));
- LinuxError:=ErrNo;
-End;
-
-Function Umask(Mask:Integer):integer;
-{
-  Sets file creation mask to (Mask and 0777 (octal) ), and returns the
-  previous value.
-}
-begin
- UMask:=Do_syscall(syscall_nr_umask,mask);
- LinuxError:=0;
-end;
-
-Procedure Nice(N:integer);
-{
-  Set process priority. A positive N means a lower priority.
-  A negative N decreases priority.
-
-Doesn't exist in BSD. Linux emu uses setpriority in a construct as below:
-}
-
-begin
-  SetPriority(Prio_Process,0,N);
-end;
-
-Procedure Execve(path:pchar;args:ppchar;ep:ppchar);
-{
-  Replaces the current program by the program specified in path,
-  arguments in args are passed to Execve.
-  environment specified in ep is passed on.
-}
-
-{
-  Replaces the current program by the program specified in path,
-  arguments in args are passed to Execve.
-  environment specified in ep is passed on.
-}
-
-Begin
-  do_syscall(syscall_nr_Execve,longint(path),longint(Args),longint(ep));
- LinuxError:=ErrNo;
-End;
-
-Procedure ExitProcess(val:longint);
-
-begin
- do_syscall(Syscall_nr_exit,val);
- LinuxError:=ErrNo;
-end;
-
-Function WaitPid(Pid:longint;Status:pointer;Options:longint):Longint;
 {
 {
-  Waits until a child with PID Pid exits, or returns if it is exited already.
-  Any resources used by the child are freed.
-  The exit status is reported in the adress referred to by Status. It should
-  be a longint.
-}
-
-begin
- WaitPID:=do_syscall(syscall_nr_WaitPID,PID,longint(Status),options,0);
- LinuxError:=ErrNo;
-end;
-
-Function GetPriority(Which,Who:longint):longint;
-{
-  Get Priority of process, process group, or user.
-   Which : selects what kind of priority is used.
-           can be one of the following predefined Constants :
-              Prio_User.
-              Prio_PGrp.
-              Prio_Process.
-   Who : depending on which, this is , respectively :
-              Uid
-              Pid
-              Process Group id
-   Errors are reported in linuxerror _only_. (priority can be negative)
-}
-begin
-  errno:=0;
-  if (which<prio_process) or (which>prio_user) then
-   begin
-     { We can save an interrupt here }
-     getpriority:=0;
-     linuxerror:=ESysEinval;
-   end
-  else
-   begin
-     GetPriority:=do_syscall(syscall_nr_GetPriority,which,who);
-     LinuxError:=ErrNo;
-   end;
-end;
-
-Procedure SetPriority(Which,Who,What:longint);
-{
- Set Priority of process, process group, or user.
-   Which : selects what kind of priority is used.
-           can be one of the following predefined Constants :
-              Prio_User.
-              Prio_PGrp.
-              Prio_Process.
-   Who : depending on value of which, this is, respectively :
-              Uid
-              Pid
-              Process Group id
-   what : A number between -20 and 20. -20 is most favorable, 20 least.
-          0 is the default.
-}
-begin
-  errno:=0;
-  if ((which<prio_process) or (which>prio_user)) or ((what<-20) or (what>20)) then
-   linuxerror:=ESyseinval  { We can save an interrupt here }
-  else
-   begin
-     do_syscall(Syscall_nr_Setpriority,which,who,what);
-     LinuxError:=ErrNo;
-   end;
-end;
-
-
-Function GetPid:LongInt;
-{
-  Get Process ID.
-}
-
-begin
- GetPID:=do_syscall(Syscall_nr_GetPID);
- LinuxError:=errno;
-end;
-
-Function GetPPid:LongInt;
-{
-  Get Process ID of parent process.
-}
-
-
-begin
-  GetPPid:=do_syscall(Syscall_nr_GetPPid);
-  LinuxError:=errno;
-end;
-
-Function GetUid:Longint;
-{
-  Get User ID.
-}
-
-begin
-  GetUID:=do_syscall(Syscall_nr_GetUID);
-  LinuxError:=ErrNo;
-end;
-
-Function GetEUid:Longint;
-{
-  Get _effective_ User ID.
-}
-
-begin
-  GetEUID:=do_syscall(Syscall_nr_GetEUID);
-  LinuxError:=ErrNo;
-end;
-
-
-Function GetGid:Longint;
-{
-  Get Group ID.
-}
-
-begin
-  GetGID:=do_syscall(Syscall_nr_getgid);
-  LinuxError:=ErrNo;
-end;
-
-
-Function GetEGid:Longint;
-{
-  Get _effective_ Group ID.
-}
-
-begin
- GetEGID:=do_syscall(syscall_nr_getegid);
- LinuxError:=ErrNo;
-end;
-
 Procedure GetTimeOfDay(var tv:timeval);
 Procedure GetTimeOfDay(var tv:timeval);
 {
 {
   Get the number of seconds since 00:00, January 1 1970, GMT
   Get the number of seconds since 00:00, January 1 1970, GMT
@@ -281,24 +75,7 @@ begin
  do_syscall(syscall_nr_gettimeofday,longint(@tv),longint(@tz));
  do_syscall(syscall_nr_gettimeofday,longint(@tv),longint(@tz));
  LinuxError:=Errno;
  LinuxError:=Errno;
 end;
 end;
-
-Function GetTimeOfDay: longint;
-{
-  Get the number of seconds since 00:00, January 1 1970, GMT
-  the time NOT corrected any way
 }
 }
-begin
-  GetTimeOfDay:=Sys_time;
-  LinuxError:=Errno;
-end;
-
-Function fdTruncate(fd,size:longint):boolean;
-
-begin
- fdtruncate:=do_syscall(syscall_nr_ftruncate,fd,size,0)=0;
- LinuxError:=Errno;
-end;
-
 Function  fdFlush (fd : Longint) : Boolean;
 Function  fdFlush (fd : Longint) : Boolean;
 
 
 begin
 begin
@@ -306,46 +83,6 @@ begin
   LinuxError:=Errno;
   LinuxError:=Errno;
 end;
 end;
 
 
-{$ifndef newreaddir}
-function sys_fcntl(Fd:longint;Cmd:longint;Arg:Longint):longint;
-
-begin
- sys_fcntl:=do_syscall(syscall_nr_fcntl,fd,cmd,arg);
- LinuxError:=Errno;
-end;
-{$endif}
-
-Function Chmod(path:pathstr;Newmode:longint):Boolean;
-{
-  Changes the permissions of a file.
-}
-
-begin
-  path:=path+#0;
-  chmod:=do_syscall(syscall_nr_chmod,longint(@path[1]),newmode)=0;
-  LinuxError:=Errno;
-end;
-
-Function Chown(path:pathstr;NewUid,NewGid:longint):boolean;
-{
-  Change the owner and group of a file.
-  A user can only change the group to a group of which he is a member.
-  The super-user can change uid and gid of any file.
-}
-
-begin
-  path:=path+#0;
-  ChOwn:=do_syscall(syscall_nr_chown,longint(@path[1]),newuid,newgid)=0;
- LinuxError:=Errno;
-end;
-
-Function Utime(path:pathstr;utim:utimebuf):boolean;
-
-begin
-  UTime:=do_syscall(syscall_nr_utimes,longint(@path[1]),longint(@utim))=0;
-  LinuxError:=Errno;
-end;
-
 Function  Flock (fd,mode : longint) : boolean;
 Function  Flock (fd,mode : longint) : boolean;
 
 
 begin
 begin
@@ -353,28 +90,6 @@ begin
  LinuxError:=Errno;
  LinuxError:=Errno;
 end;
 end;
 
 
-Function Lstat(Filename: PathStr;var Info:stat):Boolean;
-{
-  Get all information on a link (the link itself), and return it in info.
-}
-
-begin
- FileName:=FileName+#0;
- LStat:=do_syscall(syscall_nr_lstat,longint(@filename[1]),longint(@info))=0;
- LinuxError:=Errno;
-end;
-
-Function Fstat(Fd:Longint;var Info:stat):Boolean;
-{
-  Get all information on a file descriptor, and return it in info.
-}
-
-begin
- FStat:=do_syscall(syscall_nr_fstat,fd,longint(@info))=0;
- LinuxError:=Errno;
-end;
-
-
 Function StatFS(Path:Pathstr;Var Info:Tstatfs):Boolean;
 Function StatFS(Path:Pathstr;Var Info:Tstatfs):Boolean;
 
 
 {
 {
@@ -401,88 +116,6 @@ begin
  LinuxError:=Errno;
  LinuxError:=Errno;
 end;
 end;
 
 
-Function Link(OldPath,NewPath:pathstr):boolean;
-{
-  Proceduces a hard link from new to old.
-  In effect, new will be the same file as old.
-}
-begin
-  oldpath:=oldpath+#0;
-  newpath:=newpath+#0;
-  Link:=Do_Syscall(syscall_nr_link,longint(@oldpath[1]),longint(@newpath[1]))=0;
- LinuxError:=Errno;
-end;
-
-{
-Function SymLink(OldPath,newPath:pathstr):boolean;
-{
-  Proceduces a soft link from new to old.
-}
-
-begin
-  oldpath:=oldpath+#0;
-  newpath:=newpath+#0;
-  SymLink:=Do_Syscall(syscall_nr_symlink,longint(@oldpath[1]),longint(@newpath[1]))=0;
-  LinuxError:=Errno;
-end;
-}
-
-Function Access(Path:Pathstr ;mode:longint):boolean;
-{
-  Test users access rights on the specified file.
-  Mode is a mask xosisting of one or more of R_OK, W_OK, X_OK, F_OK.
-  R,W,X stand for read,write and Execute access, simultaneously.
-  F_OK checks whether the test would be allowed on the file.
-  i.e. It checks the search permissions in all directory components
-  of the path.
-  The test is done with the real user-ID, instead of the effective.
-  If access is denied, or an error occurred, false is returned.
-  If access is granted, true is returned.
-  Errors other than no access,are reported in linuxerror.
-}
-
-begin
-  path:=path+#0;
- Access:=do_syscall(syscall_nr_access,mode,longint(@path[1]))=0;
- LinuxError:=Errno;
-end;
-
-Function  Dup(oldfile:longint;var newfile:longint):Boolean;
-{
-  Copies the filedescriptor oldfile to newfile
-}
-
-begin
- newfile:=Do_syscall(syscall_nr_dup,oldfile);
- LinuxError:=Errno;
- Dup:=(LinuxError=0);
-end;
-
-
-Function Dup2(oldfile,newfile:longint):Boolean;
-{
-  Copies the filedescriptor oldfile to newfile
-}
-
-begin
- do_syscall(syscall_nr_dup2,oldfile,newfile);
- LinuxError:=Errno;
- Dup2:=(LinuxError=0);
-end;
-
-
-Function Select(N:longint;readfds,writefds,exceptfds:PFDSet;TimeOut:PTimeVal):longint;
-{
-  Select checks whether the file descriptor sets in readfs/writefs/exceptfs
-  have changed.
-}
-
-begin
- Select:=do_syscall(syscall_nr_select,n,longint(readfds),longint(writefds),longint(exceptfds),longint(timeout));
- LinuxError:=Errno;
-end;
-
-
 Function AssignPipe(var pipe_in,pipe_out:longint):boolean;
 Function AssignPipe(var pipe_in,pipe_out:longint):boolean;
 {
 {
   Sets up a pair of file variables, which act as a pipe. The first one can
   Sets up a pair of file variables, which act as a pipe. The first one can
@@ -510,7 +143,7 @@ begin
   do_syscall(syscall_nr_close,Textrec(F).Handle);
   do_syscall(syscall_nr_close,Textrec(F).Handle);
 { closed our side, Now wait for the other - this appears to be needed ?? }
 { closed our side, Now wait for the other - this appears to be needed ?? }
   pl:=@(textrec(f).userdata[2]);
   pl:=@(textrec(f).userdata[2]);
-  waitpid(pl^,@res,0);
+  fpwaitpid(pl^,res,0);
   pclose:=res shr 8;
   pclose:=res shr 8;
 end;
 end;
 
 
@@ -523,106 +156,10 @@ begin
   do_syscall(syscall_nr_close,filerec(F).Handle);
   do_syscall(syscall_nr_close,filerec(F).Handle);
 { closed our side, Now wait for the other - this appears to be needed ?? }
 { closed our side, Now wait for the other - this appears to be needed ?? }
   pl:=@(filerec(f).userdata[2]);
   pl:=@(filerec(f).userdata[2]);
-  waitpid(pl^,@res,0);
+  fpwaitpid(pl^,res,0);
   pclose:=res shr 8;
   pclose:=res shr 8;
 end;
 end;
 
 
-
-Function mkFifo(pathname:string;mode:longint):boolean;
-
-begin
-  pathname:=pathname+#0;
-  mkfifo:=do_syscall(syscall_nr_mknod,longint(@pathname[1]),mode or STAT_IFIFO,0)=0;
-  LinuxError:=Errno;
-end;
-
-
-Function Kill(Pid:longint;Sig:longint):integer;
-{
-  Send signal 'sig' to a process, or a group of processes.
-  If Pid >  0 then the signal is sent to pid
-     pid=-1                         to all processes except process 1
-     pid < -1                         to process group -pid
-  Return value is zero, except for case three, where the return value
-  is the number of processes to which the signal was sent.
-}
-
-begin
- kill:=do_syscall(syscall_nr_kill,pid,sig);
- if kill<0 THEN
-  Kill:=0;
- LinuxError:=Errno;
-end;
-
-Procedure SigProcMask(How:longint;SSet,OldSSet:PSigSet);
-{
-  Change the list of currently blocked signals.
-  How determines which signals will be blocked :
-   SigBlock   : Add SSet to the current list of blocked signals
-   SigUnBlock : Remove the signals in SSet from the list of blocked signals.
-   SigSetMask : Set the list of blocked signals to SSet
-  if OldSSet is non-null, the old set will be saved there.
-}
-
-begin
-  do_syscall(syscall_nr_sigprocmask,longint(how),longint(sset),longint(oldsset));
- LinuxError:=Errno;
-end;
-
-Function SigPending:SigSet;
-{
-  Allows examination of pending signals. The signal mask of pending
-  signals is set in SSet
-}
-Var
-  dummy : Sigset;
-begin
-  do_syscall(syscall_nr_sigpending,longint(@dummy));
-  LinuxError:=Errno;
-  sigpending:=dummy;
-end;
-
-Procedure SigSuspend(Mask:Sigset);
-{
- Set the signal mask with Mask, and suspend the program until a signal
- is received.
-}
-
-begin
-  do_syscall(syscall_nr_sigsuspend,longint(@mask));
-  LinuxError:=Errno;
-end;
-
-Function NanoSleep(const req : timespec;var rem : timespec) : longint;
-begin
-  NanoSleep:=Do_SysCall(syscall_nr_nanosleep,longint(@req),longint(@rem));
-  LinuxError:=Errno;
-end;
-
-
-
-Function IOCtl(Handle,Ndx: Longint;Data: Pointer):boolean;
-{
-  Interface to Unix ioctl call.
-  Performs various operations on the filedescriptor Handle.
-  Ndx describes the operation to perform.
-  Data points to data needed for the Ndx function. The structure of this
-  data is function-dependent.
-}
-
-begin
-  IOCtl:=Do_Syscall(syscall_nr_ioctl,handle,ndx,longint(data))=0;
-  LinuxError:=Errno;
-end;
-
-function MMap(const m:tmmapargs):longint;
-
-begin
-  {Last argument (offset) is actually 64-bit under BSD. Therefore extra 0}
- MMap:=do_syscall(syscall_nr_mmap,m.address,m.size,m.prot,m.flags,m.fd,m.offset,0);
- LinuxError:=Errno;
-end;
-
 function MUnMap (P : Pointer; Size : Longint) : Boolean;
 function MUnMap (P : Pointer; Size : Longint) : Boolean;
 
 
 begin
 begin
@@ -630,28 +167,6 @@ begin
   LinuxError:=Errno;
   LinuxError:=Errno;
 end;
 end;
 
 
-function signal(signum:longint;Handler:signalhandler):signalhandler;
-
-var sa,osa : sigactionrec;
-
-begin
-     sa.sa_handler:=handler;
-     FillChar(sa.sa_mask,sizeof(sigset),#0);
-     sa.sa_flags := 0;
-{     if (sigintr and signum) =0 then
- {restart behaviour needs libc}
-      sa.sa_flags :=sa.sa_flags or SA_RESTART;
-}
-     sigaction(signum,@sa,@osa);
-     if ErrNo<>0 then
-      signal:=NIL
-     else
-      signal:=osa.sa_handler;
-     LinuxError:=Errno;
-
-end;
-
-
 function  Clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint; assembler;
 function  Clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint; assembler;
 asm
 asm
         pushl   %esi
         pushl   %esi
@@ -684,108 +199,12 @@ asm
         popl    %esi
         popl    %esi
 end;
 end;
 
 
-{$packrecords C}
-
-TYPE uint=CARDINAL;
-
-CONST
-        I386_GET_LDT    =0;
-        I386_SET_LDT    =1;
-                                { I386_IOPL }
-        I386_GET_IOPERM =3;
-        I386_SET_IOPERM =4;
-                                { xxxxx }
-        I386_VM86       =6;
-
-{
-type i386_ldt_args = record
-        int     start : longint;
-        union   descriptor *descs;
-        int     num;
-        end;
-}
-type
- i386_ioperm_args = record
-        start    : uint;
-        length   : uint;
-        enable   : longint;
-        end;
-
-
-    i386_vm86_args = record
-        sub_op   : longint;             { sub-operation to perform }
-        sub_args : pchar;               { args }
-        end;
-
-   sysarch_args     = record
-                        op    : longint;
-                        parms : pchar;
-                       end;
-
-{
-int i386_get_ldt __P((int, union descriptor *, int));
-int i386_set_ldt __P((int, union descriptor *, int));
-int i386_get_ioperm __P((unsigned int, unsigned int *, int *));
-int i386_set_ioperm __P((unsigned int, unsigned int, int));
-int i386_vm86 __P((int, void *));
-int i386_set_watch __P((int watchnum, unsigned int watchaddr, int size,
-                        int access, struct dbreg * d));
-int i386_clr_watch __P((int watchnum, struct dbreg * d));
-}
-
-Function IOPerm(From,Num:CARDINAL;Value:Longint):boolean;
-
-var sg : i386_ioperm_args;
-    sa : sysarch_args;
-
-begin
-  sg.start:=From;
-  sg.length:=Num;
-  sg.enable:=value;
-  sa.op:=i386_SET_IOPERM;
-  sa.parms:=@sg;
-  IOPerm:=do_syscall(syscall_nr_sysarch,longint(@sa))=0;
-  LinuxError:=ErrNo;
-end;
-
-Function SetITimer(Which : Longint;Const value : ItimerVal; VarOValue:ItimerVal):Longint;
-
-Begin
- SetItimer:=Do_Syscall(syscall_nr_setitimer,Which,Longint(@Value),longint(@value));
- LinuxError:=ErrNo;
-End;
-
-
-Function GetITimer(Which : Longint;Var value : ItimerVal):Longint;
-
-Begin
- GetItimer:=Do_Syscall(syscall_nr_getItimer,Which,Longint(@value));
- LinuxError:=ErrNo;
-End;
-
-
-Function Alarm(Sec: Longint):Longint;
-
-Var it,oitv : Itimerval;
-
-Begin
-//      register struct itimerval *itp = &it;
-
- it.it_interval.sec:=0;
- it.it_interval.usec:=0;
- it.it_value.sec:=sec;
- it.it_value.usec:=0;
- If SetITimer(ITIMER_REAL,it,oitv)<0 Then
-   Exit(-1);
-
- if oitv.it_value.usec<>0 Then
-   Inc(oitv.it_value.sec);
- Alarm:=oitv.it_value.sec;
-End;
-
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2003-01-05 19:02:29  marco
+  Revision 1.8  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.7  2003/01/05 19:02:29  marco
    * Should now work with baseunx. (gmake all works)
    * Should now work with baseunx. (gmake all works)
 
 
   Revision 1.6  2002/10/18 12:19:59  marco
   Revision 1.6  2002/10/18 12:19:59  marco

+ 6 - 3
rtl/inc/sockets.inc

@@ -35,8 +35,8 @@ end;
 Procedure IOSock(var F:text);
 Procedure IOSock(var F:text);
 begin
 begin
   case textrec(f).mode of
   case textrec(f).mode of
-   fmoutput : fdWrite(textrec(f).handle,textrec(f).bufptr^,textrec(f).bufpos);
-    fminput : textrec(f).BufEnd:=fdRead(textrec(f).handle,textrec(f).bufptr^,textrec(f).bufsize);
+   fmoutput : fpWrite(textrec(f).handle,textrec(f).bufptr^,textrec(f).bufpos);
+    fminput : textrec(f).BufEnd:=fpRead(textrec(f).handle,textrec(f).bufptr^,textrec(f).bufsize);
   end;
   end;
   textrec(f).bufpos:=0;
   textrec(f).bufpos:=0;
 end;
 end;
@@ -167,7 +167,10 @@ begin
 end;
 end;
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2002-09-07 15:07:46  peter
+  Revision 1.4  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.3  2002/09/07 15:07:46  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
 }
 }

+ 1 - 2
rtl/linux/Makefile

@@ -210,7 +210,7 @@ INC=$(RTL)/inc
 PROCINC=$(RTL)/$(CPU_TARGET)
 PROCINC=$(RTL)/$(CPU_TARGET)
 UNIXINC=$(RTL)/unix
 UNIXINC=$(RTL)/unix
 ifeq ($(CPU_TARGET),i386)
 ifeq ($(CPU_TARGET),i386)
-CPU_UNITS=ports cpu mmx graph
+CPU_UNITS= cpu mmx graph
 else
 else
 CPU_UNITS=
 CPU_UNITS=
 endif
 endif
@@ -1341,7 +1341,6 @@ baseunix$(PPUEXT) : errno.inc bunxtype.inc ptypes.inc ctypes.inc \
 	bunxfunc.inc $(CPU_TARGET)/syscallh.inc $(CPU_TARGET)/sysnr.inc \
 	bunxfunc.inc $(CPU_TARGET)/syscallh.inc $(CPU_TARGET)/sysnr.inc \
 	ostypes.inc ossysch.inc bunxmacr.inc $(UNIXINC)/gensigset.inc \
 	ostypes.inc ossysch.inc bunxmacr.inc $(UNIXINC)/gensigset.inc \
 	$(UNIXINC)/genfuncs.inc $(SYSTEMUNIT)$(PPUEXT)
 	$(UNIXINC)/genfuncs.inc $(SYSTEMUNIT)$(PPUEXT)
-ports$(PPUEXT) : ports.pp unix$(PPUEXT) objpas$(PPUEXT)
 dl$(PPUEXT) : $(UNIXINC)/dl.pp $(SYSTEMUNIT)$(PPUEXT)
 dl$(PPUEXT) : $(UNIXINC)/dl.pp $(SYSTEMUNIT)$(PPUEXT)
 dynlibs$(PPUEXT) : $(INC)/dynlibs.pp $(UNIXINC)/dynlibs.inc dl$(PPUEXT) objpas$(PPUEXT)
 dynlibs$(PPUEXT) : $(INC)/dynlibs.pp $(UNIXINC)/dynlibs.inc dl$(PPUEXT) objpas$(PPUEXT)
 dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) \
 dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) \

+ 11 - 1
rtl/linux/baseunix.pp

@@ -27,16 +27,26 @@ Interface
 {$i bunxtype.inc}	{ Types }
 {$i bunxtype.inc}	{ Types }
 {$i bunxh.inc}		{ Functions}
 {$i bunxh.inc}		{ Functions}
 
 
+function fpgeterrno:longint;
+procedure fpseterrno(err:longint);
+
+
 implementation
 implementation
 
 
 {$i bunxmain.inc}	{ implementation}
 {$i bunxmain.inc}	{ implementation}
 {$i bunxovl.inc}	{ redefs and overloads implementation}
 {$i bunxovl.inc}	{ redefs and overloads implementation}
 
 
+function fpgeterrno:longint; external name 'FPC_SYS_GETERRNO';
+procedure fpseterrno(err:longint); external name 'FPC_SYS_SETERRNO';
+
 end.
 end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2002-12-18 16:44:09  marco
+  Revision 1.2  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.1  2002/12/18 16:44:09  marco
    * more new RTL
    * more new RTL
 
 
   Revision 1.2  2002/11/14 12:17:28  marco
   Revision 1.2  2002/11/14 12:17:28  marco

+ 25 - 4
rtl/linux/bunxfunc.inc

@@ -20,11 +20,12 @@
 {$i sysnr.inc}		// syscall numbers.
 {$i sysnr.inc}		// syscall numbers.
 {$i ostypes.inc}
 {$i ostypes.inc}
 {$i ossysch.inc}	// external interface to syscalls in system unit.
 {$i ossysch.inc}	// external interface to syscalls in system unit.
+//{$i genfuncs.inc}
+
 {$i bunxmacr.inc}	// macro's.
 {$i bunxmacr.inc}	// macro's.
 
 
 {$I gensigset.inc}     // general sigset funcs implementation. 
 {$I gensigset.inc}     // general sigset funcs implementation. 
-
-
+{$I genfdset.inc}
 
 
 Function fpKill(Pid:pid_t;Sig:cint):cint;
 Function fpKill(Pid:pid_t;Sig:cint):cint;
 {
 {
@@ -409,13 +410,33 @@ end;
 function fpgetcwd(path : pchar; siz:size_t):pchar;
 function fpgetcwd(path : pchar; siz:size_t):pchar;
 
 
 begin
 begin
+  fpgetcwd:=pchar(Do_Syscall(Syscall_nr_getcwd,TSysParam(Path),TSysParam(siz)));
+end;
+
+Function fpSelect(N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint;
+{
+  Select checks whether the file descriptor sets in readfs/writefs/exceptfs
+  have changed.
+}
+
+Var 
+  SelectArray : Array[1..5] of longint;
 
 
-fpgetcwd:=pchar(Do_Syscall(Syscall_nr_getcwd,TSysParam(Path),TSysParam(siz)));
+begin
+  SelectArray[1]:=n;
+  SelectArray[2]:=longint(Readfds);
+  Selectarray[3]:=longint(Writefds);
+  selectarray[4]:=longint(exceptfds);
+  Selectarray[5]:=longint(TimeOut);
+  fpSelect:=do_syscall(syscall_nr_select,longint(@selectarray));
 end;
 end;
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.2  2003-01-05 19:16:45  marco
+ Revision 1.3  2003-09-14 20:15:01  marco
+  * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+ Revision 1.2  2003/01/05 19:16:45  marco
   * small fix
   * small fix
 
 
  Revision 1.1  2002/12/18 16:43:26  marco
  Revision 1.1  2002/12/18 16:43:26  marco

+ 21 - 11
rtl/linux/bunxtype.inc

@@ -20,14 +20,21 @@
 
 
 {$i ptypes.inc}
 {$i ptypes.inc}
 
 
+
 CONST
 CONST
-    SYS_NMLM 		     = 65;
+//  SYS_NMLM 		     = 65;
     UTSNAME_LENGTH 	     = SYS_NMLM;
     UTSNAME_LENGTH 	     = SYS_NMLM;
     UTSNAME_NODENAME_LENGTH  = UTSNAME_LENGTH;
     UTSNAME_NODENAME_LENGTH  = UTSNAME_LENGTH;
     {$ifdef usedomain}
     {$ifdef usedomain}
     UTSNAME_DOMAIN_LENGTH    = UTSNAME_LENGTH;
     UTSNAME_DOMAIN_LENGTH    = UTSNAME_LENGTH;
     {$endif}
     {$endif}
 
 
+   SIG_MAXSIG      = 128;	// highest signal version
+   FD_MAXFDSET	   = 1024;
+   wordsinsigset   = 4;		// words in sigset_t
+   ln2bitsinword   = 5;         { 32bit : ln(32)/ln(2)=5 } 
+   ln2bitmask	   = 2 shl ln2bitsinword - 1;
+
 TYPE
 TYPE
    Blksize_t  = cuint;
    Blksize_t  = cuint;
    Blkcnt_t   = cuint;
    Blkcnt_t   = cuint;
@@ -129,21 +136,18 @@ TYPE
   TDirent    = Dirent;
   TDirent    = Dirent;
   pDirent    = ^Dirent;
   pDirent    = ^Dirent;
 
 
-
-
-
 {$ifdef oldreaddir}
 {$ifdef oldreaddir}
 	   { Still old one. This is a userland struct}
 	   { Still old one. This is a userland struct}
 
 
    Dir       = packed record
    Dir       = packed record
-                fd     : integer;
-                loc    : longint;
-                size   : integer;
-                buf    : pdirent;
+                dd_fd     : integer;
+                dd_loc    : longint;
+                dd_size   : integer;
+                dd_buf    : pdirent;
                 {The following are used in libc, but NOT in the linux kernel sources ??}
                 {The following are used in libc, but NOT in the linux kernel sources ??}
-                nextoff: longint;
+                dd_nextoff: longint;
                 dd_max : integer; {size of buf. Irrelevant, as buf is of type dirent}
                 dd_max : integer; {size of buf. Irrelevant, as buf is of type dirent}
-                lock   : pointer;
+                dd_lock   : pointer;
                end;
                end;
 {$else}
 {$else}
 	// new libc one. NOTE that off_t must be real, so 64-bit ifdef
 	// new libc one. NOTE that off_t must be real, so 64-bit ifdef
@@ -192,6 +196,9 @@ TYPE
    TTms      = tms;
    TTms      = tms;
    PTms	     = ^tms;
    PTms	     = ^tms;
 
 
+ TFDSet    = ARRAY[0..(FD_MAXFDSET div 32)-1] of Cardinal;
+ pFDSet    = ^TFDSet;
+
 {***********************************************************************}
 {***********************************************************************}
 {                  POSIX CONSTANT ROUTINE DEFINITIONS                   }
 {                  POSIX CONSTANT ROUTINE DEFINITIONS                   }
 {***********************************************************************}
 {***********************************************************************}
@@ -246,7 +253,10 @@ CONST
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2003-05-15 22:50:50  jonas
+  Revision 1.3  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.2  2003/05/15 22:50:50  jonas
     * the stat type is processor-dependent
     * the stat type is processor-dependent
     * the dev_t tpye is processor dependent. Don't use it in the stat type
     * the dev_t tpye is processor dependent. Don't use it in the stat type
       however, as that one is also used at a time where dev_t is already
       however, as that one is also used at a time where dev_t is already

+ 18 - 19
rtl/linux/i386/syscall.inc

@@ -19,7 +19,7 @@
 
 
 {$ASMMODE ATT}
 {$ASMMODE ATT}
 
 
-function FpSysCall(sysnr:TSysParam):TSysResult; assembler;{$ifndef VER1_0}oldfpccall;{$endif}[public,alias:'FPC_SYSCALL0'];
+function FpSysCall(sysnr:TSysParam):TSysResult; assembler; {$ifndef VER1_0} oldfpccall; {$endif}[public,alias:'FPC_SYSCALL0'];
 
 
 asm
 asm
 { load the registers... }
 { load the registers... }
@@ -44,12 +44,12 @@ asm
   popl  %edx
   popl  %edx
   movl  %edx,(%eax)
   movl  %edx,(%eax)
 .LNoThread:
 .LNoThread:
-  movl  $-1,%eax
 {$endif}
 {$endif}
+  movl  $-1,%eax
 .LSyscOK:
 .LSyscOK:
 end;
 end;
 
 
-function FpSysCall(sysnr,param1 : TSysParam):TSysResult; assembler;{$ifndef VER1_0}oldfpccall;{$endif}[public,alias:'FPC_SYSCALL1'];
+function FpSysCall(sysnr,param1 : TSysParam):TSysResult; assembler; {$ifndef VER1_0} oldfpccall; {$endif}[public,alias:'FPC_SYSCALL1'];
 
 
 asm
 asm
 { load the registers... }
 { load the registers... }
@@ -75,12 +75,12 @@ asm
   popl  %edx
   popl  %edx
   movl  %edx,(%eax)
   movl  %edx,(%eax)
 .LNoThread:
 .LNoThread:
-  movl  $-1,%eax
 {$endif}
 {$endif}
+  movl  $-1,%eax
 .LSyscOK:
 .LSyscOK:
 end;
 end;
 
 
-function FpSysCall(sysnr,param1,param2 : TSysParam):TSysResult; assembler;{$ifndef VER1_0}oldfpccall;{$endif}[public,alias:'FPC_SYSCALL2'];
+function FpSysCall(sysnr,param1,param2 : TSysParam):TSysResult; assembler; {$ifndef VER1_0} oldfpccall; {$endif} [public,alias:'FPC_SYSCALL2'];
 
 
 asm
 asm
 { load the registers... }
 { load the registers... }
@@ -107,12 +107,12 @@ asm
   popl  %edx
   popl  %edx
   movl  %edx,(%eax)
   movl  %edx,(%eax)
 .LNoThread:
 .LNoThread:
-  movl  $-1,%eax
 {$endif}
 {$endif}
+  movl  $-1,%eax
 .LSyscOK:
 .LSyscOK:
 end;
 end;
 
 
-function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;{$ifndef VER1_0}oldfpccall;{$endif}[public,alias:'FPC_SYSCALL3'];
+function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler; {$ifndef VER1_0} oldfpccall; {$endif} [public,alias:'FPC_SYSCALL3'];
 
 
 asm
 asm
 { load the registers... }
 { load the registers... }
@@ -140,12 +140,12 @@ asm
   popl  %edx
   popl  %edx
   movl  %edx,(%eax)
   movl  %edx,(%eax)
 .LNoThread:
 .LNoThread:
-  movl  $-1,%eax
 {$endif}
 {$endif}
+  movl  $-1,%eax
 .LSyscOK:
 .LSyscOK:
 end;
 end;
 
 
-function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;{$ifndef VER1_0}oldfpccall;{$endif}[public,alias:'FPC_SYSCALL4'];
+function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler; {$ifndef VER1_0} oldfpccall; {$endif} [public,alias:'FPC_SYSCALL4'];
 
 
 asm
 asm
 { load the registers... }
 { load the registers... }
@@ -174,12 +174,12 @@ asm
   popl  %edx
   popl  %edx
   movl  %edx,(%eax)
   movl  %edx,(%eax)
 .LNoThread:
 .LNoThread:
-  movl  $-1,%eax
 {$endif}
 {$endif}
+  movl  $-1,%eax
 .LSyscOK:
 .LSyscOK:
 end;
 end;
 
 
-function FpSysCall(sysnr,param1,param2,param3,param4,param5 : TSysParam):TSysResult; assembler;{$ifndef VER1_0}oldfpccall;{$endif}[public,alias:'FPC_SYSCALL5'];
+function FpSysCall(sysnr,param1,param2,param3,param4,param5 : TSysParam):TSysResult; assembler; {$ifndef VER1_0} oldfpccall; {$endif}[public,alias:'FPC_SYSCALL5'];
 
 
 asm
 asm
 { load the registers... }
 { load the registers... }
@@ -209,14 +209,14 @@ asm
   popl  %edx
   popl  %edx
   movl  %edx,(%eax)
   movl  %edx,(%eax)
 .LNoThread:
 .LNoThread:
-  movl  $-1,%eax
 {$endif}
 {$endif}
+  movl  $-1,%eax
 .LSyscOK:
 .LSyscOK:
 end;
 end;
 
 
 {$ifdef notsupported}
 {$ifdef notsupported}
 { Only 5 params are pushed, so it'll not work as expected (PFV) }
 { Only 5 params are pushed, so it'll not work as expected (PFV) }
-function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6 : TSysParam):TSysResult; assembler;{$ifndef VER1_0}oldfpccall;{$endif}[public,alias:'FPC_SYSCALL6'];
+function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6 : TSysParam):TSysResult; assembler; {$ifndef VER1_0} oldfpccall; {$endif}[public,alias:'FPC_SYSCALL6'];
 
 
 asm
 asm
 { load the registers... }
 { load the registers... }
@@ -246,8 +246,8 @@ asm
   popl  %edx
   popl  %edx
   movl  %edx,(%eax)
   movl  %edx,(%eax)
 .LNoThread:
 .LNoThread:
-  movl  $-1,%eax
 {$endif}
 {$endif}
+  movl  $-1,%eax
 .LSyscOK:
 .LSyscOK:
 end;
 end;
 {$endif notsupported}
 {$endif notsupported}
@@ -261,7 +261,7 @@ end;
                      --- Main:The System Call Self ---
                      --- Main:The System Call Self ---
 *****************************************************************************}
 *****************************************************************************}
 
 
-Procedure FpSysCall( callnr:TSysParam;var regs : SysCallregs );assembler;{$ifndef VER1_0}oldfpccall;{$endif}
+Procedure FpSysCall( callnr:TSysParam;var regs : SysCallregs );assembler; {$ifndef VER1_0} oldfpccall; {$endif}
 {
 {
   This function puts the registers in place, does the call, and then
   This function puts the registers in place, does the call, and then
   copies back the registers as they are after the SysCall.
   copies back the registers as they are after the SysCall.
@@ -294,7 +294,7 @@ end;
 
 
 {$ASMMODE DEFAULT}
 {$ASMMODE DEFAULT}
 
 
-Function SysCall( callnr:longint;var regs : SysCallregs ):longint;
+Function SysCall( callnr:longint;var regs : SysCallregs ):longint; {$ifndef VER1_0} oldfpccall; {$endif}
 {
 {
   This function serves as an interface to do_SysCall.
   This function serves as an interface to do_SysCall.
   If the SysCall returned a negative number, it returns -1, and puts the
   If the SysCall returned a negative number, it returns -1, and puts the
@@ -341,9 +341,8 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.8  2003-09-14 11:34:13  peter
-    * moved int64 asm code to int64p.inc
-    * save ebx,esi
+  Revision 1.9  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
 
 
   Revision 1.7  2002/12/24 19:45:59  peter
   Revision 1.7  2002/12/24 19:45:59  peter
     * only set errno when syscall fails
     * only set errno when syscall fails

+ 9 - 10
rtl/linux/i386/syscallh.inc

@@ -34,21 +34,20 @@ Type
 
 
   TSysParam  = Longint;
   TSysParam  = Longint;
 
 
-function Do_SysCall(sysnr:TSysParam):TSysResult;{$ifndef VER1_0}oldfpccall;{$endif}external name 'FPC_SYSCALL0';
-function Do_SysCall(sysnr,param1:TSysParam):TSysResult;{$ifndef VER1_0}oldfpccall;{$endif}external name 'FPC_SYSCALL1';
-function Do_SysCall(sysnr,param1,param2:TSysParam):TSysResult; {$ifndef VER1_0}oldfpccall;{$endif}external name 'FPC_SYSCALL2';
-function Do_SysCall(sysnr,param1,param2,param3:TSysParam):TSysResult;{$ifndef VER1_0}oldfpccall;{$endif}external name 'FPC_SYSCALL3';
-function Do_SysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult;{$ifndef VER1_0}oldfpccall;{$endif}external name 'FPC_SYSCALL4';
-function Do_SysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult; {$ifndef VER1_0}oldfpccall;{$endif}external name 'FPC_SYSCALL5';
+function Do_SysCall(sysnr:TSysParam):TSysResult;  {$ifndef VER1_0} oldfpccall; {$endif} external name 'FPC_SYSCALL0';
+function Do_SysCall(sysnr,param1:TSysParam):TSysResult; {$ifndef VER1_0} oldfpccall; {$endif} external name 'FPC_SYSCALL1';
+function Do_SysCall(sysnr,param1,param2:TSysParam):TSysResult;  {$ifndef VER1_0} oldfpccall; {$endif} external name 'FPC_SYSCALL2';
+function Do_SysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; {$ifndef VER1_0} oldfpccall; {$endif} external name 'FPC_SYSCALL3';
+function Do_SysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; {$ifndef VER1_0} oldfpccall; {$endif} external name 'FPC_SYSCALL4';
+function Do_SysCall(sysnr,param1,param2,param3,param4,param5:TSysParam):TSysResult;  {$ifndef VER1_0} oldfpccall; {$endif} external name 'FPC_SYSCALL5';
 {$ifdef notsupported}
 {$ifdef notsupported}
-function Do_SysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult; {$ifndef VER1_0}oldfpccall;{$endif}external name 'FPC_SYSCALL6';
+function Do_SysCall(sysnr,param1,param2,param3,param4,param5,param6:TSysParam):TSysResult;  {$ifndef VER1_0} oldfpccall; {$endif} external name 'FPC_SYSCALL6';
 {$endif notsupported}
 {$endif notsupported}
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2003-09-14 11:34:13  peter
-    * moved int64 asm code to int64p.inc
-    * save ebx,esi
+  Revision 1.6  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
 
 
   Revision 1.4  2003/07/06 21:26:10  peter
   Revision 1.4  2003/07/06 21:26:10  peter
     * syscall6 alias fixed
     * syscall6 alias fixed

+ 22 - 12
rtl/linux/ossysc.inc

@@ -137,21 +137,21 @@ begin
   new(ptr);
   new(ptr);
   if ptr=nil then
   if ptr=nil then
    exit;
    exit;
-  getmem(ptr^.buf,sizeof(dirent));
-  if ptr^.buf=nil then
+  getmem(ptr^.dd_buf,sizeof(dirent));
+  if ptr^.dd_buf=nil then
    exit;
    exit;
-  ptr^.fd:=fd;
-  ptr^.loc:=0;
-  ptr^.size:=0;
-  ptr^.dd_max:=sizeof(ptr^.buf^);
+  ptr^.dd_fd:=fd;
+  ptr^.dd_loc:=0;
+  ptr^.dd_size:=0;
+  ptr^.dd_max:=sizeof(ptr^.dd_buf^);
   Fpopendir:=ptr;
   Fpopendir:=ptr;
 end;
 end;
 
 
 function Fpclosedir(dirp : pdir): cint; [public, alias : 'FPC_SYSC_CLOSEDIR'];
 function Fpclosedir(dirp : pdir): cint; [public, alias : 'FPC_SYSC_CLOSEDIR'];
 
 
 begin
 begin
-  Fpclosedir:=Fpclose(dirp^.fd);
-  freemem(dirp^.buf,sizeof(dirent));
+  Fpclosedir:=Fpclose(dirp^.dd_fd);
+  freemem(dirp^.dd_buf,sizeof(dirent));
   dispose(dirp);
   dispose(dirp);
 end;
 end;
 
 
@@ -164,11 +164,11 @@ This usually the sectorsize =512 bytes, but maybe tapedrives and harddisks
 with blockmode have this higher?}
 with blockmode have this higher?}
 
 
 begin
 begin
-  if do_SysCall(SysCall_nr_readdir,TSysParam(dirp^.fd),TSysParam(dirp^.buf),TSysParam(1))=0 Then
+  if do_SysCall(SysCall_nr_readdir,TSysParam(dirp^.dd_fd),TSysParam(dirp^.dd_buf),TSysParam(1))=0 Then
 { the readdir system call returns the number of bytes written }
 { the readdir system call returns the number of bytes written }
    Fpreaddir:=nil
    Fpreaddir:=nil
   else
   else
-   Fpreaddir:=dirp^.buf
+   Fpreaddir:=dirp^.dd_buf
 end;
 end;
 
 
 {*****************************************************************************
 {*****************************************************************************
@@ -443,11 +443,21 @@ end;
 // The following belongs here, but this should be researched more.
 // The following belongs here, but this should be researched more.
 // function Fpgetcwd(pt:pchar; _size:size_t):pchar;[public, alias :'FPC_SYSC_GETCWD'];
 // function Fpgetcwd(pt:pchar; _size:size_t):pchar;[public, alias :'FPC_SYSC_GETCWD'];
 
 
-{$endif}
+function gettimeofday(tp: ptimeval;tzp:ptimezone):cint; [public, alias:
+'FPC_SYSC_GETTIMEOFDAY'];
+
+begin
+ gettimeofday:=do_syscall(syscall_nr_gettimeofday,TSysParam(tp),TSysParam(tzp));
+end;
+
+{$ENDIF}
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.3  2003-05-11 16:07:55  jonas
+ Revision 1.4  2003-09-14 20:15:01  marco
+  * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+ Revision 1.3  2003/05/11 16:07:55  jonas
    * fixed mmap for non-i386 non-m68k architectures (not sure about
    * fixed mmap for non-i386 non-m68k architectures (not sure about
      x86-64)
      x86-64)
 
 

+ 6 - 2
rtl/linux/ossysch.inc

@@ -17,14 +17,18 @@
 
 
 Function Fpmmap(adr:pointer;len:size_t;prot:cint;flags:cint;fd:cint;off:off_t):pointer;  external name 'FPC_SYSC_MMAP';
 Function Fpmmap(adr:pointer;len:size_t;prot:cint;flags:cint;fd:cint;off:off_t):pointer;  external name 'FPC_SYSC_MMAP';
 Function Fpmunmap(adr:pointer;len:size_t):cint; external name 'FPC_SYSC_MUNMAP';
 Function Fpmunmap(adr:pointer;len:size_t):cint; external name 'FPC_SYSC_MUNMAP';
-Function FpIOCtl(fd:cint;request:culong;Data: Pointer):cint;  external name 'FPC_SYSC_IOCTL';
+Function FpIOCtl(handle:cint;ndx:culong;Data: Pointer):cint;  external name 'FPC_SYSC_IOCTL';
 Function FpGetPid:pid_t;   external name 'FPC_SYSC_GETPID';
 Function FpGetPid:pid_t;   external name 'FPC_SYSC_GETPID';
 Function FpReadLink(name,linkname:pchar;maxlen:size_t):cint;  external name 'FPC_SYSC_READLINK';
 Function FpReadLink(name,linkname:pchar;maxlen:size_t):cint;  external name 'FPC_SYSC_READLINK';
 Function FpNanoSleep(const req : timespec;rem : ptimespec) : longint; external name 'FPC_SYSC_NANOSLEEP';
 Function FpNanoSleep(const req : timespec;rem : ptimespec) : longint; external name 'FPC_SYSC_NANOSLEEP';
+function gettimeofday(tp: ptimeval;tzp:ptimezone):cint; external name 'FPC_SYSC_GETTIMEOFDAY';
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.1  2002-12-18 16:43:26  marco
+ Revision 1.2  2003-09-14 20:15:01  marco
+  * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+ Revision 1.1  2002/12/18 16:43:26  marco
   * new unix rtl, linux part.....
   * new unix rtl, linux part.....
 
 
 
 

+ 10 - 8
rtl/linux/ostypes.inc

@@ -44,19 +44,18 @@ Type
   PSysCallRegs= ^SysCallRegs;
   PSysCallRegs= ^SysCallRegs;
   TSysCallRegs= SysCallRegs;
   TSysCallRegs= SysCallRegs;
 
 
-
   ptimespec   = ^timespec;
   ptimespec   = ^timespec;
   timespec    = packed record
   timespec    = packed record
     		 tv_sec   : time_t;
     		 tv_sec   : time_t;
     		 tv_nsec  : clong;
     		 tv_nsec  : clong;
  		end;
  		end;
 
 
-  timeval     = packed record
-    		 tv_sec,
-		 tv_usec:clong;
-  		end;
-  ptimeval    = ^timeval;
-  TTimeVal    = timeval;
+
+  timezone = packed record
+    minuteswest,dsttime:longint;
+  end;
+  ptimezone =^timezone;
+  TTimeZone = timezone;
 
 
 CONST 
 CONST 
        _S_IFDIR = $4000;
        _S_IFDIR = $4000;
@@ -68,7 +67,10 @@ CONST
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.2  2002-12-18 16:43:26  marco
+ Revision 1.3  2003-09-14 20:15:01  marco
+  * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+ Revision 1.2  2002/12/18 16:43:26  marco
   * new unix rtl, linux part.....
   * new unix rtl, linux part.....
 
 
  Revision 1.1  2002/11/12 14:37:59  marco
  Revision 1.1  2002/11/12 14:37:59  marco

+ 7 - 4
rtl/linux/pthread.inc

@@ -45,13 +45,13 @@
      sched_param = record
      sched_param = record
         sched_priority : LongInt;
         sched_priority : LongInt;
      end;
      end;
-
+{
      ptimespec = ^timespec;
      ptimespec = ^timespec;
      timespec = record
      timespec = record
         tv_sec : LongInt;
         tv_sec : LongInt;
         tv_nsec : LongInt;
         tv_nsec : LongInt;
      end;
      end;
-
+}
      psigset_t = ^sigset_t;
      psigset_t = ^sigset_t;
      sigset_t = DWORD; // unsigned long 32 bits
      sigset_t = DWORD; // unsigned long 32 bits
 
 
@@ -91,7 +91,7 @@
       PTHREAD_SCOPE_PROCESS   = 1;
       PTHREAD_SCOPE_PROCESS   = 1;
 
 
     type
     type
-       size_t = longint;
+//       size_t = longint;
 
 
        ppthread_attr_t = ^pthread_attr_t;
        ppthread_attr_t = ^pthread_attr_t;
        pthread_attr_t = record
        pthread_attr_t = record
@@ -198,7 +198,10 @@
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2002-10-18 18:03:57  marco
+  Revision 1.2  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.1  2002/10/18 18:03:57  marco
    * From the original systhrds code.
    * From the original systhrds code.
      Turned out to be not entirely the same as *BSD's (constants with
      Turned out to be not entirely the same as *BSD's (constants with
      different names, existing and non existing constants), so I decided to
      different names, existing and non existing constants), so I decided to

+ 13 - 1
rtl/linux/ptypes.inc

@@ -106,6 +106,14 @@ Type
     TSockLen = socklen_t;
     TSockLen = socklen_t;
     pSockLen = ^socklen_t;
     pSockLen = ^socklen_t;
 
 
+  timeval     = packed record
+    		 tv_sec,
+		 tv_usec:clong;
+  		end;
+  ptimeval    = ^timeval;
+  TTimeVal    = timeval;
+
+
 CONST
 CONST
    { System limits, POSIX value in parentheses, used for buffer and stack allocation }
    { System limits, POSIX value in parentheses, used for buffer and stack allocation }
    { took idefix' values}
    { took idefix' values}
@@ -113,10 +121,14 @@ CONST
     ARG_MAX  = 131072;   {4096}  { Maximum number of argument size     }
     ARG_MAX  = 131072;   {4096}  { Maximum number of argument size     }
     NAME_MAX = 255;     {14}    { Maximum number of bytes in filename }
     NAME_MAX = 255;     {14}    { Maximum number of bytes in filename }
     PATH_MAX = 4095;    {255}   { Maximum number of bytes in pathname }
     PATH_MAX = 4095;    {255}   { Maximum number of bytes in pathname }
+    SYS_NMLM 		     = 65;
 
 
 {
 {
    $Log$
    $Log$
-   Revision 1.3  2002-12-18 16:43:26  marco
+   Revision 1.4  2003-09-14 20:15:01  marco
+    * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+   Revision 1.3  2002/12/18 16:43:26  marco
     * new unix rtl, linux part.....
     * new unix rtl, linux part.....
 
 
    Revision 1.2  2002/11/12 14:28:40  marco
    Revision 1.2  2002/11/12 14:28:40  marco

+ 5 - 8
rtl/linux/signal.inc

@@ -16,13 +16,6 @@
 {$packrecords C}
 {$packrecords C}
 
 
 
 
-Const 			// OS specific parameters for general sigset behaviour
-   SIG_MAXSIG      = 1024;	// highest signal version
-   wordsinsigset   = 32;	// words in sigset_t
-   ln2bitsinword   = 5;         { 32bit : ln(32)/ln(2)=5 }
-
-   ln2bitmask	   = 2 shl ln2bitsinword - 1;
-
 
 
 {********************
 {********************
       Signal
       Signal
@@ -216,6 +209,7 @@ type
   psigset_t=psigset;
   psigset_t=psigset;
   TSigSet = SigSet;
   TSigSet = SigSet;
 
 
+
   SigActionRec = packed record  // this is temporary for the migration
   SigActionRec = packed record  // this is temporary for the migration
    {$ifdef posixworkaround}
    {$ifdef posixworkaround}
     sa_handler : signalhandler;
     sa_handler : signalhandler;
@@ -235,7 +229,10 @@ type
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.11  2003-09-03 14:09:37  florian
+  Revision 1.12  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.11  2003/09/03 14:09:37  florian
     * arm fixes to the common rtl code
     * arm fixes to the common rtl code
     * some generic math code fixed
     * some generic math code fixed
     * ...
     * ...

+ 10 - 5
rtl/linux/syscallo.inc

@@ -23,7 +23,8 @@
                      --- Main:The System Call Self ---
                      --- Main:The System Call Self ---
 *****************************************************************************}
 *****************************************************************************}
 
 
-Procedure Do_SysCall( callnr:longint;var regs : SysCallregs );assembler;
+
+Procedure Do_SysCallspec( callnr:longint;var regs : SysCallregs );assembler;
 {
 {
   This function puts the registers in place, does the call, and then
   This function puts the registers in place, does the call, and then
   copies back the registers as they are after the SysCall.
   copies back the registers as they are after the SysCall.
@@ -141,6 +142,7 @@ var
   LastCall : longint;
   LastCall : longint;
   DebugTxt : string[20];
   DebugTxt : string[20];
 {$ENDIF}
 {$ENDIF}
+
 Function SysCall( callnr:longint;var regs : SysCallregs ):longint;
 Function SysCall( callnr:longint;var regs : SysCallregs ):longint;
 {
 {
   This function serves as an interface to do_SysCall.
   This function serves as an interface to do_SysCall.
@@ -148,14 +150,14 @@ Function SysCall( callnr:longint;var regs : SysCallregs ):longint;
   SysCall result in errno. Otherwise, it returns the SysCall return value
   SysCall result in errno. Otherwise, it returns the SysCall return value
 }
 }
 begin
 begin
-  do_SysCall(callnr,regs);
+  do_SysCallspec(callnr,regs);
   if regs.reg1<0 then
   if regs.reg1<0 then
    begin
    begin
 {$IFDEF SYSCALL_DEBUG}
 {$IFDEF SYSCALL_DEBUG}
      If DoSysCallDebug then
      If DoSysCallDebug then
        debugtxt:=' syscall error: ';
        debugtxt:=' syscall error: ';
 {$endif}
 {$endif}
-     ErrNo:=-regs.reg1;
+     fpseterrno(-regs.reg1);
      SysCall:=-1;
      SysCall:=-1;
    end
    end
   else
   else
@@ -165,7 +167,7 @@ begin
        debugtxt:=' syscall returned: ';
        debugtxt:=' syscall returned: ';
 {$endif}
 {$endif}
      SysCall:=regs.reg1;
      SysCall:=regs.reg1;
-     errno:=0
+     fpseterrno(0);
    end;
    end;
 {$IFDEF SYSCALL_DEBUG}
 {$IFDEF SYSCALL_DEBUG}
   if DoSysCallDebug then
   if DoSysCallDebug then
@@ -186,7 +188,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2003-08-21 22:24:52  olle
+  Revision 1.6  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.5  2003/08/21 22:24:52  olle
     - removed parameter from fpc_iocheck
     - removed parameter from fpc_iocheck
 
 
   Revision 1.4  2003/06/17 16:39:58  jonas
   Revision 1.4  2003/06/17 16:39:58  jonas

+ 4 - 287
rtl/linux/syscalls.inc

@@ -16,292 +16,6 @@
 { Include syscall itself }
 { Include syscall itself }
 {$i syscallo.inc}
 {$i syscallo.inc}
 
 
-{*****************************************************************************
-               --- Time:Time handling related calls ---
-*****************************************************************************}
-
-Function Sys_Time:longint;
-var
-  regs : SysCallregs;
-begin
-  regs.reg2:=0;
-  Sys_Time:=SysCall(SysCall_nr_time,regs);
-end;
-
-
-{*****************************************************************************
-               --- File:File handling related calls ---
-*****************************************************************************}
-
-
-Function Sys_Open(f:pchar;flags:longint;mode:integer):longint;
-var
-  regs : SysCallregs;
-Begin
-  regs.reg2:=longint(f);
-  regs.reg3:=flags;
-  regs.reg4:=mode;
-  Sys_Open:=SysCall(SysCall_nr_open,regs);
-End;
-
-
-
-Function Sys_Close(f:longint):longint;
-var
-  regs : SysCallregs;
-begin
-  regs.reg2:=f;
-  Sys_Close:=SysCall(SysCall_nr_close,regs);
-end;
-
-
-
-Function Sys_Lseek(F:longint;Off:longint;Whence:longint):longint;
-var
-  regs : SysCallregs;
-begin
-  regs.reg2:=f;
-  regs.reg3:=off;
-  regs.reg4:=Whence;
-  Sys_lseek:=SysCall(SysCall_nr_lseek,regs);
-end;
-
-
-
-Function Sys_Read(f:longint;buffer:pchar;count:longint):longint;
-var
-  regs : SysCallregs;
-begin
-  regs.reg2:=f;
-  regs.reg3:=longint(buffer);
-  regs.reg4:=count;
-  Sys_Read:=SysCall(SysCall_nr_read,regs);
-end;
-
-
-
-Function Sys_Write(f:longint;buffer:pchar;count:longint):longint;
-var
-  regs : SysCallregs;
-begin
-  regs.reg2:=f;
-  regs.reg3:=longint(buffer);
-  regs.reg4:=count;
-  Sys_Write:=SysCall(SysCall_nr_write,regs);
-end;
-
-
-
-Function Sys_Unlink(Filename:pchar):longint;
-var
-  regs : SysCallregs;
-begin
-  regs.reg2:=longint(filename);
-  Sys_Unlink:=SysCall(SysCall_nr_unlink,regs);
-end;
-
-
-Function Sys_fstat(fd : longint;var Info:stat):Longint;
-var
-  regs : SysCallregs;
-begin
-  regs.reg2:=fd;
-  regs.reg3:=longint(@Info);
-  Sys_fStat:=SysCall(SysCall_nr_fstat,regs);
-end;
-
-
-Function Sys_Rename(Oldname,Newname:pchar):longint;
-var
-  regs : SysCallregs;
-begin
-  regs.reg2:=longint(oldname);
-  regs.reg3:=longint(newname);
-  Sys_Rename:=SysCall(SysCall_nr_rename,regs);
-end;
-
-
-
-Function Sys_Stat(Filename:pchar;var Buffer: stat):longint;
-{
-   We need this for getcwd
-}
-var
-  regs : SysCallregs;
-begin
-  regs.reg2:=longint(filename);
-  regs.reg3:=longint(@buffer);
-  Sys_Stat:=SysCall(SysCall_nr_stat,regs);
-end;
-
-
-Function Sys_Symlink(oldname,newname:pchar):longint;
-{
-  We need this for erase
-}
-var
-  regs : SysCallregs;
-begin
-  regs.reg2:=longint(oldname);
-  regs.reg3:=longint(newname);
-  Sys_symlink:=SysCall(SysCall_nr_symlink,regs);
-end;
-
-
-Function Sys_ReadLink(name,linkname:pchar;maxlen:longint):longint;
-var
-  regs : SysCallRegs;
-begin
-  regs.reg2:=longint(name);
-  regs.reg3:=longint(linkname);
-  regs.reg4:=maxlen;
-  Sys_ReadLink:=SysCall(Syscall_nr_readlink,regs);
-end;
-
-
-{*****************************************************************************
-               --- Directory:Directory related calls ---
-*****************************************************************************}
-
-
-Function Sys_Chdir(Filename:pchar):longint;
-var
-  regs : SysCallregs;
-
-begin
-  regs.reg2:=longint(filename);
-  Sys_ChDir:=SysCall(SysCall_nr_chdir,regs);
-end;
-
-
-
-Function Sys_Mkdir(Filename:pchar;mode:longint):longint;
-var
-  regs : SysCallregs;
-begin
-  regs.reg2:=longint(filename);
-  regs.reg3:=mode;
-  Sys_MkDir:=SysCall(SysCall_nr_mkdir,regs);
-end;
-
-
-
-Function Sys_Rmdir(Filename:pchar):longint;
-var
-  regs : SysCallregs;
-begin
-  regs.reg2:=longint(filename);
-  Sys_Rmdir:=SysCall(SysCall_nr_rmdir,regs);
-end;
-
-
-
-{ we need this for getcwd }
-Function OpenDir(f:pchar):pdir;
-var
-  fd:integer;
-  st:stat;
-  ptr:pdir;
-begin
-  opendir:=nil;
-  if sys_stat(f,st)<0 then
-   exit;
-{ Is it a dir ? }
-  if not((st.mode and $f000)=$4000)then
-   begin
-     errno:=ESysENOTDIR;
-     exit
-   end;
-{ Open it}
-  fd:=sys_open(f,OPEN_RDONLY,438);
-  if fd<0 then
-   exit;
-  new(ptr);
-  if ptr=nil then
-   exit;
-  new(ptr^.buf);
-  if ptr^.buf=nil then
-   exit;
-  ptr^.fd:=fd;
-  ptr^.loc:=0;
-  ptr^.size:=0;
-  ptr^.dd_max:=sizeof(ptr^.buf^);
-  opendir:=ptr;
-end;
-
-
-
-function CloseDir(p:pdir):integer;
-begin
-  closedir:=sys_close(p^.fd);
-  dispose(p^.buf);
-  dispose(p);
-end;
-
-
-
-Function Sys_ReadDir(p:pdir):pdirent;
-var
-  regs :SysCallregs;
-  dummy:longint;
-begin
-  regs.reg3:=longint(p^.buf);
-  regs.reg2:=p^.fd;
-  regs.reg4:=1;
-  dummy:=SysCall(SysCall_nr_readdir,regs);
-{ the readdir system call returns the number of bytes written }
-  if dummy=0 then
-   sys_readdir:=nil
-  else
-   sys_readdir:=p^.buf
-end;
-
-
-{*****************************************************************************
-        --- Process:Process & program handling - related calls ---
-*****************************************************************************}
-
-Function Sys_GetPid:LongInt;
-var
-  regs : SysCallregs;
-begin
-  Sys_GetPid:=SysCall(SysCall_nr_getpid,regs);
-end;
-
-
-Procedure Sys_Exit(ExitCode:Integer);
-var
-  regs : SysCallregs;
-begin
-  regs.reg2:=exitcode;
-  SysCall(SysCall_nr_exit,regs)
-end;
-
-Procedure SigAction(Signum:longint;Act,OldAct:PSigActionRec );
-{
-  Change action of process upon receipt of a signal.
-  Signum specifies the signal (all except SigKill and SigStop).
-  If Act is non-nil, it is used to specify the new action.
-  If OldAct is non-nil the previous action is saved there.
-}
-Var
-  sr : Syscallregs;
-begin
-  sr.reg2:=Signum;
-  sr.reg3:=Longint(act);
-  sr.reg4:=Longint(oldact);
-  SysCall(Syscall_nr_sigaction,sr);
-end;
-
-function Sys_FTruncate(Handle,Pos:longint):longint;  //moved from sysunix.inc Do_Truncate
-var
-  sr : syscallregs;
-begin
-  sr.reg2:=Handle;
-  sr.reg3:=Pos;
-  Sys_FTruncate:=syscall(syscall_nr_ftruncate,sr);
-end;
-
 Function Sys_mmap(adr,len,prot,flags,fdes,off:longint):longint; // moved from sysunix.inc, used in sbrk
 Function Sys_mmap(adr,len,prot,flags,fdes,off:longint):longint; // moved from sysunix.inc, used in sbrk
 type
 type
   tmmapargs=packed record
   tmmapargs=packed record
@@ -435,7 +149,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.17  2002-12-18 16:43:26  marco
+  Revision 1.18  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.17  2002/12/18 16:43:26  marco
    * new unix rtl, linux part.....
    * new unix rtl, linux part.....
 
 
   Revision 1.16  2002/11/11 21:40:26  marco
   Revision 1.16  2002/11/11 21:40:26  marco

+ 5 - 1
rtl/linux/system.pp

@@ -18,6 +18,7 @@
 { These things are set in the makefile, }
 { These things are set in the makefile, }
 { But you can override them here.}
 { But you can override them here.}
 
 
+
 { If you use an aout system, set the conditional AOUT}
 { If you use an aout system, set the conditional AOUT}
 { $Define AOUT}
 { $Define AOUT}
 
 
@@ -135,7 +136,10 @@ End.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2003-04-30 22:11:06  florian
+  Revision 1.8  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.7  2003/04/30 22:11:06  florian
     + for a lot of x86-64 dependend files mostly dummies added
     + for a lot of x86-64 dependend files mostly dummies added
 
 
   Revision 1.6  2002/12/27 18:36:16  peter
   Revision 1.6  2002/12/27 18:36:16  peter

+ 18 - 7
rtl/linux/systypes.inc

@@ -28,13 +28,14 @@ type
   That is why we define a special type, with only these arguments
   That is why we define a special type, with only these arguments
   To make it processor independent, we don't give any system dependent
   To make it processor independent, we don't give any system dependent
   names, but the rather abstract reg1,reg2 etc;
   names, but the rather abstract reg1,reg2 etc;
-}
+
   SysCallRegs=record
   SysCallRegs=record
     reg1,reg2,reg3,reg4,reg5,reg6 : longint;
     reg1,reg2,reg3,reg4,reg5,reg6 : longint;
   end;
   end;
   PSysCallRegs=^SysCallRegs;
   PSysCallRegs=^SysCallRegs;
   TSysCallRegs=SysCallRegs;
   TSysCallRegs=SysCallRegs;
-
+}
+{
 { The following are records for system calls }
 { The following are records for system calls }
   dirent = packed record
   dirent = packed record
     ino,
     ino,
@@ -57,9 +58,11 @@ type
   end;
   end;
   PDir =^TDir;
   PDir =^TDir;
 
 
+}
 { can't put definition in stat.inc because stat.inc is also included in }
 { can't put definition in stat.inc because stat.inc is also included in }
 { bunxtype.inc, which is used together with ptypes.inc, which defines   }
 { bunxtype.inc, which is used together with ptypes.inc, which defines   }
 { def_t in another way :(                                               }
 { def_t in another way :(                                               }
+{
 {$ifdef cpui386}
 {$ifdef cpui386}
   dev_t = word;
   dev_t = word;
 {$else cpui386}
 {$else cpui386}
@@ -77,12 +80,12 @@ type
 {$endif cpupowerpc}
 {$endif cpupowerpc}
 {$endif cpum68k}
 {$endif cpum68k}
 {$endif cpui386}
 {$endif cpui386}
-
+}{
 { definition of stat record type }
 { definition of stat record type }
-{$i stat.inc}
+{i stat.inc}
   PStat=^Stat;
   PStat=^Stat;
   TStat=Stat;
   TStat=Stat;
-
+}
   TStatfs = packed record
   TStatfs = packed record
     fstype,            { File system type }
     fstype,            { File system type }
     bsize,             { Optimal block trensfer size }
     bsize,             { Optimal block trensfer size }
@@ -97,6 +100,8 @@ type
   end;
   end;
   PStatFS=^TStatFS;
   PStatFS=^TStatFS;
 
 
+{
+
   fdSet=array[0..31] of longint;{=1024 bits}
   fdSet=array[0..31] of longint;{=1024 bits}
   pfdset=^fdset;
   pfdset=^fdset;
   TFDSet=fdset;
   TFDSet=fdset;
@@ -107,16 +112,19 @@ type
   ptimeval=^timeval;
   ptimeval=^timeval;
   TTimeVal=timeval;
   TTimeVal=timeval;
 
 
+
   timespec = packed record
   timespec = packed record
     tv_sec,tv_nsec:longint;
     tv_sec,tv_nsec:longint;
   end;
   end;
 
 
+
   timezone = packed record
   timezone = packed record
     minuteswest,dsttime:longint;
     minuteswest,dsttime:longint;
   end;
   end;
   ptimezone =^timezone;
   ptimezone =^timezone;
   TTimeZone = timezone;
   TTimeZone = timezone;
 
 
+
   utsname = packed record
   utsname = packed record
     sysname,
     sysname,
     nodename,
     nodename,
@@ -127,10 +135,13 @@ type
   end;
   end;
   PUTSName=^UTSName;
   PUTSName=^UTSName;
   TUTSName=UTSName;
   TUTSName=UTSName;
-
+}
 {
 {
   $Log$
   $Log$
-  Revision 1.11  2003-08-21 22:24:52  olle
+  Revision 1.12  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.11  2003/08/21 22:24:52  olle
     - removed parameter from fpc_iocheck
     - removed parameter from fpc_iocheck
 
 
   Revision 1.10  2003/07/08 21:23:24  peter
   Revision 1.10  2003/07/08 21:23:24  peter

+ 8 - 7
rtl/linux/unixsock.inc

@@ -40,7 +40,7 @@ Const
 
 
 Function SocketCall(SockCallNr,a1,a2,a3,a4,a5,a6:longint):longint;
 Function SocketCall(SockCallNr,a1,a2,a3,a4,a5,a6:longint):longint;
 var
 var
-  Regs:SysCallRegs;
+//  Regs:SysCallRegs;
   Args:array[1..6] of longint;
   Args:array[1..6] of longint;
 begin
 begin
 {$IFNDEF BSD}
 {$IFNDEF BSD}
@@ -50,11 +50,9 @@ begin
   args[4]:=a4;
   args[4]:=a4;
   args[5]:=a5;
   args[5]:=a5;
   args[6]:=a6;
   args[6]:=a6;
-  regs.reg2:=SockCallNr;
-  regs.reg3:=Longint(@args);
-  SocketCall:=Syscall(syscall_nr_socketcall,regs);
+  SocketCall:=do_Syscall(syscall_nr_socketcall,sockcallnr,longint(@args));
   If SocketCall<0 then
   If SocketCall<0 then
-   SocketError:=Errno
+   SocketError:=fpgetErrno
   else
   else
    SocketError:=0;
    SocketError:=0;
  {$ELSE}
  {$ELSE}
@@ -80,7 +78,7 @@ end;
 
 
 Function CloseSocket (Sock:Longint):Longint;
 Function CloseSocket (Sock:Longint):Longint;
 begin
 begin
-  if fdClose (Sock) then
+  if fpClose(Sock)=0 then
     CloseSocket := 0 else
     CloseSocket := 0 else
     CloseSocket := -1;
     CloseSocket := -1;
 end;
 end;
@@ -274,7 +272,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2003-03-23 17:47:15  armin
+  Revision 1.8  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.7  2003/03/23 17:47:15  armin
   * CloseSocket added
   * CloseSocket added
 
 
   Revision 1.6  2002/09/07 16:01:20  peter
   Revision 1.6  2002/09/07 16:01:20  peter

+ 53 - 78
rtl/linux/unixsysc.inc

@@ -25,7 +25,7 @@ var
   regs:SysCallregs;
   regs:SysCallregs;
 begin
 begin
   Fork:=SysCall(SysCall_nr_fork,regs);
   Fork:=SysCall(SysCall_nr_fork,regs);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 End;
 End;
 
 
 
 
@@ -44,7 +44,7 @@ begin
   regs.reg4:=longint(ep);
   regs.reg4:=longint(ep);
   SysCall(SysCall_nr_Execve,regs);
   SysCall(SysCall_nr_Execve,regs);
 { This only gets set when the call fails, otherwise we don't get here ! }
 { This only gets set when the call fails, otherwise we don't get here ! }
-  Linuxerror:=errno;
+  Linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -62,7 +62,7 @@ begin
   regs.reg4:=longint(ep);
   regs.reg4:=longint(ep);
   SysCall(SysCall_nr_Execve,regs);
   SysCall(SysCall_nr_Execve,regs);
 { This only gets set when the call fails, otherwise we don't get here ! }
 { This only gets set when the call fails, otherwise we don't get here ! }
-  Linuxerror:=errno;
+  Linuxerror:=fpgeterrno;
 end;
 end;
 
 
 Procedure ExitProcess(val:longint);
 Procedure ExitProcess(val:longint);
@@ -88,7 +88,7 @@ begin
   regs.reg3:=longint(status);
   regs.reg3:=longint(status);
   regs.reg4:=options;
   regs.reg4:=options;
   WaitPid:=SysCall(SysCall_nr_waitpid,regs);
   WaitPid:=SysCall(SysCall_nr_waitpid,regs);
-  LinuxError:=errno;
+  LinuxError:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -103,7 +103,7 @@ begin
   regs.reg2:=longint(@tv);
   regs.reg2:=longint(@tv);
   regs.reg3:=0;
   regs.reg3:=0;
   SysCall(SysCall_nr_gettimeofday,regs);
   SysCall(SysCall_nr_gettimeofday,regs);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 end;
 
 
 Function GetPriority(Which,Who:Integer):integer;
 Function GetPriority(Which,Who:Integer):integer;
@@ -123,7 +123,7 @@ Function GetPriority(Which,Who:Integer):integer;
 var
 var
   sr : Syscallregs;
   sr : Syscallregs;
 begin
 begin
-  errno:=0;
+  fpseterrno(0);
   if (which<prio_process) or (which>prio_user) then
   if (which<prio_process) or (which>prio_user) then
    begin
    begin
      { We can save an interrupt here }
      { We can save an interrupt here }
@@ -135,7 +135,7 @@ begin
      sr.reg2:=which;
      sr.reg2:=which;
      sr.reg3:=who;
      sr.reg3:=who;
      getpriority:=SysCall(Syscall_nr_getpriority,sr);
      getpriority:=SysCall(Syscall_nr_getpriority,sr);
-     linuxerror:=errno;
+     linuxerror:=fpgeterrno;
    end;
    end;
 end;
 end;
 
 
@@ -159,7 +159,7 @@ Procedure SetPriority(Which:Integer;Who:Integer;What:Integer);
 var
 var
   sr : Syscallregs;
   sr : Syscallregs;
 begin
 begin
-  errno:=0;
+  fpseterrno(0);
   if ((which<prio_process) or (which>prio_user)) or ((what<-20) or (what>20)) then
   if ((which<prio_process) or (which>prio_user)) or ((what<-20) or (what>20)) then
    linuxerror:=ESyseinval  { We can save an interrupt here }
    linuxerror:=ESyseinval  { We can save an interrupt here }
   else
   else
@@ -168,7 +168,7 @@ begin
      sr.reg3:=who;
      sr.reg3:=who;
      sr.reg4:=what;
      sr.reg4:=what;
      SysCall(Syscall_nr_setpriority,sr);
      SysCall(Syscall_nr_setpriority,sr);
-     linuxerror:=errno;
+     linuxerror:=fpgeterrno;
    end;
    end;
 end;
 end;
 
 
@@ -183,7 +183,7 @@ var
 begin
 begin
   sr.reg2:=n;
   sr.reg2:=n;
   SysCall(Syscall_nr_nice,sr);
   SysCall(Syscall_nr_nice,sr);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -196,7 +196,7 @@ var
   regs : SysCallregs;
   regs : SysCallregs;
 begin
 begin
   GetPid:=SysCall(SysCall_nr_getpid,regs);
   GetPid:=SysCall(SysCall_nr_getpid,regs);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -209,7 +209,7 @@ var
   regs : SysCallregs;
   regs : SysCallregs;
 begin
 begin
   GetPpid:=SysCall(SysCall_nr_getppid,regs);
   GetPpid:=SysCall(SysCall_nr_getppid,regs);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -222,7 +222,7 @@ var
   regs : SysCallregs;
   regs : SysCallregs;
 begin
 begin
   GetUid:=SysCall(SysCall_nr_getuid,regs);
   GetUid:=SysCall(SysCall_nr_getuid,regs);
-  Linuxerror:=errno;
+  Linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -235,7 +235,7 @@ var
   regs : SysCallregs;
   regs : SysCallregs;
 begin
 begin
   GetEuid:=SysCall(SysCall_nr_geteuid,regs);
   GetEuid:=SysCall(SysCall_nr_geteuid,regs);
-  Linuxerror:=errno;
+  Linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -248,7 +248,7 @@ var
   regs : SysCallregs;
   regs : SysCallregs;
 begin
 begin
   Getgid:=SysCall(SysCall_nr_getgid,regs);
   Getgid:=SysCall(SysCall_nr_getgid,regs);
-  Linuxerror:=errno;
+  Linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -261,7 +261,7 @@ var
   regs : SysCallregs;
   regs : SysCallregs;
 begin
 begin
   GetEgid:=SysCall(SysCall_nr_getegid,regs);
   GetEgid:=SysCall(SysCall_nr_getegid,regs);
-  Linuxerror:=errno;
+  Linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -277,8 +277,8 @@ begin
   regs.reg2:=longint(@tv);
   regs.reg2:=longint(@tv);
   regs.reg3:=0;
   regs.reg3:=0;
   SysCall(SysCall_nr_gettimeofday,regs);
   SysCall(SysCall_nr_gettimeofday,regs);
-  LinuxError:=Errno;
-  GetTimeOfDay:=tv.sec;
+  LinuxError:=fpgetErrno;
+  GetTimeOfDay:=tv.tv_sec;
 end;
 end;
 
 
 
 
@@ -289,7 +289,7 @@ begin
   Regs.reg2:=fd;
   Regs.reg2:=fd;
   Regs.reg3:=size;
   Regs.reg3:=size;
   fdTruncate:=(SysCall(Syscall_nr_ftruncate,regs)=0);
   fdTruncate:=(SysCall(Syscall_nr_ftruncate,regs)=0);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 end;
 
 
 
 
@@ -300,7 +300,7 @@ var
 begin
 begin
   SR.reg2 := fd;
   SR.reg2 := fd;
   fdFlush := (SysCall(syscall_nr_fsync, SR)=0);
   fdFlush := (SysCall(syscall_nr_fsync, SR)=0);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 end;
 
 
 
 
@@ -323,7 +323,7 @@ begin
      Linuxerror:=SysCall(Syscall_nr_fcntl,sr);
      Linuxerror:=SysCall(Syscall_nr_fcntl,sr);
      if linuxerror=-1 then
      if linuxerror=-1 then
       begin
       begin
-        linuxerror:=errno;
+        linuxerror:=fpgeterrno;
         fcntl:=0;
         fcntl:=0;
       end
       end
      else
      else
@@ -359,7 +359,7 @@ begin
      sr.reg3:=cmd;
      sr.reg3:=cmd;
      sr.reg4:=arg;
      sr.reg4:=arg;
      SysCall(Syscall_nr_fcntl,sr);
      SysCall(Syscall_nr_fcntl,sr);
-     linuxerror:=errno;
+     linuxerror:=fpgeterrno;
    end
    end
   else
   else
    linuxerror:=ESyseinval;
    linuxerror:=ESyseinval;
@@ -377,7 +377,7 @@ begin
   sr.reg2:=longint(@(path[1]));
   sr.reg2:=longint(@(path[1]));
   sr.reg3:=newmode;
   sr.reg3:=newmode;
   Chmod:=(SysCall(Syscall_nr_chmod,sr)=0);
   Chmod:=(SysCall(Syscall_nr_chmod,sr)=0);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -396,12 +396,10 @@ begin
   sr.reg3:=newuid;
   sr.reg3:=newuid;
   sr.reg4:=newgid;
   sr.reg4:=newgid;
   ChOwn:=(Syscall(Syscall_nr_chown,sr)=0);
   ChOwn:=(Syscall(Syscall_nr_chown,sr)=0);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
-
-
-Function Utime(path:pathstr;utim:utimebuf):boolean;
+Function Utime(path:pathstr;utim:utimbuf):boolean;
 var
 var
   sr : Syscallregs;
   sr : Syscallregs;
 begin
 begin
@@ -409,11 +407,9 @@ begin
   sr.reg2:=longint(@(path[1]));
   sr.reg2:=longint(@(path[1]));
   sr.reg3:=longint(@utim);
   sr.reg3:=longint(@utim);
   Utime:=SysCall(Syscall_nr_utime,sr)=0;
   Utime:=SysCall(Syscall_nr_utime,sr)=0;
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
-
-
 Function  Flock (fd,mode : longint) : boolean;
 Function  Flock (fd,mode : longint) : boolean;
 var
 var
   sr : Syscallregs;
   sr : Syscallregs;
@@ -421,11 +417,9 @@ begin
   sr.reg2:=fd;
   sr.reg2:=fd;
   sr.reg3:=mode;
   sr.reg3:=mode;
   flock:=Syscall(Syscall_nr_flock,sr)=0;
   flock:=Syscall(Syscall_nr_flock,sr)=0;
-  LinuxError:=errno;
+  LinuxError:=fpgeterrno;
 end;
 end;
 
 
-
-
 Function Fstat(Fd:Longint;var Info:stat):Boolean;
 Function Fstat(Fd:Longint;var Info:stat):Boolean;
 {
 {
   Get all information on a file descriptor, and return it in info.
   Get all information on a file descriptor, and return it in info.
@@ -436,7 +430,7 @@ begin
   regs.reg2:=Fd;
   regs.reg2:=Fd;
   regs.reg3:=longint(@Info);
   regs.reg3:=longint(@Info);
   FStat:=(SysCall(SysCall_nr_fstat,regs)=0);
   FStat:=(SysCall(SysCall_nr_fstat,regs)=0);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 end;
 
 
 
 
@@ -451,7 +445,7 @@ begin
   regs.reg2:=longint(@filename[1]);
   regs.reg2:=longint(@filename[1]);
   regs.reg3:=longint(@Info);
   regs.reg3:=longint(@Info);
   LStat:=(SysCall(SysCall_nr_lstat,regs)=0);
   LStat:=(SysCall(SysCall_nr_lstat,regs)=0);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 end;
 
 
 
 
@@ -469,7 +463,7 @@ begin
   regs.reg2:=longint(@path[1]);
   regs.reg2:=longint(@path[1]);
   regs.reg3:=longint(@Info);
   regs.reg3:=longint(@Info);
   StatFS:=(SysCall(SysCall_nr_statfs,regs)=0);
   StatFS:=(SysCall(SysCall_nr_statfs,regs)=0);
-  LinuxError:=errno;
+  LinuxError:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -486,7 +480,7 @@ begin
   regs.reg2:=Fd;
   regs.reg2:=Fd;
   regs.reg3:=longint(@Info);
   regs.reg3:=longint(@Info);
   StatFS:=(SysCall(SysCall_nr_fstatfs,regs)=0);
   StatFS:=(SysCall(SysCall_nr_fstatfs,regs)=0);
-  LinuxError:=errno;
+  LinuxError:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -504,7 +498,7 @@ begin
   regs.reg2:=longint(@oldpath[1]);
   regs.reg2:=longint(@oldpath[1]);
   regs.reg3:=longint(@newpath[1]);
   regs.reg3:=longint(@newpath[1]);
   Link:=SysCall(SysCall_nr_link,regs)=0;
   Link:=SysCall(SysCall_nr_link,regs)=0;
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -545,7 +539,7 @@ begin
   sr.reg2:=longint(@(path[1]));
   sr.reg2:=longint(@(path[1]));
   sr.reg3:=mode;
   sr.reg3:=mode;
   access:=(SysCall(Syscall_nr_access,sr)=0);
   access:=(SysCall(Syscall_nr_access,sr)=0);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -558,7 +552,7 @@ var
 begin
 begin
   sr.reg2:=oldfile;
   sr.reg2:=oldfile;
   newfile:=Syscall(Syscall_nr_dup,sr);
   newfile:=Syscall(Syscall_nr_dup,sr);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
   Dup:=(LinuxError=0);
   Dup:=(LinuxError=0);
 end;
 end;
 
 
@@ -573,32 +567,10 @@ begin
   sr.reg2:=oldfile;
   sr.reg2:=oldfile;
   sr.reg3:=newfile;
   sr.reg3:=newfile;
   SysCall(Syscall_nr_dup2,sr);
   SysCall(Syscall_nr_dup2,sr);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
   Dup2:=(LinuxError=0);
   Dup2:=(LinuxError=0);
 end;
 end;
 
 
-
-Function Select(N:longint;readfds,writefds,exceptfds:PFDSet;TimeOut:PTimeVal):longint;
-{
-  Select checks whether the file descriptor sets in readfs/writefs/exceptfs
-  have changed.
-}
-Var
-  SelectArray : Array[1..5] of longint;
-  Sr : Syscallregs;
-begin
-  SelectArray[1]:=n;
-  SelectArray[2]:=longint(Readfds);
-  Selectarray[3]:=longint(Writefds);
-  selectarray[4]:=longint(exceptfds);
-  Selectarray[5]:=longint(TimeOut);
-  sr.reg2:=longint(@selectarray);
-  Select:=SysCall(Syscall_nr_select,sr);
-  LinuxError:=Errno;
-end;
-
-
-
 Function AssignPipe(var pipe_in,pipe_out:longint):boolean;
 Function AssignPipe(var pipe_in,pipe_out:longint):boolean;
 {
 {
   Sets up a pair of file variables, which act as a pipe. The first one can
   Sets up a pair of file variables, which act as a pipe. The first one can
@@ -613,7 +585,7 @@ begin
   SysCall(SysCall_nr_pipe,regs);
   SysCall(SysCall_nr_pipe,regs);
   pipe_in:=pip[1];
   pipe_in:=pip[1];
   pipe_out:=pip[2];
   pipe_out:=pip[2];
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
   AssignPipe:=(LinuxError=0);
   AssignPipe:=(LinuxError=0);
 end;
 end;
 
 
@@ -684,7 +656,7 @@ var
 Begin
 Begin
   regs.reg2:=longint(@unamerec);
   regs.reg2:=longint(@unamerec);
   Uname:=SysCall(SysCall_nr_uname,regs)=0;
   Uname:=SysCall(SysCall_nr_uname,regs)=0;
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 End;
 End;
 
 
 
 
@@ -705,7 +677,7 @@ begin
   kill:=SysCall(Syscall_nr_kill,regs);
   kill:=SysCall(Syscall_nr_kill,regs);
   if kill<0 then
   if kill<0 then
    Kill:=0;
    Kill:=0;
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -725,7 +697,7 @@ begin
   sr.reg3:=longint(SSet);
   sr.reg3:=longint(SSet);
   sr.reg4:=longint(OldSSet);
   sr.reg4:=longint(OldSSet);
   SysCall(Syscall_nr_sigprocmask,sr);
   SysCall(Syscall_nr_sigprocmask,sr);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -741,7 +713,7 @@ Var
 begin
 begin
   sr.reg2:=longint(@dummy);
   sr.reg2:=longint(@dummy);
   SysCall(Syscall_nr_sigpending,sr);
   SysCall(Syscall_nr_sigpending,sr);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
   Sigpending:=dummy;
   Sigpending:=dummy;
 end;
 end;
 
 
@@ -757,7 +729,7 @@ Var
 begin
 begin
   sr.reg2:=mask[0];
   sr.reg2:=mask[0];
   SysCall(Syscall_nr_sigsuspend,sr);
   SysCall(Syscall_nr_sigsuspend,sr);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -777,7 +749,7 @@ begin
   If linuxerror=Sig_Err then
   If linuxerror=Sig_Err then
    begin
    begin
      Signal:=nil;
      Signal:=nil;
-     Linuxerror:=errno;
+     Linuxerror:=fpgeterrno;
    end
    end
   else
   else
    begin
    begin
@@ -802,7 +774,7 @@ Var Sr : Syscallregs;
 begin
 begin
   syscall(syscall_nr_pause,sr);
   syscall(syscall_nr_pause,sr);
 end;
 end;
-
+{
 Function NanoSleep(const req : timespec;var rem : timespec) : longint;
 Function NanoSleep(const req : timespec;var rem : timespec) : longint;
 
 
 var Sr : Syscallregs;
 var Sr : Syscallregs;
@@ -813,7 +785,7 @@ begin
   NanoSleep:=Syscall(syscall_nr_nanosleep,sr);
   NanoSleep:=Syscall(syscall_nr_nanosleep,sr);
   LinuxError:=Errno;
   LinuxError:=Errno;
 end;
 end;
-
+}
 Function IOCtl(Handle,Ndx: Longint;Data: Pointer):boolean;
 Function IOCtl(Handle,Ndx: Longint;Data: Pointer):boolean;
 {
 {
   Interface to Unix ioctl call.
   Interface to Unix ioctl call.
@@ -829,7 +801,7 @@ begin
   sr.reg3:=Ndx;
   sr.reg3:=Ndx;
   sr.reg4:=Longint(Data);
   sr.reg4:=Longint(Data);
   IOCtl:=(SysCall(Syscall_nr_ioctl,sr)=0);
   IOCtl:=(SysCall(Syscall_nr_ioctl,sr)=0);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 end;
 
 
 
 
@@ -839,7 +811,7 @@ Var
 begin
 begin
   Sr.reg2:=longint(@m);
   Sr.reg2:=longint(@m);
   MMap:=syscall(syscall_nr_mmap,sr);
   MMap:=syscall(syscall_nr_mmap,sr);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 end;
 
 
 function MUnMap (P : Pointer; Size : Longint) : Boolean;
 function MUnMap (P : Pointer; Size : Longint) : Boolean;
@@ -849,7 +821,7 @@ begin
   Sr.reg2:=longint(P);
   Sr.reg2:=longint(P);
   sr.reg3:=Size;
   sr.reg3:=Size;
   MUnMap:=syscall(syscall_nr_munmap,sr)=0;
   MUnMap:=syscall(syscall_nr_munmap,sr)=0;
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 end;
 
 
 {--------------------------------
 {--------------------------------
@@ -871,7 +843,7 @@ begin
   Sr.Reg3:=Num;
   Sr.Reg3:=Num;
   Sr.Reg4:=Value;
   Sr.Reg4:=Value;
   IOPerm:=Syscall(Syscall_nr_ioperm,sr)=0;
   IOPerm:=Syscall(Syscall_nr_ioperm,sr)=0;
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 end;
 
 
 Function IoPL(Level : longint) : Boolean;
 Function IoPL(Level : longint) : Boolean;
@@ -881,14 +853,17 @@ Var
 begin
 begin
   Sr.Reg2:=Level;
   Sr.Reg2:=Level;
   IOPL:=Syscall(Syscall_nr_iopl,sr)=0;
   IOPL:=Syscall(Syscall_nr_iopl,sr)=0;
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 end;
 
 
 {$endif i386}
 {$endif i386}
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.9  2003-07-08 21:23:24  peter
+  Revision 1.10  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.9  2003/07/08 21:23:24  peter
     * sparc fixes
     * sparc fixes
 
 
   Revision 1.8  2002/12/18 16:43:26  marco
   Revision 1.8  2002/12/18 16:43:26  marco

+ 14 - 1
rtl/unix/bunxh.inc

@@ -19,11 +19,18 @@ Type TGrpArr = Array [0..0] of TGid;		{ C style array workarounds}
      TFilDes = Array [0..1] of cInt;
      TFilDes = Array [0..1] of cInt;
      pFilDes = ^TFilDes;
      pFilDes = ^TFilDes;
 
 
+    Function  fpfdaddset   (var nset : TFDSet;fdno:cint): cint;
+    Function  fpfddelset   (var nset : TFDSet;fdno:cint): cint;
+    Function  fpfdemptyset (var nset : TFDSet):cint;
+    Function  fpfdfillset  (var nset : TFDSet):cint;
+    Function  fpfdismember (const nset : TFDSet;fdno:cint): cint;
+
     Function  FpsigEmptySet(var nset : TSigSet): cint;
     Function  FpsigEmptySet(var nset : TSigSet): cint;
     Function  FpSigFillSet (var nset : TSigSet): cInt;
     Function  FpSigFillSet (var nset : TSigSet): cInt;
     Function  FpSigAddSet  (var nset : TSigSet; signo : cInt): cInt;
     Function  FpSigAddSet  (var nset : TSigSet; signo : cInt): cInt;
     Function  FpSigDelSet  (var nset : TSigSet; signo : cInt): cInt;
     Function  FpSigDelSet  (var nset : TSigSet; signo : cInt): cInt;
     Function  FpSigIsMember(Const nset : TSigSet; signo : cInt): cInt;
     Function  FpSigIsMember(Const nset : TSigSet; signo : cInt): cInt;
+
     Function  FpSigProcMask(how : cInt; nset : pSigSet; oset : pSigSet): cInt; 
     Function  FpSigProcMask(how : cInt; nset : pSigSet; oset : pSigSet): cInt; 
     Function  FpSigProcMask(how : cInt; Const nset : TSigSet; var oset : TSigSet): cInt; 
     Function  FpSigProcMask(how : cInt; Const nset : TSigSet; var oset : TSigSet): cInt; 
     Function  FpSigPending (var nset : TSigSet): cInt;
     Function  FpSigPending (var nset : TSigSet): cInt;
@@ -87,6 +94,9 @@ Type TGrpArr = Array [0..0] of TGid;		{ C style array workarounds}
     Function  FpTime	   (var tloc : TTime): TTime;
     Function  FpTime	   (var tloc : TTime): TTime;
     Function  FpFtruncate  (fd : cInt; flength : TOff): cInt;
     Function  FpFtruncate  (fd : cInt; flength : TOff): cInt;
     Function  FPSigaction  (sig: cInt; act : pSigActionRec; oact : pSigActionRec): cint; 
     Function  FPSigaction  (sig: cInt; act : pSigActionRec; oact : pSigActionRec): cint; 
+    Function  FPSelect 	   (N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint;
+    Function  FpIOCtl      (Handle:cint;Ndx: culong;Data: Pointer):cint;  
+
 
 
     Function  FpGetEnv	   (name : pChar): pChar;
     Function  FpGetEnv	   (name : pChar): pChar;
     Function  FpGetEnv	   (name : String): pChar;
     Function  FpGetEnv	   (name : String): pChar;
@@ -107,7 +117,10 @@ Type TGrpArr = Array [0..0] of TGid;		{ C style array workarounds}
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2003-06-01 16:28:41  marco
+  Revision 1.4  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.3  2003/06/01 16:28:41  marco
    * Enhancements to make the compiler baseunix using.
    * Enhancements to make the compiler baseunix using.
 
 
   Revision 1.2  2003/01/05 19:11:32  marco
   Revision 1.2  2003/01/05 19:11:32  marco

+ 177 - 5
rtl/unix/bunxovl.inc

@@ -57,10 +57,6 @@ Begin
   FpExecv:=FpExecv (pchar(path),argv);
   FpExecv:=FpExecv (pchar(path),argv);
 End;
 End;
 
 
-Function  FpOpendir (dirname : AnsiString): pDir;
-Begin
-  FpOpenDir:=FpOpenDir(dirname);
-End;
 
 
 Function  FpChdir (path : AnsiString): cInt;
 Function  FpChdir (path : AnsiString): cInt;
 Begin
 Begin
@@ -137,11 +133,187 @@ begin
        fpsignal:=osa.sa_handler;
        fpsignal:=osa.sa_handler;
 end;
 end;
 
 
+function xFpread(fd: cint; buf: pchar; nbytes : size_t): ssize_t; external name 'FPC_SYSC_READ';
+
+
+Function  FpRead	   (fd : cInt;var buf; nbytes : TSize): TSsize;
+
+begin
+  FPRead:=xFpRead(fd,pchar(@buf),nbytes);
+end;
+
+Function  FpWrite	   (fd : cInt;const buf; nbytes : TSize): TSsize;
+begin
+ FpWrite:=FpWrite(fd,pchar(@buf),nbytes);
+end;
+
+Function  FpOpen    (path : pChar; flags : cInt):cInt;
+
+begin
+ FpOpen:=FpOpen(path,flags,438);
+end;
+
+Function  FpOpen    (path : AnsiString; flags : cInt):cInt;
+
+begin
+ FpOpen:=FpOpen(pchar(path),flags,438);
+end;
+
+Function  FpOpen    (path : String; flags : cInt):cInt;
+
+begin
+ path:=path+#0;
+ FpOpen:=FpOpen(@path[1],flags,438);
+end;
+
+Function  FpOpen    (path : String; flags : cInt; Mode: TMode):cInt;
+
+begin
+ path:=path+#0;
+ FpOpen:=FpOpen(@path[1],flags,Mode);
+end;
+
+Function  FpOpendir (dirname : AnsiString): pDir;
+Begin
+  FpOpenDir:=FpOpenDir(dirname);
+End;
+
+Function  FpStat (path: String; var buf : stat): cInt;
+
+begin
+ path:=path+#0;
+ FpStat:=FpStat(pchar(@path[1]),buf); 
+end;
+
+Function fpDup(var oldfile,newfile:text):cint;
+{
+  Copies the filedescriptor oldfile to newfile, after flushing the buffer of
+  oldfile.
+  After which the two textfiles are, in effect, the same, except
+  that they don't share the same buffer, and don't share the same
+  close_on_exit flag.
+}
+begin
+  flush(oldfile);{ We cannot share buffers, so we flush them. }
+  textrec(newfile):=textrec(oldfile);
+  textrec(newfile).bufptr:=@(textrec(newfile).buffer);{ No shared buffer. }
+  textrec(newfile).handle:=fpDup(textrec(oldfile).handle);
+  fpdup:=textrec(newfile).handle;
+end;
+
+Function fpDup(var oldfile,newfile:file):cint;
+{
+  Copies the filedescriptor oldfile to newfile
+}
+begin
+  filerec(newfile):=filerec(oldfile);
+  filerec(newfile).handle:=fpDup(filerec(oldfile).handle);
+  fpdup:=  filerec(newfile).handle;
+end;
+
+
+Function FpDup2(var oldfile,newfile:text):cint;
+{
+  Copies the filedescriptor oldfile to newfile, after flushing the buffer of
+  oldfile. It closes newfile if it was still open.
+  After which the two textfiles are, in effect, the same, except
+  that they don't share the same buffer, and don't share the same
+  close_on_exit flag.
+}
+var
+  tmphandle : word;
+begin
+  case TextRec(oldfile).mode of
+    fmOutput, fmInOut, fmAppend :
+      flush(oldfile);{ We cannot share buffers, so we flush them. }
+  end;
+  case TextRec(newfile).mode of
+    fmOutput, fmInOut, fmAppend :
+      flush(newfile);
+  end;
+  tmphandle:=textrec(newfile).handle;
+  textrec(newfile):=textrec(oldfile);
+  textrec(newfile).handle:=tmphandle;
+  textrec(newfile).bufptr:=@(textrec(newfile).buffer);{ No shared buffer. }
+  fpDup2:=fpDup2(textrec(oldfile).handle,textrec(newfile).handle);
+end;
+
+Function FpDup2(var oldfile,newfile:file):cint;
+{
+  Copies the filedescriptor oldfile to newfile
+}
+begin
+  filerec(newfile):=filerec(oldfile);
+  fpDup2:=fpDup2(filerec(oldfile).handle,filerec(newfile).handle);
+end;
+
+function  fptime    :time_t;
+var t:time_t;
+begin
+  fptime:=fptime(t);
+end;
+
+Function fpSelect(N:cint;readfds,writefds,exceptfds:pfdset;TimeOut:cint):cint;
+{
+  Select checks whether the file descriptor sets in readfs/writefs/exceptfs
+  have changed.
+  This function allows specification of a timeout as a longint.
+}
+var
+  p  : PTimeVal;
+  tv : TimeVal;
+begin
+  if TimeOut=-1 then
+   p:=nil
+  else
+   begin
+     tv.tv_Sec:=Timeout div 1000;
+     tv.tv_Usec:=(Timeout mod 1000)*1000;
+     p:=@tv;
+   end;
+  fpSelect:=fpSelect(N,Readfds,WriteFds,ExceptFds,p);
+end;
+
+Function fpSelect(var T:Text;TimeOut :PTimeval):cint;
+Var
+  F:TfdSet;
+begin
+  if textrec(t).mode=fmclosed then
+   begin
+     SetErrNo(ESysEBADF);
+     exit(-1);
+   end;
+  Fpfdemptyset(f);
+  fpfdaddset(f,textrec(T).handle);
+  if textrec(T).mode=fminput then
+   fpselect:=fpselect(textrec(T).handle+1,@f,nil,nil,TimeOut)
+  else
+   fpSelect:=fpselect(textrec(T).handle+1,nil,@f,nil,TimeOut);
+end;
+
+Function fpSelect(var T:Text;TimeOut :time_t):cint;
+var
+  p  : PTimeVal;
+  tv : TimeVal;
+begin
+  if TimeOut=-1 then
+   p:=nil
+  else
+   begin
+     tv.tv_Sec:=Timeout div 1000;
+     tv.tv_Usec:=(Timeout mod 1000)*1000;
+     p:=@tv;
+   end;
+  fpSelect:=fpSelect(T,p);
+end;
 
 
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.2  2003-06-01 16:28:41  marco
+ Revision 1.3  2003-09-14 20:15:01  marco
+  * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+ Revision 1.2  2003/06/01 16:28:41  marco
   * Enhancements to make the compiler baseunix using.
   * Enhancements to make the compiler baseunix using.
 
 
  Revision 1.1  2002/12/18 16:49:02  marco
  Revision 1.1  2002/12/18 16:49:02  marco

+ 42 - 21
rtl/unix/bunxovlh.inc

@@ -15,34 +15,55 @@
  **********************************************************************}
  **********************************************************************}
 
 
 Function  FpLink (existing : AnsiString; newone : AnsiString): cInt;
 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  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  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; 
+Function  FpOpen    (path : pChar; flags : cInt):cInt;
+Function  FpOpen    (path : AnsiString; flags : cInt):cInt;
+Function  FpOpen    (path : AnsiString; flags : cInt; Mode: TMode):cInt;
+Function  FpOpen    (path : String; flags : cInt):cInt;
+Function  FpOpen    (path : String; flags : cInt; Mode: TMode):cInt;
+Function  FpChdir   (path : AnsiString): 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  FpStat    (path: String; var buf : stat): cInt;
+Function  FpAccess  (pathname : AnsiString; aMode : cInt): cInt; 
 
 
-Function  FPFStat(var F:Text;Var Info:stat):Boolean;
-Function  FPFStat(var F:File;Var Info:stat):Boolean;
+Function  FPFStat   (var F:Text;Var Info:stat):Boolean;
+Function  FPFStat   (var F:File;Var Info:stat):Boolean;
+
+// added. Is a depreciated POSIX function that can be considered alias to sigaction
+
+Function  FpSignal  (signum:longint;Handler:signalhandler):signalhandler;
+Function  FpRead    (fd : cInt; var buf; nbytes : TSize): TSsize;
+Function  FpWrite   (fd : cInt; const buf; nbytes : TSize): TSsize;
+Function  FpDup	    (var oldfile,newfile:text):cint;
+Function  FpDup     (var oldfile,newfile:file):cint;
+Function  FpDup2    (var oldfile,newfile:text):cint;
+Function  FpDup2    (var oldfile,newfile:file):cint;
+function  fptime    :time_t;
+
+
+Function fpSelect(N:cint;readfds,writefds,exceptfds:pfdset;TimeOut:cint):cint;
+Function fpSelect(var T:Text;TimeOut :PTimeval):cint;
+Function fpSelect(var T:Text;TimeOut :time_t):cint;
 
 
-// added. Is a depreciated POSIX function that can be considered alias to
-// sigaction
-Function FpSignal(signum:longint;Handler:signalhandler):signalhandler;
 
 
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.2  2003-06-01 16:28:41  marco
+ Revision 1.3  2003-09-14 20:15:01  marco
+  * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+ Revision 1.2  2003/06/01 16:28:41  marco
   * Enhancements to make the compiler baseunix using.
   * Enhancements to make the compiler baseunix using.
 
 
  Revision 1.1  2002/12/18 16:49:02  marco
  Revision 1.1  2002/12/18 16:49:02  marco

+ 24 - 21
rtl/unix/crt.pp

@@ -111,7 +111,7 @@ procedure CursorOff;
 
 
 Implementation
 Implementation
 
 
-uses Unix;
+uses BaseUnix,unix;
 
 
 {
 {
   The definitions of TextRec and FileRec are in separate files.
   The definitions of TextRec and FileRec are in separate files.
@@ -349,7 +349,7 @@ procedure ttyFlushOutput;
 begin
 begin
   if OutCnt>0 then
   if OutCnt>0 then
    begin
    begin
-     fdWrite(ttyOut,OutBuf,OutCnt);
+     fpWrite(ttyOut,OutBuf,OutCnt);
      OutCnt:=0;
      OutCnt:=0;
    end;
    end;
 end;
 end;
@@ -406,7 +406,7 @@ begin
      if InTail>InHead then
      if InTail>InHead then
       i:=InTail-InHead;
       i:=InTail-InHead;
    {Read}
    {Read}
-     Readed:=fdRead(TTYIn,InBuf[InHead],i);
+     Readed:=fpread(TTYIn,InBuf[InHead],i);
    {Increase Counters}
    {Increase Counters}
      inc(InCnt,Readed);
      inc(InCnt,Readed);
      inc(InHead,Readed);
      inc(InHead,Readed);
@@ -897,15 +897,15 @@ End;
 { TTYLevel (including ones that are waiting in the TTYRecvChar buffer) }
 { TTYLevel (including ones that are waiting in the TTYRecvChar buffer) }
 function sysKeyPressed: boolean;
 function sysKeyPressed: boolean;
 var
 var
-  fdsin : fdSet;
+  fdsin : tfdSet;
 begin
 begin
   if (InCnt>0) then
   if (InCnt>0) then
    sysKeyPressed:=true
    sysKeyPressed:=true
   else
   else
    begin
    begin
-     FD_Zero(fdsin);
-     fd_Set(TTYin,fdsin);
-     sysKeypressed:=(Select(TTYIn+1,@fdsin,nil,nil,0)>0);
+     FPfdEmptyset(fdsin);
+     Fpfdaddset(fdsin,TTYin);
+     sysKeypressed:=(fpSelect(TTYIn+1,@fdsin,nil,nil,0)>0);
    end;
    end;
 end;
 end;
 
 
@@ -919,7 +919,7 @@ Var
   ch       : char;
   ch       : char;
   OldState,
   OldState,
   State    : longint;
   State    : longint;
-  FDS      : FDSet;
+  FDS      : TFDSet;
 Begin
 Begin
 {Check Buffer first}
 {Check Buffer first}
   if KeySend<>KeyPut then
   if KeySend<>KeyPut then
@@ -931,9 +931,9 @@ Begin
 { Only if none are waiting! (JM) }
 { Only if none are waiting! (JM) }
   if not sysKeyPressed then
   if not sysKeyPressed then
     begin
     begin
-      FD_Zero (FDS);
-      FD_Set (0,FDS);
-      Select (1,@FDS,nil,nil,nil);
+      Fpfdemptyset (FDS);
+      fpfdaddset (FDS,0);
+      fpSelect (1,@FDS,nil,nil,nil);
     end;
     end;
 
 
   ch:=ttyRecvChar;
   ch:=ttyRecvChar;
@@ -1370,7 +1370,7 @@ Begin
       CrtRead := 0;
       CrtRead := 0;
       exit;
       exit;
     end;
     end;
-  F.BufEnd:=fdRead(F.Handle, F.BufPtr^, F.BufSize);
+  F.BufEnd:=fpRead(F.Handle, F.BufPtr^, F.BufSize);
 { fix #13 only's -> #10 to overcome terminal setting }
 { fix #13 only's -> #10 to overcome terminal setting }
   for i:=1to F.BufEnd do
   for i:=1to F.BufEnd do
    begin
    begin
@@ -1461,7 +1461,7 @@ const
 Procedure Sound(Hz: Word);
 Procedure Sound(Hz: Word);
 begin
 begin
   if not OutputRedir then
   if not OutputRedir then
-    ioctl(TextRec(Output).Handle, KIOCSOUND, Pointer(1193180 div Hz));
+    fpIoctl(TextRec(Output).Handle, KIOCSOUND, Pointer(1193180 div Hz));
 end;
 end;
 
 
 
 
@@ -1469,7 +1469,7 @@ end;
 Procedure NoSound;
 Procedure NoSound;
 begin
 begin
   if not OutputRedir then
   if not OutputRedir then
-    ioctl(TextRec(Output).Handle, KIOCSOUND, nil);
+    fpIoctl(TextRec(Output).Handle, KIOCSOUND, nil);
 end;
 end;
 
 
 
 
@@ -1571,7 +1571,7 @@ End;
 
 
 procedure GetXY(var x,y:byte);
 procedure GetXY(var x,y:byte);
 var
 var
-  fds    : fdSet;
+  fds    : tfdSet;
   i,j,
   i,j,
   readed : longint;
   readed : longint;
   buf    : array[0..255] of char;
   buf    : array[0..255] of char;
@@ -1580,12 +1580,12 @@ begin
   x:=0;
   x:=0;
   y:=0;
   y:=0;
   s:=#27'[6n';
   s:=#27'[6n';
-  fdWrite(0,s[1],length(s));
-  FD_Zero(fds);
-  FD_Set(1,fds);
+  fpWrite(0,s[1],length(s));
+  fpFDemptyset(fds);
+  fpfdaddset(fds,1);
   if (Select(2,@fds,nil,nil,1000)>0) then
   if (Select(2,@fds,nil,nil,1000)>0) then
    begin
    begin
-     readed:=fdRead(1,buf,sizeof(buf));
+     readed:=fpRead(1,buf,sizeof(buf));
      i:=0;
      i:=0;
      while (i+5<readed) and (buf[i]<>#27) and (buf[i+1]<>'[') do
      while (i+5<readed) and (buf[i]<>#27) and (buf[i+1]<>'[') do
       inc(i);
       inc(i);
@@ -1613,7 +1613,7 @@ var
 begin
 begin
   if Assigned(ConsoleBuf) then
   if Assigned(ConsoleBuf) then
    FreeMem(ConsoleBuf,ScreenHeight*ScreenWidth*2);
    FreeMem(ConsoleBuf,ScreenHeight*ScreenWidth*2);
-  if (not OutputRedir) and IOCtl(TextRec(Output).Handle,TIOCGWINSZ,@Wininfo) then
+  if (not OutputRedir) and (fpIOCtl(TextRec(Output).Handle,TIOCGWINSZ,@Wininfo)>=0) then
    begin
    begin
      ScreenWidth:=Wininfo.ws_col;
      ScreenWidth:=Wininfo.ws_col;
      ScreenHeight:=Wininfo.ws_row;
      ScreenHeight:=Wininfo.ws_row;
@@ -1682,7 +1682,10 @@ Finalization
 End.
 End.
 {
 {
   $Log$
   $Log$
-  Revision 1.10  2002-09-07 16:01:27  peter
+  Revision 1.11  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.10  2002/09/07 16:01:27  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
   Revision 1.9  2002/05/31 13:37:24  marco
   Revision 1.9  2002/05/31 13:37:24  marco

+ 34 - 35
rtl/unix/dos.pp

@@ -158,7 +158,7 @@ Procedure SetVerify(verify: boolean);
 Implementation
 Implementation
 
 
 Uses
 Uses
-  Strings,Unix;
+  Strings,Unix,BaseUnix;
 
 
 {******************************************************************************
 {******************************************************************************
                            --- Link C Lib if set ---
                            --- Link C Lib if set ---
@@ -206,13 +206,9 @@ Var
   Rel    : LongInt;
   Rel    : LongInt;
   info   : utsname;
   info   : utsname;
 Begin
 Begin
-  {$IFNDEF BSD}
-   UName(info);
-   Move(info.release,buffer[0],40);
-   TmpStr:=StrPas(Buffer);
-  {$ELSE}
-   TmpStr:='FreeBSD doesn''t support UName';
- {$ENDIF}
+  FPUName(info);
+  Move(info.release,buffer[0],40);
+  TmpStr:=StrPas(Buffer);
   SubRel:=0;
   SubRel:=0;
   TmpPos:=Pos('.',TmpStr);
   TmpPos:=Pos('.',TmpStr);
   if TmpPos>0 then
   if TmpPos>0 then
@@ -328,7 +324,7 @@ var
   // The Error-Checking in the previous Version failed, since halt($7F) gives an WaitPid-status of $7F00
   // The Error-Checking in the previous Version failed, since halt($7F) gives an WaitPid-status of $7F00
 Begin
 Begin
   LastDosExitCode:=0;
   LastDosExitCode:=0;
-  pid:=Fork;
+  pid:=fpFork;
   if pid=0 then
   if pid=0 then
    begin
    begin
    {The child does the actual exec, and then exits}
    {The child does the actual exec, and then exits}
@@ -337,7 +333,7 @@ Begin
      else
      else
       Execl(Path+' '+ComLine);
       Execl(Path+' '+ComLine);
    {If the execve fails, we return an exitvalue of 127, to let it be known}
    {If the execve fails, we return an exitvalue of 127, to let it be known}
-     ExitProcess(127);
+     fpExit(127);
    end
    end
   else
   else
    if pid=-1 then         {Fork failed}
    if pid=-1 then         {Fork failed}
@@ -463,7 +459,7 @@ Begin
       Begin
       Begin
         RtlFindRecs[i].SearchNum:=0;
         RtlFindRecs[i].SearchNum:=0;
         if f.dirptr<>0 then
         if f.dirptr<>0 then
-         closedir(pdir(f.dirptr));
+         fpclosedir(pdir(f.dirptr)^);
       End;
       End;
    end;
    end;
   f.dirptr:=0;
   f.dirptr:=0;
@@ -474,18 +470,18 @@ Function FindGetFileInfo(const s:string;var f:SearchRec):boolean;
 var
 var
   DT   : DateTime;
   DT   : DateTime;
   Info : RtlInfoType;
   Info : RtlInfoType;
-  st   : stat;
+  st   : baseunix.stat;
 begin
 begin
   FindGetFileInfo:=false;
   FindGetFileInfo:=false;
-  if not Fstat(s,st) then
+  if not fpstat(s,st)>=0 then
    exit;
    exit;
-  info.FSize:=st.Size;
-  info.FMTime:=st.mtime;
-  if (st.mode and STAT_IFMT)=STAT_IFDIR then
+  info.FSize:=st.st_Size;
+  info.FMTime:=st.st_mtime;
+  if (st.st_mode and STAT_IFMT)=STAT_IFDIR then
    info.fmode:=$10
    info.fmode:=$10
   else
   else
    info.fmode:=$20;
    info.fmode:=$20;
-  if (st.mode and STAT_IWUSR)=0 then
+  if (st.st_mode and STAT_IWUSR)=0 then
    info.fmode:=info.fmode or 1;
    info.fmode:=info.fmode or 1;
   If ((Info.FMode and Not(f.searchattr))=0) Then
   If ((Info.FMode and Not(f.searchattr))=0) Then
    Begin
    Begin
@@ -565,12 +561,12 @@ Begin
            Move(f.SearchSpec[1], DirName[0], f.NamePos);
            Move(f.SearchSpec[1], DirName[0], f.NamePos);
            DirName[f.NamePos] := #0;
            DirName[f.NamePos] := #0;
          End;
          End;
-        f.DirPtr := longint(opendir(@(DirName)));
+        f.DirPtr := longint(fpopendir(@(DirName)));
         If f.DirPtr <> 0 Then
         If f.DirPtr <> 0 Then
          begin
          begin
            ArrayPos:=FindLastUsed;
            ArrayPos:=FindLastUsed;
            If RtlFindRecs[ArrayPos].SearchNum > 0 Then
            If RtlFindRecs[ArrayPos].SearchNum > 0 Then
-            CloseDir(pdir(rtlfindrecs[arraypos].dirptr));
+            FpCloseDir((pdir(rtlfindrecs[arraypos].dirptr)^));
            RtlFindRecs[ArrayPos].SearchNum := f.SearchNum;
            RtlFindRecs[ArrayPos].SearchNum := f.SearchNum;
            RtlFindRecs[ArrayPos].DirPtr := f.DirPtr;
            RtlFindRecs[ArrayPos].DirPtr := f.DirPtr;
            if f.searchpos>0 then
            if f.searchpos>0 then
@@ -586,11 +582,11 @@ Begin
   Finished:=(f.dirptr=0);
   Finished:=(f.dirptr=0);
   While Not Finished Do
   While Not Finished Do
    Begin
    Begin
-     p:=readdir(pdir(f.dirptr));
+     p:=fpreaddir(pdir(f.dirptr)^);
      if p=nil then
      if p=nil then
       FName:=''
       FName:=''
      else
      else
-      FName:=Strpas(@p^.name);
+      FName:=Strpas(@p^.d_name);
      If FName='' Then
      If FName='' Then
       Finished:=True
       Finished:=True
      Else
      Else
@@ -682,9 +678,9 @@ End;
 
 
 Function FSearch(path : pathstr;dirlist : string) : pathstr;
 Function FSearch(path : pathstr;dirlist : string) : pathstr;
 Var
 Var
-  info:stat;
+  info : BaseUnix.stat;
 Begin
 Begin
-  if (length(Path)>0) and (path[1]='/') and FStat(path,info) then
+  if (length(Path)>0) and (path[1]='/') and (fpStat(path,info)>=0) then
     FSearch:=path
     FSearch:=path
   else
   else
     FSearch:=Unix.FSearch(path,dirlist);
     FSearch:=Unix.FSearch(path,dirlist);
@@ -694,25 +690,25 @@ End;
 
 
 Procedure GetFAttr(var f; var attr : word);
 Procedure GetFAttr(var f; var attr : word);
 Var
 Var
-  info : stat;
+  info    : baseunix.stat;
   LinAttr : longint;
   LinAttr : longint;
 Begin
 Begin
   DosError:=0;
   DosError:=0;
-  if not FStat(strpas(@textrec(f).name),info) then
+  if FPStat(strpas(@textrec(f).name),info)<0 then
    begin
    begin
      Attr:=0;
      Attr:=0;
      DosError:=3;
      DosError:=3;
      exit;
      exit;
    end
    end
   else
   else
-   LinAttr:=Info.Mode;
-  if S_ISDIR(LinAttr) then
+   LinAttr:=Info.st_Mode;
+  if fpISDIR(LinAttr) then
    Attr:=$10
    Attr:=$10
   else
   else
    Attr:=$20;
    Attr:=$20;
-  if not Access(strpas(@textrec(f).name),W_OK) then
+  if fpAccess(strpas(@textrec(f).name),W_OK)<0 then
    Attr:=Attr or $1;
    Attr:=Attr or $1;
-  if (not S_ISDIR(LinAttr)) and (filerec(f).name[0]='.')  then
+  if (not fpISDIR(LinAttr)) and (filerec(f).name[0]='.')  then
    Attr:=Attr or $2;
    Attr:=Attr or $2;
 end;
 end;
 
 
@@ -720,18 +716,18 @@ end;
 
 
 Procedure getftime (var f; var time : longint);
 Procedure getftime (var f; var time : longint);
 Var
 Var
-  Info: stat;
+  Info: baseunix.stat;
   DT: DateTime;
   DT: DateTime;
 Begin
 Begin
   doserror:=0;
   doserror:=0;
-  if not fstat(filerec(f).handle,info) then
+  if fpfstat(filerec(f).handle,info)<0 then
    begin
    begin
      Time:=0;
      Time:=0;
      doserror:=6;
      doserror:=6;
      exit
      exit
    end
    end
   else
   else
-   UnixDateToDT(Info.mTime,DT);
+   UnixDateToDT(Info.st_mTime,DT);
   PackTime(DT,Time);
   PackTime(DT,Time);
 End;
 End;
 
 
@@ -782,7 +778,7 @@ Function GetEnv(EnvVar: String): String;
 var
 var
   p     : pchar;
   p     : pchar;
 Begin
 Begin
-  p:=Unix.GetEnv(EnvVar);
+  p:=BaseUnix.fpGetEnv(EnvVar);
   if p=nil then
   if p=nil then
    GetEnv:=''
    GetEnv:=''
   else
   else
@@ -855,7 +851,7 @@ Begin
     end;
     end;
   for Index:=0 to FilerecNameLength-1 do
   for Index:=0 to FilerecNameLength-1 do
     path[Index+1]:=filerec(f).name[Index];
     path[Index+1]:=filerec(f).name[Index];
-  if not utime(path,utim) then
+  if fputime(path,@utim)<0 then
     begin
     begin
     Time:=0;
     Time:=0;
     doserror:=3;
     doserror:=3;
@@ -910,7 +906,10 @@ End.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.15  2003-05-16 20:56:06  florian
+  Revision 1.16  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.15  2003/05/16 20:56:06  florian
   no message
   no message
 
 
   Revision 1.14  2003/05/14 13:51:03  florian
   Revision 1.14  2003/05/14 13:51:03  florian

+ 6 - 3
rtl/unix/genfuncs.inc

@@ -96,16 +96,16 @@ Begin
 	exit(cp+1);
 	exit(cp+1);
    inc(p);
    inc(p);
   end;
   end;
+ fpgetenv:=nil;
 End;
 End;
 
 
-Function fpgetenv(name:string):Pchar;
+Function fpgetenv(name:string):Pchar; [public, alias : 'FPC_SYSC_FPGETENV'];
 {
 {
   Searches the environment for a string with name p and
   Searches the environment for a string with name p and
   returns a pchar to it's value.
   returns a pchar to it's value.
   A pchar is used to accomodate for strings of length > 255
   A pchar is used to accomodate for strings of length > 255
 }
 }
 
 
-
 Begin
 Begin
   name:=name+'=';            {Else HOST will also find HOSTNAME, etc}
   name:=name+'=';            {Else HOST will also find HOSTNAME, etc}
   fpgetenv:=fpgetenv(@name[1]);
   fpgetenv:=fpgetenv(@name[1]);
@@ -113,7 +113,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2002-12-18 16:50:39  marco
+  Revision 1.2  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.1  2002/12/18 16:50:39  marco
    * Unix RTL generic parts. Linux working, *BSD will follow shortly
    * Unix RTL generic parts. Linux working, *BSD will follow shortly
 
 
   Revision 1.2  2002/10/27 17:21:30  marco
   Revision 1.2  2002/10/27 17:21:30  marco

+ 5 - 2
rtl/unix/gpm.pp

@@ -16,7 +16,7 @@
 unit gpm;
 unit gpm;
 interface
 interface
 uses
 uses
-  Unix;
+  baseUnix;
 
 
 {$linklib gpm}
 {$linklib gpm}
 {$linklib c}
 {$linklib c}
@@ -206,7 +206,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2002-09-07 16:01:27  peter
+  Revision 1.6  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.5  2002/09/07 16:01:27  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
 }
 }

+ 5 - 2
rtl/unix/graph.pp

@@ -85,7 +85,7 @@ Const
 implementation
 implementation
 
 
 uses
 uses
-  Unix;
+  Unix,x86;
 
 
 const
 const
   InternalDriverName = 'LinuxVGA';
   InternalDriverName = 'LinuxVGA';
@@ -601,7 +601,10 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2002-09-07 16:01:27  peter
+  Revision 1.8  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.7  2002/09/07 16:01:27  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
 }
 }

+ 13 - 10
rtl/unix/ipc.pp

@@ -239,7 +239,7 @@ Function semctl(semid:longint; semnum:longint; cmd:longint; var arg: tsemun): lo
 
 
 implementation
 implementation
 
 
-uses Unix;
+uses BaseUnix,Syscall;
 
 
 { The following definitions come from linux/ipc.h }
 { The following definitions come from linux/ipc.h }
 
 
@@ -261,30 +261,30 @@ Const
 function ipccall(Call,First,Second,Third : Longint; P : Pointer) : longint;
 function ipccall(Call,First,Second,Third : Longint; P : Pointer) : longint;
 
 
 {$ifndef bsd}
 {$ifndef bsd}
-Var SR : SysCallRegs;
+//Var SR : SysCallRegs;
 {$endif}
 {$endif}
 begin
 begin
  {$IFNDEF bsd}
  {$IFNDEF bsd}
-  SR.Reg2:=Call;
+{  SR.Reg2:=Call;
   SR.reg3:=first;
   SR.reg3:=first;
   SR.reg4:=second;
   SR.reg4:=second;
   SR.Reg5:=third;
   SR.Reg5:=third;
-  SR.Reg6:=Longint(P);
-  ipccall:=syscall(syscall_nr_ipc,sr);
+  SR.Reg6:=Longint(P); }
+  ipccall:=do_syscall(syscall_nr_ipc,call,first,second,third,longint(P));
   {$Endif}
   {$Endif}
- ipcerror:=Errno;
+ ipcerror:=fpgetErrno;
 end;
 end;
 
 
 Function ftok (Path : String; ID : char) : TKey;
 Function ftok (Path : String; ID : char) : TKey;
 
 
-Var Info : Stat;
+Var Info : TStat;
 
 
 begin
 begin
-  If not fstat(path,info) then
+  If fpstat(path,info)<0 then
     ftok:=-1
     ftok:=-1
   else
   else
     begin
     begin
-    ftok:= (info.ino and $FFFF) or ((info.dev and $ff) shl 16) or (byte(ID) shl 24)
+    ftok:= (info.st_ino and $FFFF) or ((info.st_dev and $ff) shl 16) or (byte(ID) shl 24)
     end;
     end;
 end;
 end;
 
 
@@ -372,7 +372,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2002-09-07 16:01:27  peter
+  Revision 1.5  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.4  2002/09/07 16:01:27  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
 }
 }

+ 48 - 45
rtl/unix/keyboard.pp

@@ -42,7 +42,7 @@ uses
   Strings,
   Strings,
   TermInfo,
   TermInfo,
 {$endif NotUseTree}
 {$endif NotUseTree}
-  Unix;
+  Unix,baseUnix;
 
 
 {$i keyboard.inc}
 {$i keyboard.inc}
 
 
@@ -130,19 +130,19 @@ var
   entry : kbentry;
   entry : kbentry;
   i : longint;
   i : longint;
 begin
 begin
-  Ioctl(stdinputhandle,KDGKBMETA,@oldmeta);
+  fpIoctl(stdinputhandle,KDGKBMETA,@oldmeta);
   meta:=K_ESCPREFIX;
   meta:=K_ESCPREFIX;
-  Ioctl(stdinputhandle,KDSKBMETA,@meta);
+  fpIoctl(stdinputhandle,KDSKBMETA,@meta);
   for i:=1 to kbdchanges do
   for i:=1 to kbdchanges do
    begin
    begin
      e:=@kbdchange[i];
      e:=@kbdchange[i];
      entry.kb_table:=e^.tab;
      entry.kb_table:=e^.tab;
      entry.kb_index:=e^.idx;
      entry.kb_index:=e^.idx;
-     Ioctl(stdinputhandle,KDGKBENT,@entry);
+     fpIoctl(stdinputhandle,KDGKBENT,@entry);
      e^.oldval:=entry.kb_value;
      e^.oldval:=entry.kb_value;
      entry.kb_table:=e^.oldtab;
      entry.kb_table:=e^.oldtab;
      entry.kb_index:=e^.oldidx;
      entry.kb_index:=e^.oldidx;
-     ioctl(stdinputhandle,KDGKBENT,@entry);
+     fpioctl(stdinputhandle,KDGKBENT,@entry);
      e^.newval:=entry.kb_value;
      e^.newval:=entry.kb_value;
    end;
    end;
   for i:=1 to kbdchanges do
   for i:=1 to kbdchanges do
@@ -151,7 +151,7 @@ begin
      entry.kb_table:=e^.tab;
      entry.kb_table:=e^.tab;
      entry.kb_index:=e^.idx;
      entry.kb_index:=e^.idx;
      entry.kb_value:=e^.newval;
      entry.kb_value:=e^.newval;
-     Ioctl(stdinputhandle,KDSKBENT,@entry);
+     fpioctl(stdinputhandle,KDSKBENT,@entry);
    end;
    end;
 end;
 end;
 
 
@@ -163,14 +163,14 @@ var
   i : longint;
   i : longint;
 begin
 begin
   if oldmeta in [K_ESCPREFIX,K_METABIT] then
   if oldmeta in [K_ESCPREFIX,K_METABIT] then
-    Ioctl(stdinputhandle,KDSKBMETA,@oldmeta);
+    fpioctl(stdinputhandle,KDSKBMETA,@oldmeta);
   for i:=1 to kbdchanges do
   for i:=1 to kbdchanges do
    begin
    begin
      e:=@kbdchange[i];
      e:=@kbdchange[i];
      entry.kb_table:=e^.tab;
      entry.kb_table:=e^.tab;
      entry.kb_index:=e^.idx;
      entry.kb_index:=e^.idx;
      entry.kb_value:=e^.oldval;
      entry.kb_value:=e^.oldval;
-     Ioctl(stdinputhandle,KDSKBENT,@entry);
+     fpioctl(stdinputhandle,KDSKBENT,@entry);
    end;
    end;
 end;
 end;
 
 
@@ -197,7 +197,7 @@ begin
      if InTail>InHead then
      if InTail>InHead then
       i:=InTail-InHead;
       i:=InTail-InHead;
    {Read}
    {Read}
-     Readed:=fdRead(StdInputHandle,InBuf[InHead],i);
+     Readed:=fpRead(StdInputHandle,InBuf[InHead],i);
    {Increase Counters}
    {Increase Counters}
      inc(InCnt,Readed);
      inc(InCnt,Readed);
      inc(InHead,Readed);
      inc(InHead,Readed);
@@ -283,15 +283,15 @@ End;
 { TTYLevel (including ones that are waiting in the TTYRecvChar buffer) }
 { TTYLevel (including ones that are waiting in the TTYRecvChar buffer) }
 function sysKeyPressed: boolean;
 function sysKeyPressed: boolean;
 var
 var
-  fdsin : fdSet;
+  fdsin : tfdSet;
 begin
 begin
   if (InCnt>0) then
   if (InCnt>0) then
    sysKeyPressed:=true
    sysKeyPressed:=true
   else
   else
    begin
    begin
-     FD_Zero(fdsin);
-     fd_Set(StdInputHandle,fdsin);
-     sysKeypressed:=(Select(StdInputHandle+1,@fdsin,nil,nil,0)>0);
+     fpfdemptyset(fdsin);
+     fpfdaddset(fdsin,StdInputHandle);
+     sysKeypressed:=(fpSelect(StdInputHandle+1,@fdsin,nil,nil,0)>0);
    end;
    end;
 end;
 end;
 
 
@@ -331,13 +331,13 @@ Const
   procedure GenMouseEvent;
   procedure GenMouseEvent;
   var MouseEvent: TMouseEvent;
   var MouseEvent: TMouseEvent;
       ch : char;
       ch : char;
-      fdsin : fdSet;
+      fdsin : tfdSet;
   begin
   begin
-    FD_Zero(fdsin);
-    fd_Set(StdInputHandle,fdsin);
+    fpfdemptyset(fdsin);
+    fpfdaddset(fdsin,StdInputHandle);
     Fillchar(MouseEvent,SizeOf(TMouseEvent),#0);
     Fillchar(MouseEvent,SizeOf(TMouseEvent),#0);
      if InCnt=0 then
      if InCnt=0 then
-       Select(StdInputHandle+1,@fdsin,nil,nil,10);
+       fpSelect(StdInputHandle+1,@fdsin,nil,nil,10);
      ch:=ttyRecvChar;
      ch:=ttyRecvChar;
     { Other bits are used for Shift, Meta and Ctrl modifiers PM }
     { Other bits are used for Shift, Meta and Ctrl modifiers PM }
     case (ord(ch)-ord(' ')) and 3  of
     case (ord(ch)-ord(' ')) and 3  of
@@ -350,11 +350,11 @@ Const
       3 : { no button pressed };
       3 : { no button pressed };
       end;
       end;
      if InCnt=0 then
      if InCnt=0 then
-       Select(StdInputHandle+1,@fdsin,nil,nil,10);
+       fpSelect(StdInputHandle+1,@fdsin,nil,nil,10);
      ch:=ttyRecvChar;
      ch:=ttyRecvChar;
      MouseEvent.x:=Ord(ch)-ord(' ')-1;
      MouseEvent.x:=Ord(ch)-ord(' ')-1;
      if InCnt=0 then
      if InCnt=0 then
-      Select(StdInputHandle+1,@fdsin,nil,nil,10);
+      fpSelect(StdInputHandle+1,@fdsin,nil,nil,10);
      ch:=ttyRecvChar;
      ch:=ttyRecvChar;
      MouseEvent.y:=Ord(ch)-ord(' ')-1;
      MouseEvent.y:=Ord(ch)-ord(' ')-1;
      if (MouseEvent.buttons<>0) then
      if (MouseEvent.buttons<>0) then
@@ -802,7 +802,7 @@ end;
 
 
 Function RawReadKey:char;
 Function RawReadKey:char;
 Var
 Var
-  fdsin    : fdSet;
+  fdsin    : tfdSet;
 Begin
 Begin
 {Check Buffer first}
 {Check Buffer first}
   if KeySend<>KeyPut then
   if KeySend<>KeyPut then
@@ -813,9 +813,9 @@ Begin
 {Wait for Key}
 {Wait for Key}
   if not sysKeyPressed then
   if not sysKeyPressed then
    begin
    begin
-     FD_Zero (fdsin);
-     FD_Set (StdInputHandle,fdsin);
-     Select (StdInputHandle+1,@fdsin,nil,nil,nil);
+     fpfdemptyset (fdsin);
+     fpfdaddSet (fdsin,StdInputHandle);
+     fpSelect (StdInputHandle+1,@fdsin,nil,nil,nil);
    end;
    end;
   RawReadKey:=ttyRecvChar;
   RawReadKey:=ttyRecvChar;
 end;
 end;
@@ -824,15 +824,15 @@ end;
 Function RawReadString : String;
 Function RawReadString : String;
 Var
 Var
   ch : char;
   ch : char;
-  fdsin : fdSet;
+  fdsin : tfdSet;
   St : String;
   St : String;
 Begin
 Begin
   St:=RawReadKey;
   St:=RawReadKey;
-  FD_Zero (fdsin);
-  FD_Set (StdInputHandle,fdsin);
+  fpfdemptyset (fdsin);
+  fpfdaddSet (fdsin,StdInputHandle);
   Repeat
   Repeat
      if InCnt=0 then
      if InCnt=0 then
-       Select(StdInputHandle+1,@fdsin,nil,nil,10);
+       fpSelect(StdInputHandle+1,@fdsin,nil,nil,10);
      if SysKeyPressed then
      if SysKeyPressed then
        ch:=ttyRecvChar
        ch:=ttyRecvChar
      else
      else
@@ -852,7 +852,7 @@ Var
   State    : longint;
   State    : longint;
 {$endif NotUseTree}
 {$endif NotUseTree}
   is_delay : boolean;
   is_delay : boolean;
-  fdsin    : fdSet;
+  fdsin    : tfdSet;
   store    : array [0..8] of char;
   store    : array [0..8] of char;
   arrayind : byte;
   arrayind : byte;
 {$ifndef NotUseTree}
 {$ifndef NotUseTree}
@@ -872,11 +872,11 @@ Var
       #35 : { no button pressed };
       #35 : { no button pressed };
       end;
       end;
      if InCnt=0 then
      if InCnt=0 then
-       Select(StdInputHandle+1,@fdsin,nil,nil,10);
+       fpSelect(StdInputHandle+1,@fdsin,nil,nil,10);
      ch:=ttyRecvChar;
      ch:=ttyRecvChar;
      MouseEvent.x:=Ord(ch)-ord(' ')-1;
      MouseEvent.x:=Ord(ch)-ord(' ')-1;
      if InCnt=0 then
      if InCnt=0 then
-      Select(StdInputHandle+1,@fdsin,nil,nil,10);
+      fpSelect(StdInputHandle+1,@fdsin,nil,nil,10);
      ch:=ttyRecvChar;
      ch:=ttyRecvChar;
      MouseEvent.y:=Ord(ch)-ord(' ')-1;
      MouseEvent.y:=Ord(ch)-ord(' ')-1;
      if (MouseEvent.buttons<>0) then
      if (MouseEvent.buttons<>0) then
@@ -917,9 +917,9 @@ Begin
 {Wait for Key}
 {Wait for Key}
   if not sysKeyPressed then
   if not sysKeyPressed then
    begin
    begin
-     FD_Zero (fdsin);
-     FD_Set (StdInputHandle,fdsin);
-     Select (StdInputHandle+1,@fdsin,nil,nil,nil);
+     fpfdemptyset (fdsin);
+     fpfdaddSet (fdsin,StdInputHandle);
+     fpSelect (StdInputHandle+1,@fdsin,nil,nil,nil);
    end;
    end;
   ch:=ttyRecvChar;
   ch:=ttyRecvChar;
 {$ifndef NotUseTree}
 {$ifndef NotUseTree}
@@ -928,14 +928,14 @@ Begin
     PushKey(ch)
     PushKey(ch)
   else
   else
     begin
     begin
-     FD_Zero(fdsin);
-     fd_Set(StdInputHandle,fdsin);
+     fpfdemptyset(fdsin);
+     fpfdaddSet(fdsin,StdInputHandle);
      store[0]:=ch;
      store[0]:=ch;
      arrayind:=1;
      arrayind:=1;
       while assigned(NPT) and syskeypressed do
       while assigned(NPT) and syskeypressed do
         begin
         begin
           if (InCnt=0) then
           if (InCnt=0) then
-            Select(StdInputHandle+1,@fdsin,nil,nil,10);
+            fpSelect(StdInputHandle+1,@fdsin,nil,nil,10);
           ch:=ttyRecvChar;
           ch:=ttyRecvChar;
           NNPT:=FindChild(ord(ch),NPT);
           NNPT:=FindChild(ord(ch),NPT);
           if assigned(NNPT) then
           if assigned(NNPT) then
@@ -983,8 +983,8 @@ Begin
 {Esc Found ?}
 {Esc Found ?}
   If (ch=#27) then
   If (ch=#27) then
    begin
    begin
-     FD_Zero(fdsin);
-     fd_Set(StdInputHandle,fdsin);
+     fpfdemptyset(fdsin);
+     fpfdaddSet(fdsin,StdInputHandle);
      State:=1;
      State:=1;
      store[0]:=#27;
      store[0]:=#27;
      arrayind:=1;
      arrayind:=1;
@@ -992,7 +992,7 @@ Begin
      write(f,'Esc');
      write(f,'Esc');
 {$endif logging}
 {$endif logging}
      if InCnt=0 then
      if InCnt=0 then
-      Select(StdInputHandle+1,@fdsin,nil,nil,10);
+      fpSelect(StdInputHandle+1,@fdsin,nil,nil,10);
      while (State<>0) and (sysKeyPressed) do
      while (State<>0) and (sysKeyPressed) do
       begin
       begin
         ch:=ttyRecvChar;
         ch:=ttyRecvChar;
@@ -1173,7 +1173,7 @@ Begin
       255 : { just forget this trailing char };
       255 : { just forget this trailing char };
         end;
         end;
         if (State<>0) and (InCnt=0) then
         if (State<>0) and (InCnt=0) then
-         Select(StdInputHandle+1,@fdsin,nil,nil,10);
+         fpSelect(StdInputHandle+1,@fdsin,nil,nil,10);
       end;
       end;
      if State=1 then
      if State=1 then
       PushKey(ch);
       PushKey(ch);
@@ -1181,7 +1181,7 @@ Begin
      if ch='$' then
      if ch='$' then
        begin { '$<XX>' means a delay of XX millisecs }
        begin { '$<XX>' means a delay of XX millisecs }
          is_delay :=false;
          is_delay :=false;
-         Select(StdInputHandle+1,@fdsin,nil,nil,10);
+         fpSelect(StdInputHandle+1,@fdsin,nil,nil,10);
          if (sysKeyPressed) then
          if (sysKeyPressed) then
            begin
            begin
              ch:=ttyRecvChar;
              ch:=ttyRecvChar;
@@ -1196,7 +1196,7 @@ Begin
 {$ifdef logging}
 {$ifdef logging}
                  write(f,'$<');
                  write(f,'$<');
 {$endif logging}
 {$endif logging}
-                 Select(StdInputHandle+1,@fdsin,nil,nil,10);
+                 fpSelect(StdInputHandle+1,@fdsin,nil,nil,10);
                  while (sysKeyPressed) and (ch<>'>') do
                  while (sysKeyPressed) and (ch<>'>') do
                    begin
                    begin
                      { Should we really repect this delay ?? }
                      { Should we really repect this delay ?? }
@@ -1204,7 +1204,7 @@ Begin
 {$ifdef logging}
 {$ifdef logging}
                      write(f,ch);
                      write(f,ch);
 {$endif logging}
 {$endif logging}
-                     Select(StdInputHandle+1,@fdsin,nil,nil,10);
+                     fpSelect(StdInputHandle+1,@fdsin,nil,nil,10);
                    end;
                    end;
                end;
                end;
            end
            end
@@ -1239,7 +1239,7 @@ begin
   arg:=6;
   arg:=6;
   shift:=0;
   shift:=0;
   {$Ifndef BSD}
   {$Ifndef BSD}
-  if IOCtl(StdInputHandle,TIOCLINUX,@arg) then
+  if fpioctl(StdInputHandle,TIOCLINUX,@arg)=0 then
    begin
    begin
      if (arg and 8)<>0 then
      if (arg and 8)<>0 then
       shift:=kbAlt;
       shift:=kbAlt;
@@ -1532,7 +1532,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2003-03-27 12:52:10  armin
+  Revision 1.14  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.13  2003/03/27 12:52:10  armin
   * forgot to initialize RootTree to nil in FreeTree
   * forgot to initialize RootTree to nil in FreeTree
 
 
   Revision 1.12  2003/03/26 12:35:23  armin
   Revision 1.12  2003/03/26 12:35:23  armin

+ 190 - 87
rtl/unix/linux.pp

@@ -16,17 +16,24 @@
 Unit Linux;
 Unit Linux;
 Interface
 Interface
 
 
+Uses BaseUnix;
+
 { Get Types and Constants }
 { Get Types and Constants }
 {$i sysconst.inc}
 {$i sysconst.inc}
 {$i systypes.inc}
 {$i systypes.inc}
 
 
-{ Get System call numbers and error-numbers}
+{$i ptypes.inc}
+{$i ostypes.inc}
 {$i sysnr.inc}
 {$i sysnr.inc}
+{$i syscallh.inc}
+
+{ Get System call numbers and error-numbers}
 {$i errno.inc}
 {$i errno.inc}
 {$I signal.inc}
 {$I signal.inc}
 
 
+Type stat=baseunix.tstat;
+
 var
 var
-  ErrNo,
   LinuxError : Longint;
   LinuxError : Longint;
 
 
 
 
@@ -159,20 +166,6 @@ Type
                             Procedure/Functions
                             Procedure/Functions
 ******************************************************************************}
 ******************************************************************************}
 
 
-{$ifdef bsd}
-function Do_SysCall(sysnr:longint):longint;
-//function Do_Syscall(sysnr,param1:integer):longint;
-function Do_SysCall(sysnr,param1:LONGINT):longint;
-function Do_SysCall(sysnr,param1,param2:LONGINT):longint;
-function Do_SysCall(sysnr,param1,param2,param3:LONGINT):longint;
-function Do_SysCall(sysnr,param1,param2,param3,param4:LONGINT):longint;
-function Do_SysCall(sysnr,param1,param2,param3,param4,param5:LONGINT):longint;
-function Do_SysCall(sysnr,param1,param2,param3,param4,param5,param6:LONGINT):int64;
-function Do_SysCall(sysnr,param1,param2,param3,param4,param5,param6,param7:LONGINT):int64;
-{$else}
-Function SysCall(callnr:longint;var regs:SysCallregs):longint;
-{$endif}
-
 {**************************
 {**************************
      Time/Date Handling
      Time/Date Handling
 ***************************}
 ***************************}
@@ -268,7 +261,7 @@ Function  fdOpen(pathname:string;flags,mode:longint):longint;
 Function  fdOpen(pathname:pchar;flags:longint):longint;
 Function  fdOpen(pathname:pchar;flags:longint):longint;
 Function  fdOpen(pathname:pchar;flags,mode:longint):longint;
 Function  fdOpen(pathname:pchar;flags,mode:longint):longint;
 Function  fdClose(fd:longint):boolean;
 Function  fdClose(fd:longint):boolean;
-Function  fdRead(fd:longint;var buf;size:longint):longint;
+Function  fdRead(fd:longint;var buf;tsize:longint):longint;
 Function  fdWrite(fd:longint;const buf;size:longint):longint;
 Function  fdWrite(fd:longint;const buf;size:longint):longint;
 Function  fdTruncate(fd,size:longint):boolean;
 Function  fdTruncate(fd,size:longint):boolean;
 Function  fdSeek (fd,pos,seektype :longint): longint;
 Function  fdSeek (fd,pos,seektype :longint): longint;
@@ -310,8 +303,8 @@ Function  Dup(var oldfile,newfile:file):Boolean;
 Function  Dup2(oldfile,newfile:longint):Boolean;
 Function  Dup2(oldfile,newfile:longint):Boolean;
 Function  Dup2(var oldfile,newfile:text):Boolean;
 Function  Dup2(var oldfile,newfile:text):Boolean;
 Function  Dup2(var oldfile,newfile:file):Boolean;
 Function  Dup2(var oldfile,newfile:file):Boolean;
-Function  Select(N:longint;readfds,writefds,exceptfds:PFDSet;TimeOut:PTimeVal):longint;
-Function  Select(N:longint;readfds,writefds,exceptfds:PFDSet;TimeOut:Longint):longint;
+Function  Select(N:longint;readfds,writefds,exceptfds:pfdset;TimeOut:PTimeVal):longint;
+Function  Select(N:longint;readfds,writefds,exceptfds:pfdset;TimeOut:Longint):longint;
 Function  SelectText(var T:Text;TimeOut :PTimeVal):Longint;
 Function  SelectText(var T:Text;TimeOut :PTimeVal):Longint;
 Function  SelectText(var T:Text;TimeOut :Longint):Longint;
 Function  SelectText(var T:Text;TimeOut :Longint):Longint;
 
 
@@ -359,7 +352,7 @@ Function  Uname(var unamerec:utsname):Boolean;
         Signal
         Signal
 ***************************}
 ***************************}
 
 
-Procedure SigAction(Signum:longint;Act,OldAct:PSigActionRec );
+Procedure SigAction(Signum:longint;Act,OldAct:baseunix.PSigActionRec );
 Procedure SigProcMask (How:longint;SSet,OldSSet:PSigSet);
 Procedure SigProcMask (How:longint;SSet,OldSSet:PSigSet);
 Function  SigPending:SigSet;
 Function  SigPending:SigSet;
 Procedure SigSuspend(Mask:Sigset);
 Procedure SigSuspend(Mask:Sigset);
@@ -476,10 +469,10 @@ Function  StringToPPChar(S : Pchar):ppchar;
 Function  GetFS(var T:Text):longint;
 Function  GetFS(var T:Text):longint;
 Function  GetFS(Var F:File):longint;
 Function  GetFS(Var F:File):longint;
 {Filedescriptorsets}
 {Filedescriptorsets}
-Procedure FD_Zero(var fds:fdSet);
-Procedure FD_Clr(fd:longint;var fds:fdSet);
-Procedure FD_Set(fd:longint;var fds:fdSet);
-Function  FD_IsSet(fd:longint;var fds:fdSet):boolean;
+Procedure FD_Zero(var fds:tfdset);
+Procedure FD_Clr(fd:longint;var fds:tfdset);
+Procedure FD_Set(fd:longint;var fds:tfdset);
+Function  FD_IsSet(fd:longint;var fds:tfdset):boolean;
 {Stat.Mode Types}
 {Stat.Mode Types}
 Function S_ISLNK(m:word):boolean;
 Function S_ISLNK(m:word):boolean;
 Function S_ISREG(m:word):boolean;
 Function S_ISREG(m:word):boolean;
@@ -497,7 +490,7 @@ Function S_ISSOCK(m:word):boolean;
 
 
 Implementation
 Implementation
 
 
-Uses Strings,baseunix;
+Uses Strings,Unix;
 
 
 
 
 { Get the definitions of textrec and filerec }
 { Get the definitions of textrec and filerec }
@@ -505,10 +498,13 @@ Uses Strings,baseunix;
 {$i filerec.inc}
 {$i filerec.inc}
 
 
 { Raw System calls are in Syscalls.inc}
 { Raw System calls are in Syscalls.inc}
+{$DEFINE FROMLINUXUNIT}
 {$i syscalls.inc}
 {$i syscalls.inc}
 
 
 {$i unixsysc.inc}   {Syscalls only used in unit Unix/Linux}
 {$i unixsysc.inc}   {Syscalls only used in unit Unix/Linux}
 
 
+Function FpNanoSleep(const req : timespec;rem : ptimespec) : longint; external name 'FPC_SYSC_NANOSLEEP';
+
 
 
 {******************************************************************************
 {******************************************************************************
                           Process related calls
                           Process related calls
@@ -898,9 +894,9 @@ var
   t : timeval;
   t : timeval;
 begin
 begin
   gettimeofday(t);
   gettimeofday(t);
-  EpochToLocal(t.sec,year,month,day,hour,min,sec);
-  msec:=t.usec div 1000;
-  usec:=t.usec mod 1000;
+  EpochToLocal(t.tv_sec,year,month,day,hour,min,sec);
+  msec:=t.tv_usec div 1000;
+  usec:=t.tv_usec mod 1000;
 end;
 end;
 
 
 
 
@@ -954,7 +950,7 @@ var
 begin
 begin
   sr.reg2:=longint(@t);
   sr.reg2:=longint(@t);
   SysCall(Syscall_nr_stime,sr);
   SysCall(Syscall_nr_stime,sr);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
    stime:=linuxerror=0;
    stime:=linuxerror=0;
 end;
 end;
 {$endif}
 {$endif}
@@ -1004,6 +1000,120 @@ end;
 { Include timezone handling routines which use /usr/share/timezone info }
 { Include timezone handling routines which use /usr/share/timezone info }
 {$i timezone.inc}
 {$i timezone.inc}
 
 
+Function NanoSleep(const req : timespec;var rem : timespec) : longint;
+
+begin
+ nanosleep:=fpnanosleep(req,@rem);
+end;
+
+Function  OpenDir(f:pchar):pdir;
+
+begin
+   OpenDir:=fpopendir(f);
+  linuxerror:=fpgeterrno;
+end;
+
+function  CloseDir(p:pdir):integer;
+
+begin
+  CloseDir:=Fpclosedir(p^);
+  linuxerror:=fpgeterrno;
+end;
+
+Procedure SigAction(Signum:longint;Act:baseunix.psigactionrec;OldAct:baseunix.PSigActionRec );
+
+begin
+   fpsigaction(signum,act,oldact);
+  linuxerror:=fpgeterrno;
+end;
+
+
+Function  sys_ReadDir(p:pdir):pdirent;
+
+begin
+  sys_readdir:=fpreaddir(p^);
+  linuxerror:=fpgeterrno;
+end;
+
+function sys_unlink(p:pchar):longint;
+
+begin
+  sys_unlink:=fpunlink(p);
+  linuxerror:=fpgeterrno;
+end;
+
+function sys_rename(p,p2:pchar):longint;
+
+begin
+  sys_rename:=fprename(p,p2);
+  linuxerror:=fpgeterrno;
+end;
+
+Function sys_SymLink(OldPath,newPath:pchar):longint;
+
+begin
+  sys_Symlink:=fpsymlink(oldpath,newpath);
+  linuxerror:=fpgeterrno;
+end;
+
+
+Function sys_ReadLink(name,linkname:pchar;maxlen:longint):longint;
+{
+  Read a link (where it points to)
+}
+begin
+  sys_Readlink:=fpreadlink(Name,LinkName,maxlen);
+  linuxerror:=fpgeterrno;
+end;
+
+function sys_open(p:pchar;f,i:longint):longint;
+
+begin
+  sys_open:=fpopen(p,f,i);
+  linuxerror:=fpgeterrno;
+end;
+
+Function Sys_Lseek(F:longint;Off:longint;Whence:longint):longint;
+begin
+ sys_lseek:=fplseek(f,off,whence);
+ linuxerror:=fpgeterrno;
+end;
+
+Function Sys_Stat(Filename:pchar;var Buffer: stat):longint;
+
+begin
+ Sys_stat:=fpstat(filename,buffer); 
+ linuxerror:=fpgeterrno;
+end;
+
+function sys_close(f:longint):longint;
+
+begin
+ sys_close:=fpclose(f);
+ linuxerror:=fpgeterrno;
+end;
+
+function sys_read(f:longint;p:pchar;i:longint):longint;
+
+begin
+ sys_read:=fpread(f,p,i);
+ linuxerror:=fpgeterrno;
+end;
+
+function sys_write(f:longint;p:pchar;i:longint):longint;
+
+begin
+ sys_write:=fpwrite(f,p,i);
+ linuxerror:=fpgeterrno;
+end;
+
+
+Function  Select(N:longint;readfds,writefds,exceptfds:pfdset;TimeOut:PTimeVal):longint;
+
+begin
+   select:=fpSelect(N,readfds,writefds,exceptfds,TimeOut^.tv_sec);
+   linuxerror:=fpgeterrno;
+end;
 
 
 {******************************************************************************
 {******************************************************************************
                            FileSystem calls
                            FileSystem calls
@@ -1013,7 +1123,6 @@ Function fdOpen(pathname:string;flags:longint):longint;
 begin
 begin
   pathname:=pathname+#0;
   pathname:=pathname+#0;
   fdOpen:=Sys_Open(@pathname[1],flags,438);
   fdOpen:=Sys_Open(@pathname[1],flags,438);
-  LinuxError:=Errno;
 end;
 end;
 
 
 
 
@@ -1021,7 +1130,6 @@ Function fdOpen(pathname:string;flags,mode:longint):longint;
 begin
 begin
   pathname:=pathname+#0;
   pathname:=pathname+#0;
   fdOpen:=Sys_Open(@pathname[1],flags,mode);
   fdOpen:=Sys_Open(@pathname[1],flags,mode);
-  LinuxError:=Errno;
 end;
 end;
 
 
 
 
@@ -1029,7 +1137,6 @@ end;
 Function  fdOpen(pathname:pchar;flags:longint):longint;
 Function  fdOpen(pathname:pchar;flags:longint):longint;
 begin
 begin
   fdOpen:=Sys_Open(pathname,flags,0);
   fdOpen:=Sys_Open(pathname,flags,0);
-  LinuxError:=Errno;
 end;
 end;
 
 
 
 
@@ -1037,7 +1144,6 @@ end;
 Function  fdOpen(pathname:pchar;flags,mode:longint):longint;
 Function  fdOpen(pathname:pchar;flags,mode:longint):longint;
 begin
 begin
   fdOpen:=Sys_Open(pathname,flags,mode);
   fdOpen:=Sys_Open(pathname,flags,mode);
-  LinuxError:=Errno;
 end;
 end;
 
 
 
 
@@ -1045,15 +1151,13 @@ end;
 Function fdClose(fd:longint):boolean;
 Function fdClose(fd:longint):boolean;
 begin
 begin
   fdClose:=(Sys_Close(fd)=0);
   fdClose:=(Sys_Close(fd)=0);
-  LinuxError:=Errno;
 end;
 end;
 
 
 
 
 
 
-Function fdRead(fd:longint;var buf;size:longint):longint;
+Function fdRead(fd:longint;var buf;tsize:longint):longint;
 begin
 begin
-  fdRead:=Sys_Read(fd,pchar(@buf),size);
-  LinuxError:=Errno;
+  fdRead:=Sys_Read(fd,pchar(@buf),tsize);
 end;
 end;
 
 
 
 
@@ -1061,7 +1165,6 @@ end;
 Function fdWrite(fd:longint;const buf;size:longint):longint;
 Function fdWrite(fd:longint;const buf;size:longint):longint;
 begin
 begin
   fdWrite:=Sys_Write(fd,pchar(@buf),size);
   fdWrite:=Sys_Write(fd,pchar(@buf),size);
-  LinuxError:=Errno;
 end;
 end;
 
 
 
 
@@ -1074,7 +1177,7 @@ Function  fdSeek (fd,pos,seektype :longint): longint;
 }
 }
 begin
 begin
    fdseek:=Sys_LSeek (fd,pos,seektype);
    fdseek:=Sys_LSeek (fd,pos,seektype);
-   LinuxError:=Errno;
+   linuxerror:=fpgeterrno;
 end;
 end;
 
 
 {$ifdef BSD}
 {$ifdef BSD}
@@ -1093,7 +1196,7 @@ begin
      Linuxerror:=fpfcntl(fd,cmd,0);
      Linuxerror:=fpfcntl(fd,cmd,0);
      if linuxerror=-1 then
      if linuxerror=-1 then
       begin
       begin
-        linuxerror:=errno;
+        linuxerror:=fpgeterrno;
         fcntl:=0;
         fcntl:=0;
       end
       end
      else
      else
@@ -1123,7 +1226,7 @@ begin
   if (cmd in [F_SetFd,F_SetFl,F_GetLk,F_SetLk,F_SetLkw,F_SetOwn]) then
   if (cmd in [F_SetFd,F_SetFl,F_GetLk,F_SetLk,F_SetLkw,F_SetOwn]) then
    begin
    begin
      fpfcntl(fd,cmd,arg);
      fpfcntl(fd,cmd,arg);
-     LinuxError:=ErrNo;
+     linuxerror:=fpgeterrno;
    end
    end
   else
   else
    linuxerror:=ESyseinval;
    linuxerror:=ESyseinval;
@@ -1164,7 +1267,7 @@ Function FStat(Path:Pathstr;Var Info:stat):Boolean;
 begin
 begin
   path:=path+#0;
   path:=path+#0;
   FStat:=(Sys_stat(@(path[1]),Info)=0);
   FStat:=(Sys_stat(@(path[1]),Info)=0);
-  LinuxError:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -1196,7 +1299,7 @@ begin
   oldpath:=oldpath+#0;
   oldpath:=oldpath+#0;
   newpath:=newpath+#0;
   newpath:=newpath+#0;
   Symlink:=Sys_symlink(pchar(@(oldpath[1])),pchar(@(newpath[1])))=0;
   Symlink:=Sys_symlink(pchar(@(oldpath[1])),pchar(@(newpath[1])))=0;
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -1206,7 +1309,7 @@ Function ReadLink(name,linkname:pchar;maxlen:longint):longint;
 }
 }
 begin
 begin
   Readlink:=Sys_readlink(Name,LinkName,maxlen);
   Readlink:=Sys_readlink(Name,LinkName,maxlen);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -1238,7 +1341,7 @@ Function UnLink(Path:pathstr):boolean;
 begin
 begin
   path:=path+#0;
   path:=path+#0;
   Unlink:=Sys_unlink(pchar(@(path[1])))=0;
   Unlink:=Sys_unlink(pchar(@(path[1])))=0;
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -1249,14 +1352,14 @@ Function  UnLink(Path:pchar):Boolean;
 }
 }
 begin
 begin
   Unlink:=(Sys_unlink(path)=0);
   Unlink:=(Sys_unlink(path)=0);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
 Function  FRename (OldName,NewName : Pchar) : Boolean;
 Function  FRename (OldName,NewName : Pchar) : Boolean;
 begin
 begin
   FRename:=Sys_rename(OldName,NewName)=0;
   FRename:=Sys_rename(OldName,NewName)=0;
-  LinuxError:=Errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -1330,9 +1433,7 @@ begin
   Dup2:=Dup2(filerec(oldfile).handle,filerec(newfile).handle);
   Dup2:=Dup2(filerec(oldfile).handle,filerec(newfile).handle);
 end;
 end;
 
 
-
-
-Function  Select(N:longint;readfds,writefds,exceptfds:PFDSet;TimeOut:Longint):longint;
+Function  Select(N:longint;readfds,writefds,exceptfds:pfdset;TimeOut:Longint):longint;
 {
 {
   Select checks whether the file descriptor sets in readfs/writefs/exceptfs
   Select checks whether the file descriptor sets in readfs/writefs/exceptfs
   have changed.
   have changed.
@@ -1346,8 +1447,8 @@ begin
    p:=nil
    p:=nil
   else
   else
    begin
    begin
-     tv.Sec:=Timeout div 1000;
-     tv.Usec:=(Timeout mod 1000)*1000;
+     tv.tv_Sec:=Timeout div 1000;
+     tv.tv_Usec:=(Timeout mod 1000)*1000;
      p:=@tv;
      p:=@tv;
    end;
    end;
   Select:=Select(N,Readfds,WriteFds,ExceptFds,p);
   Select:=Select(N,Readfds,WriteFds,ExceptFds,p);
@@ -1357,7 +1458,7 @@ end;
 
 
 Function SelectText(var T:Text;TimeOut :PTimeval):Longint;
 Function SelectText(var T:Text;TimeOut :PTimeval):Longint;
 Var
 Var
-  F:FDSet;
+  F:tfdset;
 begin
 begin
   if textrec(t).mode=fmclosed then
   if textrec(t).mode=fmclosed then
    begin
    begin
@@ -1382,8 +1483,8 @@ begin
    p:=nil
    p:=nil
   else
   else
    begin
    begin
-     tv.Sec:=Timeout div 1000;
-     tv.Usec:=(Timeout mod 1000)*1000;
+     tv.tv_Sec:=Timeout div 1000;
+     tv.tv_Usec:=(Timeout mod 1000)*1000;
      p:=@tv;
      p:=@tv;
    end;
    end;
   SelectText:=SelectText(T,p);
   SelectText:=SelectText(T,p);
@@ -1398,7 +1499,7 @@ Function OpenDir(F:String):PDir;
 begin
 begin
   F:=F+#0;
   F:=F+#0;
   OpenDir:=OpenDir(@F[1]);
   OpenDir:=OpenDir(@F[1]);
-  LinuxError:=ErrNo;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -1406,17 +1507,16 @@ procedure SeekDir(p:pdir;off:longint);
 begin
 begin
   if p=nil then
   if p=nil then
    begin
    begin
-     errno:=ESysEBadf;
+     fpseterrno(ESysEBadf);
      exit;
      exit;
    end;
    end;
- {$ifndef bsd}                          {Should be ifdef Linux, but can't because
-                                                of 1.0.5 cycle}
+ {$ifndef bsd}                         
   {$ifndef Solaris}
   {$ifndef Solaris}
-  p^.nextoff:=Sys_lseek(p^.fd,off,seek_set);
+  p^.dd_nextoff:=Sys_lseek(p^.dd_fd,off,seek_set);
   {$endif}
   {$endif}
  {$endif}
  {$endif}
-  p^.size:=0;
-  p^.loc:=0;
+  p^.dd_size:=0;
+  p^.dd_loc:=0;
 end;
 end;
 
 
 
 
@@ -1424,11 +1524,11 @@ function TellDir(p:pdir):longint;
 begin
 begin
   if p=nil then
   if p=nil then
    begin
    begin
-     errno:=ESysEBadf;
+     fpseterrno(ESysEBadf);
      telldir:=-1;
      telldir:=-1;
      exit;
      exit;
    end;
    end;
-  telldir:=Sys_lseek(p^.fd,0,seek_cur)
+  telldir:=Sys_lseek(p^.dd_fd,0,seek_cur)
   { We could try to use the nextoff field here, but on my 1.2.13
   { We could try to use the nextoff field here, but on my 1.2.13
     kernel, this gives nothing... This may have to do with
     kernel, this gives nothing... This may have to do with
     the readdir implementation of libc... I also didn't find any trace of
     the readdir implementation of libc... I also didn't find any trace of
@@ -1441,7 +1541,7 @@ end;
 Function ReadDir(P:pdir):pdirent;
 Function ReadDir(P:pdir):pdirent;
 begin
 begin
   ReadDir:=Sys_ReadDir(p);
   ReadDir:=Sys_ReadDir(p);
-  LinuxError:=Errno;
+  linuxerror:=fpgeterrno;
 end;
 end;
 
 
 
 
@@ -1943,11 +2043,11 @@ Var
   Sysn : utsname;
   Sysn : utsname;
 begin
 begin
   Uname(Sysn);
   Uname(Sysn);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
   If linuxerror<>0 then
   If linuxerror<>0 then
    getdomainname:=''
    getdomainname:=''
   else
   else
-   getdomainname:=strpas(@Sysn.domainname[0]);
+   getdomainname:=strpas(@Sysn.domain[0]);
 end;
 end;
 
 
 
 
@@ -1960,7 +2060,7 @@ Var
   Sysn : utsname;
   Sysn : utsname;
 begin
 begin
   uname(Sysn);
   uname(Sysn);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
   If linuxerror<>0 then
   If linuxerror<>0 then
    gethostname:=''
    gethostname:=''
   else
   else
@@ -2011,7 +2111,7 @@ begin
   {$endif}
   {$endif}
   else
   else
    begin
    begin
-     ErrNo:=ESysEINVAL;
+     fpsetErrNo(ESysEINVAL);
      TCSetAttr:=false;
      TCSetAttr:=false;
      exit;
      exit;
    end;
    end;
@@ -2178,15 +2278,15 @@ var
     d:=Readdir(dirstream);
     d:=Readdir(dirstream);
     while (d<>nil) do
     while (d<>nil) do
      begin
      begin
-       name:=n+'/'+strpas(@(d^.name));
+       name:=n+'/'+strpas(@(d^.d_name));
        fstat(name,st);
        fstat(name,st);
        if linuxerror=0 then
        if linuxerror=0 then
         begin
         begin
           if ((st.mode and $E000)=$4000) and  { if it is a directory }
           if ((st.mode and $E000)=$4000) and  { if it is a directory }
-             (strpas(@(d^.name))<>'.') and    { but not ., .. and fd subdirs }
-             (strpas(@(d^.name))<>'..') and
-             (strpas(@(d^.name))<>'') and
-             (strpas(@(d^.name))<>'fd') then
+             (strpas(@(d^.d_name))<>'.') and    { but not ., .. and fd subdirs }
+             (strpas(@(d^.d_name))<>'..') and
+             (strpas(@(d^.d_name))<>'') and
+             (strpas(@(d^.d_name))<>'fd') then
            begin                      {we found a directory, search inside it}
            begin                      {we found a directory, search inside it}
              if mysearch(name) then
              if mysearch(name) then
               begin                 {the device is here}
               begin                 {the device is here}
@@ -2195,7 +2295,7 @@ var
                 exit;
                 exit;
               end;
               end;
            end
            end
-          else if (d^.ino=myino) and (st.dev=mydev) then
+          else if (d^.d_fileno=myino) and (st.st_dev=mydev) then
            begin
            begin
              closedir(dirstream);
              closedir(dirstream);
              ttyname:=name;
              ttyname:=name;
@@ -2212,7 +2312,7 @@ var
 begin
 begin
   TTYName:='';
   TTYName:='';
   fstat(handle,st);
   fstat(handle,st);
-  if (errno<>0) and isatty (handle) then
+  if (fpgeterrno<>0) and isatty (handle) then
    exit;
    exit;
   mydev:=st.dev;
   mydev:=st.dev;
   myino:=st.ino;
   myino:=st.ino;
@@ -2554,13 +2654,13 @@ begin
   if thedir=nil then
   if thedir=nil then
    begin
    begin
      glob:=nil;
      glob:=nil;
-     linuxerror:=errno;
+     linuxerror:=fpgeterrno;
      exit;
      exit;
    end;
    end;
   temp:=basename(path,''); { get the pattern }
   temp:=basename(path,''); { get the pattern }
-  if thedir^.fd<0 then
+  if thedir^.dd_fd<0 then
    begin
    begin
-     linuxerror:=errno;
+     linuxerror:=fpgeterrno;
      glob:=nil;
      glob:=nil;
      exit;
      exit;
    end;
    end;
@@ -2571,7 +2671,7 @@ begin
     buffer:=Sys_readdir(thedir);
     buffer:=Sys_readdir(thedir);
     if buffer=nil then
     if buffer=nil then
      break;
      break;
-    temp2:=strpas(@(buffer^.name[0]));
+    temp2:=strpas(@(buffer^.d_name[0]));
     if fnmatch(temp,temp2) then
     if fnmatch(temp,temp2) then
      begin
      begin
        if root=nil then
        if root=nil then
@@ -2598,7 +2698,7 @@ begin
           globfree(root);
           globfree(root);
           break;
           break;
         end;
         end;
-       move(buffer^.name[0],current^.name^,length(temp2)+1);
+       move(buffer^.d_name[0],current^.name^,length(temp2)+1);
      end;
      end;
   until false;
   until false;
   closedir(thedir);
   closedir(thedir);
@@ -2610,17 +2710,17 @@ end;
       FiledescriptorSets
       FiledescriptorSets
 --------------------------------}
 --------------------------------}
 
 
-Procedure FD_Zero(var fds:fdSet);
+Procedure FD_Zero(var fds:tfdset);
 {
 {
   Clear the set of filedescriptors
   Clear the set of filedescriptors
 }
 }
 begin
 begin
-  FillChar(fds,sizeof(fdSet),0);
+  FillChar(fds,sizeof(tfdset),0);
 end;
 end;
 
 
 
 
 
 
-Procedure FD_Clr(fd:longint;var fds:fdSet);
+Procedure FD_Clr(fd:longint;var fds:tfdset);
 {
 {
   Remove fd from the set of filedescriptors
   Remove fd from the set of filedescriptors
 }
 }
@@ -2630,7 +2730,7 @@ end;
 
 
 
 
 
 
-Procedure FD_Set(fd:longint;var fds:fdSet);
+Procedure FD_Set(fd:longint;var fds:tfdset);
 {
 {
   Add fd to the set of filedescriptors
   Add fd to the set of filedescriptors
 }
 }
@@ -2640,7 +2740,7 @@ end;
 
 
 
 
 
 
-Function FD_IsSet(fd:longint;var fds:fdSet):boolean;
+Function FD_IsSet(fd:longint;var fds:tfdset):boolean;
 {
 {
   Test if fd is part of the set of filedescriptors
   Test if fd is part of the set of filedescriptors
 }
 }
@@ -3032,7 +3132,10 @@ End.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.30  2003-05-30 19:58:40  marco
+  Revision 1.31  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.30  2003/05/30 19:58:40  marco
    * Getting NetBSD/i386 to compile.
    * Getting NetBSD/i386 to compile.
 
 
   Revision 1.29  2003/05/30 19:37:14  marco
   Revision 1.29  2003/05/30 19:37:14  marco

+ 13 - 10
rtl/unix/mouse.pp

@@ -26,7 +26,7 @@ interface
 implementation
 implementation
 
 
 uses
 uses
-  Unix,Video
+  BaseUnix,Video
 {$ifndef NOGPM}
 {$ifndef NOGPM}
   ,gpm
   ,gpm
 {$endif ndef NOGPM}
 {$endif ndef NOGPM}
@@ -129,7 +129,7 @@ begin
       connect.MinMod:=0;
       connect.MinMod:=0;
       connect.MaxMod:=0;
       connect.MaxMod:=0;
       gpm_fs:=Gpm_Open(connect,0);
       gpm_fs:=Gpm_Open(connect,0);
-      if (gpm_fs=-2) and (getenv('TERM')<>'xterm') then
+      if (gpm_fs=-2) and (fpgetenv('TERM')<>'xterm') then
         begin
         begin
           gpm_fs:=-1;
           gpm_fs:=-1;
           Gpm_Close;
           Gpm_Close;
@@ -145,7 +145,7 @@ begin
   if gpm_fs<>-1 then
   if gpm_fs<>-1 then
     ShowMouse;
     ShowMouse;
 {$else ifdef NOGPM}
 {$else ifdef NOGPM}
-      if (getenv('TERM')='xterm') then
+      if (fpgetenv('TERM')='xterm') then
         begin
         begin
           gpm_fs:=-2;
           gpm_fs:=-2;
           Write(#27'[?1001s'); { save old hilit tracking }
           Write(#27'[?1001s'); { save old hilit tracking }
@@ -187,7 +187,7 @@ begin
       connect.MinMod:=0;
       connect.MinMod:=0;
       connect.MaxMod:=0;
       connect.MaxMod:=0;
       gpm_fs:=Gpm_Open(connect,0);
       gpm_fs:=Gpm_Open(connect,0);
-      if (gpm_fs=-2) and (getenv('TERM')<>'xterm') then
+      if (gpm_fs=-2) and (fpgetenv('TERM')<>'xterm') then
         begin
         begin
           Gpm_Close;
           Gpm_Close;
           gpm_fs:=-1;
           gpm_fs:=-1;
@@ -206,7 +206,7 @@ begin
   else
   else
     SysDetectMouse:=0;
     SysDetectMouse:=0;
 {$else ifdef NOGPM}
 {$else ifdef NOGPM}
-  if (getenv('TERM')='xterm') then
+  if (fpgetenv('TERM')='xterm') then
     SysDetectMouse:=2;
     SysDetectMouse:=2;
 {$endif NOGPM}
 {$endif NOGPM}
 end;
 end;
@@ -335,7 +335,7 @@ function SysPollMouseEvent(var MouseEvent: TMouseEvent):boolean;
 {$ifndef NOGPM}
 {$ifndef NOGPM}
 var
 var
   e : TGPMEvent;
   e : TGPMEvent;
-  fds : FDSet;
+  fds : tFDSet;
 {$endif ndef NOGPM}
 {$endif ndef NOGPM}
 begin
 begin
   fillchar(MouseEvent,SizeOf(TMouseEvent),#0);
   fillchar(MouseEvent,SizeOf(TMouseEvent),#0);
@@ -344,10 +344,10 @@ begin
    exit(false);
    exit(false);
   if gpm_fs>0 then
   if gpm_fs>0 then
     begin
     begin
-      FD_Zero(fds);
-      FD_Set(gpm_fs,fds);
+      fpfdemptyset(fds);
+      fpFDaddset(fds,gpm_fs);
     end;
     end;
-  if (Select(gpm_fs+1,@fds,nil,nil,1)>0) then
+  if (fpSelect(gpm_fs+1,@fds,nil,nil,1)>0) then
    begin
    begin
      FillChar(e,SizeOf(e),#0);
      FillChar(e,SizeOf(e),#0);
      { Gpm_snapshot does not work here PM }
      { Gpm_snapshot does not work here PM }
@@ -418,7 +418,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.9  2002-10-14 18:37:15  peter
+  Revision 1.10  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.9  2002/10/14 18:37:15  peter
     * use Unix unit
     * use Unix unit
 
 
   Revision 1.8  2002/09/15 17:52:30  peter
   Revision 1.8  2002/09/15 17:52:30  peter

+ 14 - 11
rtl/unix/printer.pp

@@ -61,7 +61,7 @@ Procedure AssignLst ( Var F : text; ToFile : string);
 }
 }
 
 
 Implementation
 Implementation
-Uses Unix,Strings;
+Uses Unix,BaseUnix,Strings;
 
 
 {
 {
   include definition of textrec
   include definition of textrec
@@ -87,7 +87,7 @@ begin
   f:=f+#0;
   f:=f+#0;
   if lpr='' then
   if lpr='' then
    exit;
    exit;
-  i:=Fork;
+  i:=fpFork;
   if i<0 then
   if i<0 then
    exit; { No printing was done. We leave the file where it is.}
    exit; { No printing was done. We leave the file where it is.}
   if i=0 then
   if i=0 then
@@ -102,18 +102,18 @@ begin
      pp^:=@f[1];
      pp^:=@f[1];
      inc(pp);
      inc(pp);
      pp^:=nil;
      pp^:=nil;
-     Execve(lpr,p,envp);
+     fpExecve(lpr,p,envp);
      { In trouble here ! }
      { In trouble here ! }
      halt(128)
      halt(128)
    end
    end
   else
   else
    begin
    begin
    { We're in the parent. }
    { We're in the parent. }
-     waitpid (i,@j,0);
+     fpwaitpid (i,j,0);
      if j<>0 then
      if j<>0 then
       exit;
       exit;
    { Erase the file }
    { Erase the file }
-     Unlink(f);
+     fpUnlink(f);
    end;
    end;
 end;
 end;
 
 
@@ -136,7 +136,7 @@ begin
  If textrec(f).mode <> fmoutput then
  If textrec(f).mode <> fmoutput then
   exit;
   exit;
  textrec(f).userdata[15]:=0; { set Zero length flag }
  textrec(f).userdata[15]:=0; { set Zero length flag }
- i:=fdOpen(StrPas(textrec(f).name),(Open_WrOnly or Open_Creat), 438);
+ i:=fpOpen(StrPas(textrec(f).name),(Open_WrOnly or Open_Creat), 438);
  if i<0 then
  if i<0 then
   textrec(f).mode:=fmclosed
   textrec(f).mode:=fmclosed
  else
  else
@@ -150,11 +150,11 @@ begin
 {$IFDEF PRINTERDEBUG}
 {$IFDEF PRINTERDEBUG}
   writeln ('Printer : In CloseLstFile');
   writeln ('Printer : In CloseLstFile');
 {$ENDIF}
 {$ENDIF}
-  fdclose (textrec(f).handle);
+  fpclose (textrec(f).handle);
 { In case length is zero, don't print : lpr would give an error }
 { In case length is zero, don't print : lpr would give an error }
   if (textrec(f).userdata[15]=0) and (textrec(f).userdata[16]=P_TOF) then
   if (textrec(f).userdata[15]=0) and (textrec(f).userdata[16]=P_TOF) then
    begin
    begin
-     Unlink(StrPas(textrec(f).name));
+     fpUnlink(StrPas(textrec(f).name));
      exit
      exit
    end;
    end;
 { Non empty : needs printing ? }
 { Non empty : needs printing ? }
@@ -174,7 +174,7 @@ begin
    exit;
    exit;
   if textrec(f).bufpos<>0 then
   if textrec(f).bufpos<>0 then
    textrec(f).userdata[15]:=1; { Set it is not empty. Important when closing !!}
    textrec(f).userdata[15]:=1; { Set it is not empty. Important when closing !!}
-  fdwrite(textrec(f).handle,textrec(f).bufptr^,textrec(f).bufpos);
+  fpwrite(textrec(f).handle,textrec(f).bufptr^,textrec(f).bufpos);
   textrec(f).bufpos:=0;
   textrec(f).bufpos:=0;
 end;
 end;
 
 
@@ -189,7 +189,7 @@ begin
   if i=0 then
   if i=0 then
    exit;
    exit;
   delete (s,i,3);
   delete (s,i,3);
-  str(GetPid,temp);
+  str(fpGetPid,temp);
   insert(temp,s,i);
   insert(temp,s,i);
 {$IFDEF PRINTERDEBUG}
 {$IFDEF PRINTERDEBUG}
   writeln ('Print : Filename became : ',s);
   writeln ('Print : Filename became : ',s);
@@ -254,7 +254,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2002-09-07 16:01:27  peter
+  Revision 1.5  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.4  2002/09/07 16:01:27  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
 }
 }

+ 20 - 17
rtl/unix/serial.pp

@@ -10,7 +10,7 @@ unit Serial;
 
 
 interface
 interface
 
 
-uses Unix;
+uses BaseUnix,Unix;
 
 
 type
 type
 
 
@@ -70,12 +70,12 @@ implementation
 
 
 function SerOpen(const DeviceName: String): TSerialHandle;
 function SerOpen(const DeviceName: String): TSerialHandle;
 begin
 begin
-  Result := fdOpen(DeviceName, OPEN_RDWR or OPEN_NOCTTY);
+  Result := fpopen(DeviceName, OPEN_RDWR or OPEN_NOCTTY);
 end;
 end;
 
 
 procedure SerClose(Handle: TSerialHandle);
 procedure SerClose(Handle: TSerialHandle);
 begin
 begin
-  fdClose(Handle);
+  fpClose(Handle);
 end;
 end;
 
 
 procedure SerFlush(Handle: TSerialHandle);
 procedure SerFlush(Handle: TSerialHandle);
@@ -85,12 +85,12 @@ end;
 
 
 function SerRead(Handle: TSerialHandle; var Buffer; Count: LongInt): LongInt;
 function SerRead(Handle: TSerialHandle; var Buffer; Count: LongInt): LongInt;
 begin
 begin
-  Result := fdRead(Handle, Buffer, Count);
+  Result := fpRead(Handle, Buffer, Count);
 end;
 end;
 
 
 function SerWrite(Handle: TSerialHandle; var Buffer; Count: LongInt): LongInt;
 function SerWrite(Handle: TSerialHandle; var Buffer; Count: LongInt): LongInt;
 begin
 begin
-  Result := fdWrite(Handle, Buffer, Count);
+  Result := fpWrite(Handle, Buffer, Count);
 end;
 end;
 
 
 procedure SerSetParams(Handle: TSerialHandle; BitsPerSec: LongInt;
 procedure SerSetParams(Handle: TSerialHandle; BitsPerSec: LongInt;
@@ -153,17 +153,17 @@ end;
 
 
 function SerSaveState(Handle: TSerialHandle): TSerialState;
 function SerSaveState(Handle: TSerialHandle): TSerialState;
 begin
 begin
-  ioctl(Handle, TIOCMGET, @Result.LineState);
-//  ioctl(Handle, TCGETS, @Result.tios);
+  fpioctl(Handle, TIOCMGET, @Result.LineState);
+//  fpioctl(Handle, TCGETS, @Result.tios);
   TcGetAttr(handle,result.tios);
   TcGetAttr(handle,result.tios);
 
 
 end;
 end;
 
 
 procedure SerRestoreState(Handle: TSerialHandle; State: TSerialState);
 procedure SerRestoreState(Handle: TSerialHandle; State: TSerialState);
 begin
 begin
-//  ioctl(Handle, TCSETS, @State.tios);
+//  fpioctl(Handle, TCSETS, @State.tios);
     TCSetAttr(handle,TCSANOW,State.tios);
     TCSetAttr(handle,TCSANOW,State.tios);
-    ioctl(Handle, TIOCMSET, @State.LineState);
+    fpioctl(Handle, TIOCMSET, @State.LineState);
 end;
 end;
 
 
 procedure SerSetDTR(Handle: TSerialHandle; State: Boolean);
 procedure SerSetDTR(Handle: TSerialHandle; State: Boolean);
@@ -171,9 +171,9 @@ const
   DTR: Cardinal = TIOCM_DTR;
   DTR: Cardinal = TIOCM_DTR;
 begin
 begin
   if State then
   if State then
-    ioctl(Handle, TIOCMBIS, @DTR)
+    fpioctl(Handle, TIOCMBIS, @DTR)
   else
   else
-    ioctl(Handle, TIOCMBIC, @DTR);
+    fpioctl(Handle, TIOCMBIC, @DTR);
 end;
 end;
 
 
 procedure SerSetRTS(Handle: TSerialHandle; State: Boolean);
 procedure SerSetRTS(Handle: TSerialHandle; State: Boolean);
@@ -181,16 +181,16 @@ const
   RTS: Cardinal = TIOCM_RTS;
   RTS: Cardinal = TIOCM_RTS;
 begin
 begin
   if State then
   if State then
-    ioctl(Handle, TIOCMBIS, @RTS)
+    fpioctl(Handle, TIOCMBIS, @RTS)
   else
   else
-    ioctl(Handle, TIOCMBIC, @RTS);
+    fpioctl(Handle, TIOCMBIC, @RTS);
 end;
 end;
 
 
 function SerGetCTS(Handle: TSerialHandle): Boolean;
 function SerGetCTS(Handle: TSerialHandle): Boolean;
 var
 var
   Flags: Cardinal;
   Flags: Cardinal;
 begin
 begin
-  ioctl(Handle, TIOCMGET, @Flags);
+  fpioctl(Handle, TIOCMGET, @Flags);
   Result := (Flags and TIOCM_CTS) <> 0;
   Result := (Flags and TIOCM_CTS) <> 0;
 end;
 end;
 
 
@@ -198,7 +198,7 @@ function SerGetDSR(Handle: TSerialHandle): Boolean;
 var
 var
   Flags: Cardinal;
   Flags: Cardinal;
 begin
 begin
-  ioctl(Handle, TIOCMGET, @Flags);
+  fpioctl(Handle, TIOCMGET, @Flags);
   Result := (Flags and TIOCM_DSR) <> 0;
   Result := (Flags and TIOCM_DSR) <> 0;
 end;
 end;
 
 
@@ -206,7 +206,7 @@ function SerGetRI(Handle: TSerialHandle): Boolean;
 var
 var
   Flags: Cardinal;
   Flags: Cardinal;
 begin
 begin
-  ioctl(Handle, TIOCMGET, @Flags);
+  fpioctl(Handle, TIOCMGET, @Flags);
   Result := (Flags and TIOCM_RI) <> 0;
   Result := (Flags and TIOCM_RI) <> 0;
 end;
 end;
 
 
@@ -215,7 +215,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2002-09-07 16:01:27  peter
+  Revision 1.8  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.7  2002/09/07 16:01:27  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
   Revision 1.6  2002/08/06 13:31:50  sg
   Revision 1.6  2002/08/06 13:31:50  sg

+ 5 - 3
rtl/unix/sockets.pp

@@ -134,12 +134,11 @@ Function Accept(Sock:longint;var addr:string;var SockIn,SockOut:File):Boolean;
 
 
 Implementation
 Implementation
 
 
-Uses Unix;
+Uses BaseUnix,SysCall;
 
 
 { Include filerec and textrec structures }
 { Include filerec and textrec structures }
 {$i filerec.inc}
 {$i filerec.inc}
 {$i textrec.inc}
 {$i textrec.inc}
-
 {******************************************************************************
 {******************************************************************************
                           Kernel Socket Callings
                           Kernel Socket Callings
 ******************************************************************************}
 ******************************************************************************}
@@ -152,7 +151,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2002-09-07 16:01:27  peter
+  Revision 1.7  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.6  2002/09/07 16:01:27  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
 }
 }

+ 14 - 4
rtl/unix/systhrds.pp

@@ -45,9 +45,13 @@ interface
 
 
 implementation
 implementation
 
 
+Uses BaseUnix;
+
 {*****************************************************************************
 {*****************************************************************************
                              Generic overloaded
                              Generic overloaded
 *****************************************************************************}
 *****************************************************************************}
+{$i ostypes.inc}
+{$i ossysch.inc}
 
 
 { Include generic overloaded routines }
 { Include generic overloaded routines }
 {$i thread.inc}
 {$i thread.inc}
@@ -106,6 +110,7 @@ const
   MAP_PRIVATE   =2;
   MAP_PRIVATE   =2;
   MAP_ANONYMOUS =$20;
   MAP_ANONYMOUS =$20;
 
 
+{
 type
 type
   SysCallRegs=record
   SysCallRegs=record
     reg1,reg2,reg3,reg4,reg5,reg6 : longint;
     reg1,reg2,reg3,reg4,reg5,reg6 : longint;
@@ -149,7 +154,7 @@ begin
   t.reg3:=len;
   t.reg3:=len;
   Fpmunmap:=syscall(syscall_nr_munmap,t);
   Fpmunmap:=syscall(syscall_nr_munmap,t);
 end;
 end;
-
+}
 {$else}
 {$else}
 CONST
 CONST
   { Constansts for MMAP. These are still private for *BSD }
   { Constansts for MMAP. These are still private for *BSD }
@@ -157,9 +162,7 @@ CONST
   MAP_ANONYMOUS =$1000;
   MAP_ANONYMOUS =$1000;
 
 
   // include some non posix internal types.
   // include some non posix internal types.
-  {$i ostypes.inc}
   // *BSD POSIX. Include headers to syscalls.
   // *BSD POSIX. Include headers to syscalls.
-  {$I ossysch.inc}
 
 
 {$endif}
 {$endif}
 
 
@@ -203,7 +206,11 @@ CONST
 
 
     procedure SysReleaseThreadVars;
     procedure SysReleaseThreadVars;
       begin
       begin
+	{$ifdef ver1_0}
         Fpmunmap(longint(pthread_getspecific(tlskey)),threadvarblocksize);
         Fpmunmap(longint(pthread_getspecific(tlskey)),threadvarblocksize);
+	{$else}
+        Fpmunmap(pointer(pthread_getspecific(tlskey)),threadvarblocksize);
+	{$endif}
       end;
       end;
 
 
 { Include OS independent Threadvar initialization }
 { Include OS independent Threadvar initialization }
@@ -425,7 +432,10 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.8  2003-03-27 17:14:27  armin
+  Revision 1.9  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.8  2003/03/27 17:14:27  armin
   * more platform independent thread routines, needs to be implemented for unix
   * more platform independent thread routines, needs to be implemented for unix
 
 
   Revision 1.7  2003/01/05 19:11:32  marco
   Revision 1.7  2003/01/05 19:11:32  marco

+ 32 - 27
rtl/unix/sysutils.pp

@@ -33,6 +33,8 @@ type
 
 
 implementation
 implementation
 
 
+Uses Baseunix;
+
 { Include platform independent implementation part }
 { Include platform independent implementation part }
 {$i sysutils.inc}
 {$i sysutils.inc}
 
 
@@ -52,7 +54,7 @@ BEGIN
     1 : LinuxFlags:=LinuxFlags or Open_WrOnly;
     1 : LinuxFlags:=LinuxFlags or Open_WrOnly;
     2 : LinuxFlags:=LinuxFlags or Open_RdWr;
     2 : LinuxFlags:=LinuxFlags or Open_RdWr;
   end;
   end;
-  FileOpen:=fdOpen (FileName,LinuxFlags);
+  FileOpen:=fpOpen (FileName,LinuxFlags);
   //!! We need to set locking based on Mode !!
   //!! We need to set locking based on Mode !!
 end;
 end;
 
 
@@ -60,7 +62,7 @@ end;
 Function FileCreate (Const FileName : String) : Longint;
 Function FileCreate (Const FileName : String) : Longint;
 
 
 begin
 begin
-  FileCreate:=fdOpen(FileName,Open_RdWr or Open_Creat or Open_Trunc);
+  FileCreate:=fpOpen(FileName,Open_RdWr or Open_Creat or Open_Trunc);
 end;
 end;
 
 
 
 
@@ -75,28 +77,28 @@ BEGIN
     1 : LinuxFlags:=LinuxFlags or Open_WrOnly;
     1 : LinuxFlags:=LinuxFlags or Open_WrOnly;
     2 : LinuxFlags:=LinuxFlags or Open_RdWr;
     2 : LinuxFlags:=LinuxFlags or Open_RdWr;
   end;
   end;
-  FileCreate:=fdOpen(FileName,LinuxFlags or Open_Creat or Open_Trunc);
+  FileCreate:=fpOpen(FileName,LinuxFlags or Open_Creat or Open_Trunc);
 end;
 end;
 
 
 
 
 Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint;
 Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint;
 
 
 begin
 begin
-  FileRead:=fdRead (Handle,Buffer,Count);
+  FileRead:=fpRead (Handle,Buffer,Count);
 end;
 end;
 
 
 
 
 Function FileWrite (Handle : Longint; const Buffer; Count : Longint) : Longint;
 Function FileWrite (Handle : Longint; const Buffer; Count : Longint) : Longint;
 
 
 begin
 begin
-  FileWrite:=fdWrite (Handle,Buffer,Count);
+  FileWrite:=fpWrite (Handle,Buffer,Count);
 end;
 end;
 
 
 
 
 Function FileSeek (Handle,FOffset,Origin : Longint) : Longint;
 Function FileSeek (Handle,FOffset,Origin : Longint) : Longint;
 
 
 begin
 begin
-  FileSeek:=fdSeek (Handle,FOffset,Origin);
+  FileSeek:=fplSeek (Handle,FOffset,Origin);
 end;
 end;
 
 
 
 
@@ -104,20 +106,20 @@ Function FileSeek (Handle : Longint; FOffset,Origin : Int64) : Int64;
 
 
 begin
 begin
   {$warning need to add 64bit call }
   {$warning need to add 64bit call }
-  FileSeek:=fdSeek (Handle,FOffset,Origin);
+  FileSeek:=fplSeek (Handle,FOffset,Origin);
 end;
 end;
 
 
 
 
 Procedure FileClose (Handle : Longint);
 Procedure FileClose (Handle : Longint);
 
 
 begin
 begin
-  fdclose(Handle);
+  fpclose(Handle);
 end;
 end;
 
 
 Function FileTruncate (Handle,Size: Longint) : boolean;
 Function FileTruncate (Handle,Size: Longint) : boolean;
 
 
 begin
 begin
-  FileTruncate:=fdtruncate(Handle,Size);
+  FileTruncate:=fpftruncate(Handle,Size)>=0;
 end;
 end;
 
 
 Function FileAge (Const FileName : String): Longint;
 Function FileAge (Const FileName : String): Longint;
@@ -126,11 +128,11 @@ Var Info : Stat;
     Y,M,D,hh,mm,ss : word;
     Y,M,D,hh,mm,ss : word;
 
 
 begin
 begin
-  If not fstat (FileName,Info) then
+  If  fpstat (FileName,Info)<0 then
     exit(-1)
     exit(-1)
   else
   else
     begin
     begin
-    EpochToLocal(info.mtime,y,m,d,hh,mm,ss);
+    EpochToLocal(info.st_mtime,y,m,d,hh,mm,ss);
     Result:=DateTimeToFileDate(EncodeDate(y,m,d)+EncodeTime(hh,mm,ss,0));
     Result:=DateTimeToFileDate(EncodeDate(y,m,d)+EncodeTime(hh,mm,ss,0));
     end;
     end;
 end;
 end;
@@ -141,7 +143,7 @@ Function FileExists (Const FileName : String) : Boolean;
 Var Info : Stat;
 Var Info : Stat;
 
 
 begin
 begin
-  FileExists:=fstat(filename,Info);
+  FileExists:=fpstat(filename,Info)>=0;
 end;
 end;
 
 
 
 
@@ -150,8 +152,8 @@ Function DirectoryExists (Const Directory : String) : Boolean;
 Var Info : Stat;
 Var Info : Stat;
 
 
 begin
 begin
-  DirectoryExists:=fstat(Directory,Info) and
-                   ((info.mode and STAT_IFMT)=STAT_IFDIR);
+  DirectoryExists:=(fpstat(Directory,Info)>=0) and
+                   ((info.st_mode and STAT_IFMT)=STAT_IFDIR);
 end;
 end;
 
 
 
 
@@ -159,13 +161,13 @@ Function LinuxToWinAttr (FN : Pchar; Const Info : Stat) : Longint;
 
 
 begin
 begin
   Result:=faArchive;
   Result:=faArchive;
-  If (Info.Mode and STAT_IFDIR)=STAT_IFDIR then
+  If (Info.st_Mode and STAT_IFDIR)=STAT_IFDIR then
     Result:=Result or faDirectory;
     Result:=Result or faDirectory;
   If (FN[0]='.') and (not (FN[1] in [#0,'.']))  then
   If (FN[0]='.') and (not (FN[1] in [#0,'.']))  then
     Result:=Result or faHidden;
     Result:=Result or faHidden;
-  If (Info.Mode and STAT_IWUSR)=0 Then
+  If (Info.st_Mode and STAT_IWUSR)=0 Then
      Result:=Result or faReadOnly;
      Result:=Result or faReadOnly;
-  If (Info.Mode and
+  If (Info.st_Mode and
       (STAT_IFSOCK or STAT_IFBLK or STAT_IFCHR or STAT_IFIFO))<>0 then
       (STAT_IFSOCK or STAT_IFBLK or STAT_IFCHR or STAT_IFIFO))<>0 then
      Result:=Result or faSysFile;
      Result:=Result or faSysFile;
 end;
 end;
@@ -196,7 +198,7 @@ begin
   If Result then
   If Result then
     begin
     begin
     GlobSearchRec^.GlobHandle:=P^.Next;
     GlobSearchRec^.GlobHandle:=P^.Next;
-    Result:=Fstat(GlobSearchRec^.Path+StrPas(p^.name),SInfo);
+    Result:=Fpstat(GlobSearchRec^.Path+StrPas(p^.name),SInfo)>=0;
     If Result then
     If Result then
       begin
       begin
       Info.Attr:=LinuxToWinAttr(p^.name,SInfo);
       Info.Attr:=LinuxToWinAttr(p^.name,SInfo);
@@ -207,8 +209,8 @@ begin
            Attr:=Info.Attr;
            Attr:=Info.Attr;
            If P^.Name<>Nil then
            If P^.Name<>Nil then
            Name:=strpas(p^.name);
            Name:=strpas(p^.name);
-           Time:=Sinfo.mtime;
-           Size:=Sinfo.Size;
+           Time:=Sinfo.st_mtime;
+           Size:=Sinfo.st_Size;
            end;
            end;
       end;
       end;
     P^.Next:=Nil;
     P^.Next:=Nil;
@@ -270,10 +272,10 @@ Function FileGetDate (Handle : Longint) : Longint;
 Var Info : Stat;
 Var Info : Stat;
 
 
 begin
 begin
-  If Not(FStat(Handle,Info)) then
+  If (fpFStat(Handle,Info))<0 then
     Result:=-1
     Result:=-1
   else
   else
-    Result:=Info.Mtime;
+    Result:=Info.st_Mtime;
 end;
 end;
 
 
 
 
@@ -290,7 +292,7 @@ Function FileGetAttr (Const FileName : String) : Longint;
 Var Info : Stat;
 Var Info : Stat;
 
 
 begin
 begin
-  If Not FStat (FileName,Info) then
+  If  FpStat (FileName,Info)<0 then
     Result:=-1
     Result:=-1
   Else
   Else
     Result:=LinuxToWinAttr(Pchar(FileName),Info);
     Result:=LinuxToWinAttr(Pchar(FileName),Info);
@@ -307,14 +309,14 @@ end;
 Function DeleteFile (Const FileName : String) : Boolean;
 Function DeleteFile (Const FileName : String) : Boolean;
 
 
 begin
 begin
-  Result:=UnLink (FileName);
+  Result:=fpUnLink (FileName)>=0;
 end;
 end;
 
 
 
 
 Function RenameFile (Const OldName, NewName : String) : Boolean;
 Function RenameFile (Const OldName, NewName : String) : Boolean;
 
 
 begin
 begin
-  RenameFile:=Unix.FRename(OldNAme,NewName);
+  RenameFile:=BaseUnix.FpRename(OldNAme,NewName)>=0;
 end;
 end;
 
 
 
 
@@ -477,7 +479,7 @@ end;
 Function GetEnvironmentVariable(Const EnvVar : String) : String;
 Function GetEnvironmentVariable(Const EnvVar : String) : String;
 
 
 begin
 begin
-  Result:=StrPas(Unix.Getenv(PChar(EnvVar)));
+  Result:=StrPas(BaseUnix.FPGetenv(PChar(EnvVar)));
 end;
 end;
 
 
 
 
@@ -494,7 +496,10 @@ end.
 {
 {
 
 
   $Log$
   $Log$
-  Revision 1.18  2003-04-01 15:57:41  peter
+  Revision 1.19  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.18  2003/04/01 15:57:41  peter
     * made THandle platform dependent and unique type
     * made THandle platform dependent and unique type
 
 
   Revision 1.17  2003/03/30 10:38:00  armin
   Revision 1.17  2003/03/30 10:38:00  armin

+ 6 - 3
rtl/unix/terminfo.pp

@@ -642,7 +642,7 @@ function tputs(Ndx: Word; L1: Longint; F: WriterFunc): Longint;
 implementation
 implementation
 
 
 uses
 uses
-  Unix;
+  baseUnix;
 
 
 function putp(Ndx: Longint): Longint;
 function putp(Ndx: Longint): Longint;
 var
 var
@@ -651,7 +651,7 @@ begin
   if not assigned(cur_term) then
   if not assigned(cur_term) then
     RunError(219);
     RunError(219);
   P := cur_term_strings^[Ndx];
   P := cur_term_strings^[Ndx];
-  putp := fdWrite(cur_term_common^.filedes, P^, StrLen(P));
+  putp := fpWrite(cur_term_common^.filedes, P^, StrLen(P));
 end;
 end;
 
 
 function tputs(Ndx: Word; L1: Longint; F: WriterFunc): Longint;
 function tputs(Ndx: Word; L1: Longint; F: WriterFunc): Longint;
@@ -741,7 +741,10 @@ function tparam(const char *, char *, int, ...): PChar; cdecl; external;}
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2002-09-07 16:01:28  peter
+  Revision 1.4  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.3  2002/09/07 16:01:28  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
 }
 }

+ 24 - 21
rtl/unix/timezone.inc

@@ -154,17 +154,17 @@ begin
    fn:='localtime';
    fn:='localtime';
   if fn[1]<>'/' then
   if fn[1]<>'/' then
    begin
    begin
-     tzdir:=getenv('TZDIR');
+     tzdir:=fpgetenv('TZDIR');
      if tzdir='' then
      if tzdir='' then
       tzdir:='/usr/share/zoneinfo';
       tzdir:='/usr/share/zoneinfo';
      if tzdir[length(tzdir)]<>'/' then
      if tzdir[length(tzdir)]<>'/' then
       tzdir:=tzdir+'/';
       tzdir:=tzdir+'/';
      fn:=tzdir+fn;
      fn:=tzdir+fn;
    end;
    end;
-  f:=fdopen(fn,Open_RdOnly);
+  f:=fpopen(fn,Open_RdOnly);
   if f<0 then
   if f<0 then
    exit;
    exit;
-  i:=fdread(f,tzhead,sizeof(tzhead));
+  i:=fpread(f,tzhead,sizeof(tzhead));
   if i<>sizeof(tzhead) then
   if i<>sizeof(tzhead) then
    exit;
    exit;
   decode(tzhead.tzh_timecnt);
   decode(tzhead.tzh_timecnt);
@@ -184,44 +184,44 @@ begin
   reallocmem(zone_names,chars);
   reallocmem(zone_names,chars);
   reallocmem(leaps,num_leaps*sizeof(tleap));
   reallocmem(leaps,num_leaps*sizeof(tleap));
 
 
-  fdread(f,transitions^,num_transitions*4);
-  fdread(f,type_idxs^,num_transitions);
+  fpread(f,transitions^,num_transitions*4);
+  fpread(f,type_idxs^,num_transitions);
 
 
   for i:=0 to num_transitions-1 do
   for i:=0 to num_transitions-1 do
    decode(transitions[i]);
    decode(transitions[i]);
 
 
   for i:=0 to num_types-1 do
   for i:=0 to num_types-1 do
    begin
    begin
-     fdread(f,types[i].offset,4);
-     fdread(f,types[i].isdst,1);
-     fdread(f,types[i].idx,1);
+     fpread(f,types[i].offset,4);
+     fpread(f,types[i].isdst,1);
+     fpread(f,types[i].idx,1);
      decode(types[i].offset);
      decode(types[i].offset);
      types[i].isstd:=0;
      types[i].isstd:=0;
      types[i].isgmt:=0;
      types[i].isgmt:=0;
    end;
    end;
 
 
-  fdread(f,zone_names^,chars);
+  fpread(f,zone_names^,chars);
 
 
   for i:=0 to num_leaps-1 do
   for i:=0 to num_leaps-1 do
    begin
    begin
-     fdread(f,leaps[i].transition,4);
-     fdread(f,leaps[i].change,4);
+     fpread(f,leaps[i].transition,4);
+     fpread(f,leaps[i].change,4);
      decode(leaps[i].transition);
      decode(leaps[i].transition);
      decode(leaps[i].change);
      decode(leaps[i].change);
    end;
    end;
 
 
   getmem(buf,tzhead.tzh_ttisstdcnt);
   getmem(buf,tzhead.tzh_ttisstdcnt);
-  fdread(f,buf^,tzhead.tzh_ttisstdcnt);
+  fpread(f,buf^,tzhead.tzh_ttisstdcnt);
   for i:=0 to tzhead.tzh_ttisstdcnt-1 do
   for i:=0 to tzhead.tzh_ttisstdcnt-1 do
    types[i].isstd:=byte(buf[i]<>0);
    types[i].isstd:=byte(buf[i]<>0);
   freemem(buf);
   freemem(buf);
 
 
   getmem(buf,tzhead.tzh_ttisgmtcnt);
   getmem(buf,tzhead.tzh_ttisgmtcnt);
-  fdread(f,buf^,tzhead.tzh_ttisgmtcnt);
+  fpread(f,buf^,tzhead.tzh_ttisgmtcnt);
   for i:=0 to tzhead.tzh_ttisgmtcnt-1 do
   for i:=0 to tzhead.tzh_ttisgmtcnt-1 do
    types[i].isgmt:=byte(buf[i]<>0);
    types[i].isgmt:=byte(buf[i]<>0);
   freemem(buf);
   freemem(buf);
-  fdclose(f);
+  fpclose(f);
 end;
 end;
 
 
 Const
 Const
@@ -240,22 +240,22 @@ var
 
 
 begin
 begin
   GetTimezoneFile:='';
   GetTimezoneFile:='';
-  f:=fdopen(TimeZoneLocationFile,Open_RdOnly);
+  f:=fpopen(TimeZoneLocationFile,Open_RdOnly);
   if f>0 then
   if f>0 then
     begin
     begin
-    len:=fdread(f,s[1],high(s));
+    len:=fpread(f,s[1],high(s));
     s[0]:=chr(len);
     s[0]:=chr(len);
     len:=pos(#10,s);
     len:=pos(#10,s);
     if len<>0 then
     if len<>0 then
      s[0]:=chr(len-1);
      s[0]:=chr(len-1);
-    fdclose(f);
+    fpclose(f);
     GetTimezoneFile:=s;
     GetTimezoneFile:=s;
     end
     end
   // Try SuSE
   // Try SuSE
-  else if fstat(TimeZoneFile,info) then
+  else if fpstat(TimeZoneFile,info)>=0 then
     GetTimeZoneFile:=TimeZoneFile
     GetTimeZoneFile:=TimeZoneFile
   // Try RedHat
   // Try RedHat
-  else If fstat(AltTimeZoneFile,Info) then
+  else If fpstat(AltTimeZoneFile,Info)>=0 then
       GetTimeZoneFile:=AltTimeZoneFile;
       GetTimeZoneFile:=AltTimeZoneFile;
 end;
 end;
 
 
@@ -263,7 +263,7 @@ end;
 procedure InitLocalTime;
 procedure InitLocalTime;
 begin
 begin
   ReadTimezoneFile(GetTimezoneFile);
   ReadTimezoneFile(GetTimezoneFile);
-  GetLocalTimezone(GetTimeOfDay);
+  GetLocalTimezone(fptime);
 end;
 end;
 
 
 
 
@@ -286,7 +286,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2002-09-07 16:01:28  peter
+  Revision 1.4  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.3  2002/09/07 16:01:28  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
 }
 }

File diff suppressed because it is too large
+ 57 - 500
rtl/unix/unix.pp


+ 16 - 13
rtl/unix/video.pp

@@ -23,7 +23,7 @@ interface
 implementation
 implementation
 
 
 uses
 uses
-  Unix, Strings, TermInfo;
+  BaseUnix, Unix, Strings, TermInfo;
 
 
 {$i video.inc}
 {$i video.inc}
 
 
@@ -155,7 +155,7 @@ begin
      pdelay:=strpos(p,'$<');
      pdelay:=strpos(p,'$<');
      if assigned(pdelay) then
      if assigned(pdelay) then
        pdelay^:=#0;
        pdelay^:=#0;
-     fdWrite(TTYFd, P^, StrLen(P));
+     fpWrite(TTYFd, P^, StrLen(P));
      SendEscapeSeqNdx:=true;
      SendEscapeSeqNdx:=true;
      if assigned(pdelay) then
      if assigned(pdelay) then
        pdelay^:='$';
        pdelay^:='$';
@@ -165,7 +165,7 @@ end;
 
 
 procedure SendEscapeSeq(const S: String);
 procedure SendEscapeSeq(const S: String);
 begin
 begin
-  fdWrite(TTYFd, S[1], Length(S));
+  fpWrite(TTYFd, S[1], Length(S));
 end;
 end;
 
 
 
 
@@ -367,7 +367,7 @@ end;
        blockwrite(f,outbuf,outptr);
        blockwrite(f,outbuf,outptr);
        blockwrite(f,nl,1);
        blockwrite(f,nl,1);
 {$endif logging}
 {$endif logging}
-       fdWrite(TTYFd,outbuf,outptr);
+       fpWrite(TTYFd,outbuf,outptr);
        outptr:=0;
        outptr:=0;
      end;
      end;
   end;
   end;
@@ -476,7 +476,7 @@ begin
   blockwrite(f,outbuf,outptr);
   blockwrite(f,outbuf,outptr);
   blockwrite(f,nl,1);
   blockwrite(f,nl,1);
 {$endif logging}
 {$endif logging}
-  fdWrite(TTYFd,outbuf,outptr);
+  fpWrite(TTYFd,outbuf,outptr);
   if InACS then
   if InACS then
     SendEscapeSeqNdx(exit_alt_charset_mode);
     SendEscapeSeqNdx(exit_alt_charset_mode);
  {turn autowrap on}
  {turn autowrap on}
@@ -580,14 +580,14 @@ begin
      { save current terminal characteristics and remove rawness }
      { save current terminal characteristics and remove rawness }
      prepareInitVideo;
      prepareInitVideo;
      { write code to set a correct font }
      { write code to set a correct font }
-     fdWrite(stdoutputhandle,fontstr[1],length(fontstr));
+     fpWrite(stdoutputhandle,fontstr[1],length(fontstr));
      { running on a tty, find out whether locally or remotely }
      { running on a tty, find out whether locally or remotely }
      if (Copy(ThisTTY, 1, 8) = '/dev/tty') and
      if (Copy(ThisTTY, 1, 8) = '/dev/tty') and
         (ThisTTY[9] >= '0') and (ThisTTY[9] <= '9') then
         (ThisTTY[9] >= '0') and (ThisTTY[9] <= '9') then
       begin
       begin
         { running on the console }
         { running on the console }
         FName:='/dev/vcsa' + ThisTTY[9];
         FName:='/dev/vcsa' + ThisTTY[9];
-        TTYFd:=fdOpen(FName, Octal(666), Open_RdWr); { open console }
+        TTYFd:=fpOpen(FName, Octal(666), Open_RdWr); { open console }
       end
       end
      else
      else
       TTYFd:=-1;
       TTYFd:=-1;
@@ -600,7 +600,7 @@ begin
         LowAscii:=false;
         LowAscii:=false;
         TTYFd:=stdoutputhandle;
         TTYFd:=stdoutputhandle;
       end;
       end;
-     ioctl(stdinputhandle, TIOCGWINSZ, @WS);
+     fpioctl(stdinputhandle, TIOCGWINSZ, @WS);
      if WS.ws_Col=0 then
      if WS.ws_Col=0 then
       WS.ws_Col:=80;
       WS.ws_Col:=80;
      if WS.ws_Row=0 then
      if WS.ws_Row=0 then
@@ -739,8 +739,8 @@ begin
    exit;
    exit;
   if Console then
   if Console then
    begin
    begin
-     fdSeek(TTYFd, 4, Seek_Set);
-     fdWrite(TTYFd, VideoBuf^,VideoBufSize);
+     fplSeek(TTYFd, 4, Seek_Set);
+     fpWrite(TTYFd, VideoBuf^,VideoBufSize);
    end
    end
   else
   else
    begin
    begin
@@ -763,10 +763,10 @@ var
 begin
 begin
   if Console then
   if Console then
    begin
    begin
-     fdSeek(TTYFd, 2, Seek_Set);
+     fplSeek(TTYFd, 2, Seek_Set);
      Pos[1]:=NewCursorX;
      Pos[1]:=NewCursorX;
      Pos[2]:=NewCursorY;
      Pos[2]:=NewCursorY;
-     fdWrite(TTYFd, Pos, 2);
+     fpWrite(TTYFd, Pos, 2);
    end
    end
   else
   else
    begin
    begin
@@ -826,7 +826,10 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2003-03-26 12:45:21  armin
+  Revision 1.14  2003-09-14 20:15:01  marco
+   * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
+
+  Revision 1.13  2003/03/26 12:45:21  armin
   * added wrapoff to avoid problems in the ide with some terminal emulators
   * added wrapoff to avoid problems in the ide with some terminal emulators
 
 
   Revision 1.12  2002/09/07 16:01:28  peter
   Revision 1.12  2002/09/07 16:01:28  peter

Some files were not shown because too many files changed in this diff