Browse Source

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

marco 22 năm trước cách đây
mục cha
commit
7efaf7dee2
57 tập tin đã thay đổi với 1374 bổ sung2542 xóa
  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 bunxh.inc}		{ Functions}
 
+function fpgeterrno:longint; 
+procedure fpseterrno(err:longint); 
+
+
 implementation
 
+
 {$i bunxmain.inc}	{ 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.
 
 {
   $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
 
   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 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 genfdset.inc}      // general fdset funcs.
 
 {  $ 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}
 
 Function FPKill(Pid:pid_t;Sig:cint):cint;
@@ -50,7 +45,8 @@ begin
 //  Kill:=0;
 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.
   How determines which signals will be blocked :
@@ -460,10 +456,23 @@ begin
 	FPtimes:=clock_t(CONVTCK(t));
 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$
- 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
 
  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
  FPISDIR:=((m and %001111000000000000) = %100000000000000);
 end;
 
-function FPISCHR(m : mode_t): boolean;
+function FPISCHR(m : TMode): boolean;
 begin
  FPISCHR:=((m and %001111000000000000) = %10000000000000);
 end;
 
-function FPISBLK(m : mode_t): boolean;
+function FPISBLK(m : TMode): boolean;
 begin
  FPISBLK:=((m and %001111000000000000) = %110000000000000);
 end;
 
-function FPISREG(m : mode_t): boolean;
+function FPISREG(m : TMode): boolean;
 begin
  FPISREG:=((m and %001111000000000000) = %1000000000000000);
 end;
 
-function FPISFIFO(m : mode_t): boolean;
+function FPISFIFO(m : TMode): boolean;
 begin
  FPISFIFO:=((m and %001111000000000000) = %1000000000000);
 end;
@@ -79,7 +79,10 @@ end;
 
 {
   $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
 
   Revision 1.1  2003/01/05 19:01:28  marco

+ 15 - 1
rtl/bsd/bunxtype.inc

@@ -36,6 +36,13 @@
 //    _UTSNAME_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
    { system information services }
    utsname = record
@@ -137,6 +144,9 @@ TYPE
  TTms= tms;
  pTms= ^tms;
 
+ TFDSet    = ARRAY[0..(FD_MAXFDSET div 32)-1] of Cardinal;
+ pFDSet    = ^TFDSet;
+
 {***********************************************************************}
 {                  POSIX CONSTANT ROUTINE DEFINITIONS                   }
 {***********************************************************************}
@@ -180,6 +190,7 @@ CONST
     WUNTRACED =          2;     { report status of stopped children }
 
 
+
     {*************************************************************************}
     {                               SIGNALS                                   }
     {*************************************************************************}
@@ -191,7 +202,10 @@ CONST
 
 {
   $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
 
   Revision 1.2  2003/06/01 16:35:27  marco

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

@@ -34,19 +34,22 @@ Type
 
   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$
-  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.
 
   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 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
 begin
   FpIOCtl:=do_SysCall(syscall_nr_ioctl,handle,Ndx,TSysParam(data));
@@ -524,10 +525,10 @@ begin
  FpGetPID:=do_syscall(syscall_nr_getpid);
 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
-  Fpreadlink:=do_syscall(syscall_nr_readlink, TSysParam(name),TSysParam(linkname),maxlen);
+ gettimeofday:=do_syscall(syscall_nr_gettimeofday,TSysParam(tp),TSysParam(tzp));
 end;
 
 Function FpNanoSleep(const req : timespec;var rem : timespec) : longint; [public, alias : 'FPC_SYSC_NANOSLEEP'];
@@ -597,7 +598,10 @@ end;
 
 {
  $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
 
  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 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 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}
 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$
-  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.
 
   Revision 1.4  2002/10/27 11:58:29  marco

+ 4 - 6
rtl/bsd/ostypes.inc

@@ -22,11 +22,6 @@
 }
 
 Type
-  timeval  = packed record
-    tv_sec,tv_usec:clong;
-  end;
-  ptimeval = ^timeval;
-  TTimeVal = timeval;
 
   timespec = packed record
     tv_sec   : time_t;
@@ -63,7 +58,10 @@ Type
 
 {
  $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.
 
  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;
     pSocklen = ^socklen_t;
 
+  timeval  = packed record
+    tv_sec,tv_usec:clong;
+  end;
+  ptimeval = ^timeval;
+  TTimeVal = timeval;
+
 CONST
    { System limits, POSIX value in parentheses, used for buffer and stack allocation }
     ARG_MAX  = 65536;   {4096}  { Maximum number of argument size     }
@@ -86,7 +92,10 @@ CONST
 
 {
   $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
 
 

+ 9 - 483
rtl/freebsd/syscalls.inc

@@ -24,497 +24,23 @@
                      --- 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
- 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}
 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$
-  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.
 
   Revision 1.10  2003/01/05 19:02:29  marco

+ 4 - 120
rtl/freebsd/systypes.inc

@@ -14,94 +14,6 @@
  **********************************************************************}
 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
     spare2,            { place holder}
     bsize,             { fundamental block size}
@@ -122,37 +34,6 @@ type
   end;
   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
               It_Interval,
               It_Value      : TimeVal;
@@ -160,7 +41,10 @@ type
 
 {
   $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
 
   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;
 {NOT IMPLEMENTED YET UNDER BSD}
@@ -77,198 +62,7 @@ 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);
 {
   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));
  LinuxError:=Errno;
 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;
 
 begin
@@ -306,46 +83,6 @@ begin
   LinuxError:=Errno;
 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;
 
 begin
@@ -353,28 +90,6 @@ begin
  LinuxError:=Errno;
 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;
 
 {
@@ -401,88 +116,6 @@ begin
  LinuxError:=Errno;
 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;
 {
   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);
 { closed our side, Now wait for the other - this appears to be needed ?? }
   pl:=@(textrec(f).userdata[2]);
-  waitpid(pl^,@res,0);
+  fpwaitpid(pl^,res,0);
   pclose:=res shr 8;
 end;
 
@@ -523,106 +156,10 @@ begin
   do_syscall(syscall_nr_close,filerec(F).Handle);
 { closed our side, Now wait for the other - this appears to be needed ?? }
   pl:=@(filerec(f).userdata[2]);
-  waitpid(pl^,@res,0);
+  fpwaitpid(pl^,res,0);
   pclose:=res shr 8;
 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;
 
 begin
@@ -630,28 +167,6 @@ begin
   LinuxError:=Errno;
 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;
 asm
         pushl   %esi
@@ -684,108 +199,12 @@ asm
         popl    %esi
 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$
-  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)
 
   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);
 begin
   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;
   textrec(f).bufpos:=0;
 end;
@@ -167,7 +167,10 @@ begin
 end;
 {
   $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
 
 }

+ 1 - 2
rtl/linux/Makefile

@@ -210,7 +210,7 @@ INC=$(RTL)/inc
 PROCINC=$(RTL)/$(CPU_TARGET)
 UNIXINC=$(RTL)/unix
 ifeq ($(CPU_TARGET),i386)
-CPU_UNITS=ports cpu mmx graph
+CPU_UNITS= cpu mmx graph
 else
 CPU_UNITS=
 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 \
 	ostypes.inc ossysch.inc bunxmacr.inc $(UNIXINC)/gensigset.inc \
 	$(UNIXINC)/genfuncs.inc $(SYSTEMUNIT)$(PPUEXT)
-ports$(PPUEXT) : ports.pp unix$(PPUEXT) objpas$(PPUEXT)
 dl$(PPUEXT) : $(UNIXINC)/dl.pp $(SYSTEMUNIT)$(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) \

+ 11 - 1
rtl/linux/baseunix.pp

@@ -27,16 +27,26 @@ Interface
 {$i bunxtype.inc}	{ Types }
 {$i bunxh.inc}		{ Functions}
 
+function fpgeterrno:longint;
+procedure fpseterrno(err:longint);
+
+
 implementation
 
 {$i bunxmain.inc}	{ 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.
 
 {
   $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
 
   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 ostypes.inc}
 {$i ossysch.inc}	// external interface to syscalls in system unit.
+//{$i genfuncs.inc}
+
 {$i bunxmacr.inc}	// macro's.
 
 {$I gensigset.inc}     // general sigset funcs implementation. 
-
-
+{$I genfdset.inc}
 
 Function fpKill(Pid:pid_t;Sig:cint):cint;
 {
@@ -409,13 +410,33 @@ end;
 function fpgetcwd(path : pchar; siz:size_t):pchar;
 
 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;
 
 {
  $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
 
  Revision 1.1  2002/12/18 16:43:26  marco

+ 21 - 11
rtl/linux/bunxtype.inc

@@ -20,14 +20,21 @@
 
 {$i ptypes.inc}
 
+
 CONST
-    SYS_NMLM 		     = 65;
+//  SYS_NMLM 		     = 65;
     UTSNAME_LENGTH 	     = SYS_NMLM;
     UTSNAME_NODENAME_LENGTH  = UTSNAME_LENGTH;
     {$ifdef usedomain}
     UTSNAME_DOMAIN_LENGTH    = UTSNAME_LENGTH;
     {$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
    Blksize_t  = cuint;
    Blkcnt_t   = cuint;
@@ -129,21 +136,18 @@ TYPE
   TDirent    = Dirent;
   pDirent    = ^Dirent;
 
-
-
-
 {$ifdef oldreaddir}
 	   { Still old one. This is a userland struct}
 
    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 ??}
-                nextoff: longint;
+                dd_nextoff: longint;
                 dd_max : integer; {size of buf. Irrelevant, as buf is of type dirent}
-                lock   : pointer;
+                dd_lock   : pointer;
                end;
 {$else}
 	// new libc one. NOTE that off_t must be real, so 64-bit ifdef
@@ -192,6 +196,9 @@ TYPE
    TTms      = tms;
    PTms	     = ^tms;
 
+ TFDSet    = ARRAY[0..(FD_MAXFDSET div 32)-1] of Cardinal;
+ pFDSet    = ^TFDSet;
+
 {***********************************************************************}
 {                  POSIX CONSTANT ROUTINE DEFINITIONS                   }
 {***********************************************************************}
@@ -246,7 +253,10 @@ CONST
 
 {
   $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 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

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

@@ -19,7 +19,7 @@
 
 {$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
 { load the registers... }
@@ -44,12 +44,12 @@ asm
   popl  %edx
   movl  %edx,(%eax)
 .LNoThread:
-  movl  $-1,%eax
 {$endif}
+  movl  $-1,%eax
 .LSyscOK:
 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
 { load the registers... }
@@ -75,12 +75,12 @@ asm
   popl  %edx
   movl  %edx,(%eax)
 .LNoThread:
-  movl  $-1,%eax
 {$endif}
+  movl  $-1,%eax
 .LSyscOK:
 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
 { load the registers... }
@@ -107,12 +107,12 @@ asm
   popl  %edx
   movl  %edx,(%eax)
 .LNoThread:
-  movl  $-1,%eax
 {$endif}
+  movl  $-1,%eax
 .LSyscOK:
 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
 { load the registers... }
@@ -140,12 +140,12 @@ asm
   popl  %edx
   movl  %edx,(%eax)
 .LNoThread:
-  movl  $-1,%eax
 {$endif}
+  movl  $-1,%eax
 .LSyscOK:
 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
 { load the registers... }
@@ -174,12 +174,12 @@ asm
   popl  %edx
   movl  %edx,(%eax)
 .LNoThread:
-  movl  $-1,%eax
 {$endif}
+  movl  $-1,%eax
 .LSyscOK:
 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
 { load the registers... }
@@ -209,14 +209,14 @@ asm
   popl  %edx
   movl  %edx,(%eax)
 .LNoThread:
-  movl  $-1,%eax
 {$endif}
+  movl  $-1,%eax
 .LSyscOK:
 end;
 
 {$ifdef notsupported}
 { 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
 { load the registers... }
@@ -246,8 +246,8 @@ asm
   popl  %edx
   movl  %edx,(%eax)
 .LNoThread:
-  movl  $-1,%eax
 {$endif}
+  movl  $-1,%eax
 .LSyscOK:
 end;
 {$endif notsupported}
@@ -261,7 +261,7 @@ end;
                      --- 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
   copies back the registers as they are after the SysCall.
@@ -294,7 +294,7 @@ end;
 
 {$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.
   If the SysCall returned a negative number, it returns -1, and puts the
@@ -341,9 +341,8 @@ end;
 
 {
   $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
     * only set errno when syscall fails

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

@@ -34,21 +34,20 @@ Type
 
   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}
-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}
 
 {
   $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
     * syscall6 alias fixed

+ 22 - 12
rtl/linux/ossysc.inc

@@ -137,21 +137,21 @@ begin
   new(ptr);
   if ptr=nil then
    exit;
-  getmem(ptr^.buf,sizeof(dirent));
-  if ptr^.buf=nil then
+  getmem(ptr^.dd_buf,sizeof(dirent));
+  if ptr^.dd_buf=nil then
    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;
 end;
 
 function Fpclosedir(dirp : pdir): cint; [public, alias : 'FPC_SYSC_CLOSEDIR'];
 
 begin
-  Fpclosedir:=Fpclose(dirp^.fd);
-  freemem(dirp^.buf,sizeof(dirent));
+  Fpclosedir:=Fpclose(dirp^.dd_fd);
+  freemem(dirp^.dd_buf,sizeof(dirent));
   dispose(dirp);
 end;
 
@@ -164,11 +164,11 @@ This usually the sectorsize =512 bytes, but maybe tapedrives and harddisks
 with blockmode have this higher?}
 
 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 }
    Fpreaddir:=nil
   else
-   Fpreaddir:=dirp^.buf
+   Fpreaddir:=dirp^.dd_buf
 end;
 
 {*****************************************************************************
@@ -443,11 +443,21 @@ end;
 // The following belongs here, but this should be researched more.
 // 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$
- 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
      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 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 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 gettimeofday(tp: ptimeval;tzp:ptimezone):cint; external name 'FPC_SYSC_GETTIMEOFDAY';
 
 {
  $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.....
 
 

+ 10 - 8
rtl/linux/ostypes.inc

@@ -44,19 +44,18 @@ Type
   PSysCallRegs= ^SysCallRegs;
   TSysCallRegs= SysCallRegs;
 
-
   ptimespec   = ^timespec;
   timespec    = packed record
     		 tv_sec   : time_t;
     		 tv_nsec  : clong;
  		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 
        _S_IFDIR = $4000;
@@ -68,7 +67,10 @@ CONST
 
 {
  $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.....
 
  Revision 1.1  2002/11/12 14:37:59  marco

+ 7 - 4
rtl/linux/pthread.inc

@@ -45,13 +45,13 @@
      sched_param = record
         sched_priority : LongInt;
      end;
-
+{
      ptimespec = ^timespec;
      timespec = record
         tv_sec : LongInt;
         tv_nsec : LongInt;
      end;
-
+}
      psigset_t = ^sigset_t;
      sigset_t = DWORD; // unsigned long 32 bits
 
@@ -91,7 +91,7 @@
       PTHREAD_SCOPE_PROCESS   = 1;
 
     type
-       size_t = longint;
+//       size_t = longint;
 
        ppthread_attr_t = ^pthread_attr_t;
        pthread_attr_t = record
@@ -198,7 +198,10 @@
 
 {
   $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.
      Turned out to be not entirely the same as *BSD's (constants with
      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;
     pSockLen = ^socklen_t;
 
+  timeval     = packed record
+    		 tv_sec,
+		 tv_usec:clong;
+  		end;
+  ptimeval    = ^timeval;
+  TTimeVal    = timeval;
+
+
 CONST
    { System limits, POSIX value in parentheses, used for buffer and stack allocation }
    { took idefix' values}
@@ -113,10 +121,14 @@ CONST
     ARG_MAX  = 131072;   {4096}  { Maximum number of argument size     }
     NAME_MAX = 255;     {14}    { Maximum number of bytes in filename }
     PATH_MAX = 4095;    {255}   { Maximum number of bytes in pathname }
+    SYS_NMLM 		     = 65;
 
 {
    $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.....
 
    Revision 1.2  2002/11/12 14:28:40  marco

+ 5 - 8
rtl/linux/signal.inc

@@ -16,13 +16,6 @@
 {$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
@@ -216,6 +209,7 @@ type
   psigset_t=psigset;
   TSigSet = SigSet;
 
+
   SigActionRec = packed record  // this is temporary for the migration
    {$ifdef posixworkaround}
     sa_handler : signalhandler;
@@ -235,7 +229,10 @@ type
 
 {
   $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
     * some generic math code fixed
     * ...

+ 10 - 5
rtl/linux/syscallo.inc

@@ -23,7 +23,8 @@
                      --- 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
   copies back the registers as they are after the SysCall.
@@ -141,6 +142,7 @@ var
   LastCall : longint;
   DebugTxt : string[20];
 {$ENDIF}
+
 Function SysCall( callnr:longint;var regs : SysCallregs ):longint;
 {
   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
 }
 begin
-  do_SysCall(callnr,regs);
+  do_SysCallspec(callnr,regs);
   if regs.reg1<0 then
    begin
 {$IFDEF SYSCALL_DEBUG}
      If DoSysCallDebug then
        debugtxt:=' syscall error: ';
 {$endif}
-     ErrNo:=-regs.reg1;
+     fpseterrno(-regs.reg1);
      SysCall:=-1;
    end
   else
@@ -165,7 +167,7 @@ begin
        debugtxt:=' syscall returned: ';
 {$endif}
      SysCall:=regs.reg1;
-     errno:=0
+     fpseterrno(0);
    end;
 {$IFDEF SYSCALL_DEBUG}
   if DoSysCallDebug then
@@ -186,7 +188,10 @@ end;
 
 {
   $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
 
   Revision 1.4  2003/06/17 16:39:58  jonas

+ 4 - 287
rtl/linux/syscalls.inc

@@ -16,292 +16,6 @@
 { Include syscall itself }
 {$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
 type
   tmmapargs=packed record
@@ -435,7 +149,10 @@ end;
 
 {
   $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.....
 
   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, }
 { But you can override them here.}
 
+
 { If you use an aout system, set the conditional AOUT}
 { $Define AOUT}
 
@@ -135,7 +136,10 @@ End.
 
 {
   $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
 
   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
   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 }
   dirent = packed record
     ino,
@@ -57,9 +58,11 @@ type
   end;
   PDir =^TDir;
 
+}
 { 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   }
 { def_t in another way :(                                               }
+{
 {$ifdef cpui386}
   dev_t = word;
 {$else cpui386}
@@ -77,12 +80,12 @@ type
 {$endif cpupowerpc}
 {$endif cpum68k}
 {$endif cpui386}
-
+}{
 { definition of stat record type }
-{$i stat.inc}
+{i stat.inc}
   PStat=^Stat;
   TStat=Stat;
-
+}
   TStatfs = packed record
     fstype,            { File system type }
     bsize,             { Optimal block trensfer size }
@@ -97,6 +100,8 @@ type
   end;
   PStatFS=^TStatFS;
 
+{
+
   fdSet=array[0..31] of longint;{=1024 bits}
   pfdset=^fdset;
   TFDSet=fdset;
@@ -107,16 +112,19 @@ type
   ptimeval=^timeval;
   TTimeVal=timeval;
 
+
   timespec = packed record
     tv_sec,tv_nsec:longint;
   end;
 
+
   timezone = packed record
     minuteswest,dsttime:longint;
   end;
   ptimezone =^timezone;
   TTimeZone = timezone;
 
+
   utsname = packed record
     sysname,
     nodename,
@@ -127,10 +135,13 @@ type
   end;
   PUTSName=^UTSName;
   TUTSName=UTSName;
-
+}
 {
   $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
 
   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;
 var
-  Regs:SysCallRegs;
+//  Regs:SysCallRegs;
   Args:array[1..6] of longint;
 begin
 {$IFNDEF BSD}
@@ -50,11 +50,9 @@ begin
   args[4]:=a4;
   args[5]:=a5;
   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
-   SocketError:=Errno
+   SocketError:=fpgetErrno
   else
    SocketError:=0;
  {$ELSE}
@@ -80,7 +78,7 @@ end;
 
 Function CloseSocket (Sock:Longint):Longint;
 begin
-  if fdClose (Sock) then
+  if fpClose(Sock)=0 then
     CloseSocket := 0 else
     CloseSocket := -1;
 end;
@@ -274,7 +272,10 @@ end;
 
 {
   $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
 
   Revision 1.6  2002/09/07 16:01:20  peter

+ 53 - 78
rtl/linux/unixsysc.inc

@@ -25,7 +25,7 @@ var
   regs:SysCallregs;
 begin
   Fork:=SysCall(SysCall_nr_fork,regs);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 End;
 
 
@@ -44,7 +44,7 @@ begin
   regs.reg4:=longint(ep);
   SysCall(SysCall_nr_Execve,regs);
 { This only gets set when the call fails, otherwise we don't get here ! }
-  Linuxerror:=errno;
+  Linuxerror:=fpgeterrno;
 end;
 
 
@@ -62,7 +62,7 @@ begin
   regs.reg4:=longint(ep);
   SysCall(SysCall_nr_Execve,regs);
 { This only gets set when the call fails, otherwise we don't get here ! }
-  Linuxerror:=errno;
+  Linuxerror:=fpgeterrno;
 end;
 
 Procedure ExitProcess(val:longint);
@@ -88,7 +88,7 @@ begin
   regs.reg3:=longint(status);
   regs.reg4:=options;
   WaitPid:=SysCall(SysCall_nr_waitpid,regs);
-  LinuxError:=errno;
+  LinuxError:=fpgeterrno;
 end;
 
 
@@ -103,7 +103,7 @@ begin
   regs.reg2:=longint(@tv);
   regs.reg3:=0;
   SysCall(SysCall_nr_gettimeofday,regs);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 
 Function GetPriority(Which,Who:Integer):integer;
@@ -123,7 +123,7 @@ Function GetPriority(Which,Who:Integer):integer;
 var
   sr : Syscallregs;
 begin
-  errno:=0;
+  fpseterrno(0);
   if (which<prio_process) or (which>prio_user) then
    begin
      { We can save an interrupt here }
@@ -135,7 +135,7 @@ begin
      sr.reg2:=which;
      sr.reg3:=who;
      getpriority:=SysCall(Syscall_nr_getpriority,sr);
-     linuxerror:=errno;
+     linuxerror:=fpgeterrno;
    end;
 end;
 
@@ -159,7 +159,7 @@ Procedure SetPriority(Which:Integer;Who:Integer;What:Integer);
 var
   sr : Syscallregs;
 begin
-  errno:=0;
+  fpseterrno(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
@@ -168,7 +168,7 @@ begin
      sr.reg3:=who;
      sr.reg4:=what;
      SysCall(Syscall_nr_setpriority,sr);
-     linuxerror:=errno;
+     linuxerror:=fpgeterrno;
    end;
 end;
 
@@ -183,7 +183,7 @@ var
 begin
   sr.reg2:=n;
   SysCall(Syscall_nr_nice,sr);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -196,7 +196,7 @@ var
   regs : SysCallregs;
 begin
   GetPid:=SysCall(SysCall_nr_getpid,regs);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -209,7 +209,7 @@ var
   regs : SysCallregs;
 begin
   GetPpid:=SysCall(SysCall_nr_getppid,regs);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -222,7 +222,7 @@ var
   regs : SysCallregs;
 begin
   GetUid:=SysCall(SysCall_nr_getuid,regs);
-  Linuxerror:=errno;
+  Linuxerror:=fpgeterrno;
 end;
 
 
@@ -235,7 +235,7 @@ var
   regs : SysCallregs;
 begin
   GetEuid:=SysCall(SysCall_nr_geteuid,regs);
-  Linuxerror:=errno;
+  Linuxerror:=fpgeterrno;
 end;
 
 
@@ -248,7 +248,7 @@ var
   regs : SysCallregs;
 begin
   Getgid:=SysCall(SysCall_nr_getgid,regs);
-  Linuxerror:=errno;
+  Linuxerror:=fpgeterrno;
 end;
 
 
@@ -261,7 +261,7 @@ var
   regs : SysCallregs;
 begin
   GetEgid:=SysCall(SysCall_nr_getegid,regs);
-  Linuxerror:=errno;
+  Linuxerror:=fpgeterrno;
 end;
 
 
@@ -277,8 +277,8 @@ begin
   regs.reg2:=longint(@tv);
   regs.reg3:=0;
   SysCall(SysCall_nr_gettimeofday,regs);
-  LinuxError:=Errno;
-  GetTimeOfDay:=tv.sec;
+  LinuxError:=fpgetErrno;
+  GetTimeOfDay:=tv.tv_sec;
 end;
 
 
@@ -289,7 +289,7 @@ begin
   Regs.reg2:=fd;
   Regs.reg3:=size;
   fdTruncate:=(SysCall(Syscall_nr_ftruncate,regs)=0);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 
 
@@ -300,7 +300,7 @@ var
 begin
   SR.reg2 := fd;
   fdFlush := (SysCall(syscall_nr_fsync, SR)=0);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 
 
@@ -323,7 +323,7 @@ begin
      Linuxerror:=SysCall(Syscall_nr_fcntl,sr);
      if linuxerror=-1 then
       begin
-        linuxerror:=errno;
+        linuxerror:=fpgeterrno;
         fcntl:=0;
       end
      else
@@ -359,7 +359,7 @@ begin
      sr.reg3:=cmd;
      sr.reg4:=arg;
      SysCall(Syscall_nr_fcntl,sr);
-     linuxerror:=errno;
+     linuxerror:=fpgeterrno;
    end
   else
    linuxerror:=ESyseinval;
@@ -377,7 +377,7 @@ begin
   sr.reg2:=longint(@(path[1]));
   sr.reg3:=newmode;
   Chmod:=(SysCall(Syscall_nr_chmod,sr)=0);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -396,12 +396,10 @@ begin
   sr.reg3:=newuid;
   sr.reg4:=newgid;
   ChOwn:=(Syscall(Syscall_nr_chown,sr)=0);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
-
-
-Function Utime(path:pathstr;utim:utimebuf):boolean;
+Function Utime(path:pathstr;utim:utimbuf):boolean;
 var
   sr : Syscallregs;
 begin
@@ -409,11 +407,9 @@ begin
   sr.reg2:=longint(@(path[1]));
   sr.reg3:=longint(@utim);
   Utime:=SysCall(Syscall_nr_utime,sr)=0;
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
-
-
 Function  Flock (fd,mode : longint) : boolean;
 var
   sr : Syscallregs;
@@ -421,11 +417,9 @@ begin
   sr.reg2:=fd;
   sr.reg3:=mode;
   flock:=Syscall(Syscall_nr_flock,sr)=0;
-  LinuxError:=errno;
+  LinuxError:=fpgeterrno;
 end;
 
-
-
 Function Fstat(Fd:Longint;var Info:stat):Boolean;
 {
   Get all information on a file descriptor, and return it in info.
@@ -436,7 +430,7 @@ begin
   regs.reg2:=Fd;
   regs.reg3:=longint(@Info);
   FStat:=(SysCall(SysCall_nr_fstat,regs)=0);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 
 
@@ -451,7 +445,7 @@ begin
   regs.reg2:=longint(@filename[1]);
   regs.reg3:=longint(@Info);
   LStat:=(SysCall(SysCall_nr_lstat,regs)=0);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 
 
@@ -469,7 +463,7 @@ begin
   regs.reg2:=longint(@path[1]);
   regs.reg3:=longint(@Info);
   StatFS:=(SysCall(SysCall_nr_statfs,regs)=0);
-  LinuxError:=errno;
+  LinuxError:=fpgeterrno;
 end;
 
 
@@ -486,7 +480,7 @@ begin
   regs.reg2:=Fd;
   regs.reg3:=longint(@Info);
   StatFS:=(SysCall(SysCall_nr_fstatfs,regs)=0);
-  LinuxError:=errno;
+  LinuxError:=fpgeterrno;
 end;
 
 
@@ -504,7 +498,7 @@ begin
   regs.reg2:=longint(@oldpath[1]);
   regs.reg3:=longint(@newpath[1]);
   Link:=SysCall(SysCall_nr_link,regs)=0;
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -545,7 +539,7 @@ begin
   sr.reg2:=longint(@(path[1]));
   sr.reg3:=mode;
   access:=(SysCall(Syscall_nr_access,sr)=0);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -558,7 +552,7 @@ var
 begin
   sr.reg2:=oldfile;
   newfile:=Syscall(Syscall_nr_dup,sr);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
   Dup:=(LinuxError=0);
 end;
 
@@ -573,32 +567,10 @@ begin
   sr.reg2:=oldfile;
   sr.reg3:=newfile;
   SysCall(Syscall_nr_dup2,sr);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
   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.
-}
-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;
 {
   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);
   pipe_in:=pip[1];
   pipe_out:=pip[2];
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
   AssignPipe:=(LinuxError=0);
 end;
 
@@ -684,7 +656,7 @@ var
 Begin
   regs.reg2:=longint(@unamerec);
   Uname:=SysCall(SysCall_nr_uname,regs)=0;
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 End;
 
 
@@ -705,7 +677,7 @@ begin
   kill:=SysCall(Syscall_nr_kill,regs);
   if kill<0 then
    Kill:=0;
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -725,7 +697,7 @@ begin
   sr.reg3:=longint(SSet);
   sr.reg4:=longint(OldSSet);
   SysCall(Syscall_nr_sigprocmask,sr);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -741,7 +713,7 @@ Var
 begin
   sr.reg2:=longint(@dummy);
   SysCall(Syscall_nr_sigpending,sr);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
   Sigpending:=dummy;
 end;
 
@@ -757,7 +729,7 @@ Var
 begin
   sr.reg2:=mask[0];
   SysCall(Syscall_nr_sigsuspend,sr);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -777,7 +749,7 @@ begin
   If linuxerror=Sig_Err then
    begin
      Signal:=nil;
-     Linuxerror:=errno;
+     Linuxerror:=fpgeterrno;
    end
   else
    begin
@@ -802,7 +774,7 @@ Var Sr : Syscallregs;
 begin
   syscall(syscall_nr_pause,sr);
 end;
-
+{
 Function NanoSleep(const req : timespec;var rem : timespec) : longint;
 
 var Sr : Syscallregs;
@@ -813,7 +785,7 @@ begin
   NanoSleep:=Syscall(syscall_nr_nanosleep,sr);
   LinuxError:=Errno;
 end;
-
+}
 Function IOCtl(Handle,Ndx: Longint;Data: Pointer):boolean;
 {
   Interface to Unix ioctl call.
@@ -829,7 +801,7 @@ begin
   sr.reg3:=Ndx;
   sr.reg4:=Longint(Data);
   IOCtl:=(SysCall(Syscall_nr_ioctl,sr)=0);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 
 
@@ -839,7 +811,7 @@ Var
 begin
   Sr.reg2:=longint(@m);
   MMap:=syscall(syscall_nr_mmap,sr);
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 
 function MUnMap (P : Pointer; Size : Longint) : Boolean;
@@ -849,7 +821,7 @@ begin
   Sr.reg2:=longint(P);
   sr.reg3:=Size;
   MUnMap:=syscall(syscall_nr_munmap,sr)=0;
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 
 {--------------------------------
@@ -871,7 +843,7 @@ begin
   Sr.Reg3:=Num;
   Sr.Reg4:=Value;
   IOPerm:=Syscall(Syscall_nr_ioperm,sr)=0;
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 
 Function IoPL(Level : longint) : Boolean;
@@ -881,14 +853,17 @@ Var
 begin
   Sr.Reg2:=Level;
   IOPL:=Syscall(Syscall_nr_iopl,sr)=0;
-  LinuxError:=Errno;
+  LinuxError:=fpgetErrno;
 end;
 
 {$endif i386}
 
 {
   $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
 
   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;
      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  FpSigFillSet (var nset : TSigSet): cInt;
     Function  FpSigAddSet  (var nset : TSigSet; signo : cInt): cInt;
     Function  FpSigDelSet  (var nset : TSigSet; signo : cInt): cInt;
     Function  FpSigIsMember(Const nset : TSigSet; signo : cInt): cInt;
+
     Function  FpSigProcMask(how : cInt; nset : pSigSet; oset : pSigSet): cInt; 
     Function  FpSigProcMask(how : cInt; Const nset : TSigSet; var oset : 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  FpFtruncate  (fd : cInt; flength : TOff): 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 : String): pChar;
@@ -107,7 +117,10 @@ Type TGrpArr = Array [0..0] of TGid;		{ C style array workarounds}
 
 {
   $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.
 
   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);
 End;
 
-Function  FpOpendir (dirname : AnsiString): pDir;
-Begin
-  FpOpenDir:=FpOpenDir(dirname);
-End;
 
 Function  FpChdir (path : AnsiString): cInt;
 Begin
@@ -137,11 +133,187 @@ begin
        fpsignal:=osa.sa_handler;
 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$
- 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.
 
  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  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  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$
- 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.
 
  Revision 1.1  2002/12/18 16:49:02  marco

+ 24 - 21
rtl/unix/crt.pp

@@ -111,7 +111,7 @@ procedure CursorOff;
 
 Implementation
 
-uses Unix;
+uses BaseUnix,unix;
 
 {
   The definitions of TextRec and FileRec are in separate files.
@@ -349,7 +349,7 @@ procedure ttyFlushOutput;
 begin
   if OutCnt>0 then
    begin
-     fdWrite(ttyOut,OutBuf,OutCnt);
+     fpWrite(ttyOut,OutBuf,OutCnt);
      OutCnt:=0;
    end;
 end;
@@ -406,7 +406,7 @@ begin
      if InTail>InHead then
       i:=InTail-InHead;
    {Read}
-     Readed:=fdRead(TTYIn,InBuf[InHead],i);
+     Readed:=fpread(TTYIn,InBuf[InHead],i);
    {Increase Counters}
      inc(InCnt,Readed);
      inc(InHead,Readed);
@@ -897,15 +897,15 @@ End;
 { TTYLevel (including ones that are waiting in the TTYRecvChar buffer) }
 function sysKeyPressed: boolean;
 var
-  fdsin : fdSet;
+  fdsin : tfdSet;
 begin
   if (InCnt>0) then
    sysKeyPressed:=true
   else
    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;
 
@@ -919,7 +919,7 @@ Var
   ch       : char;
   OldState,
   State    : longint;
-  FDS      : FDSet;
+  FDS      : TFDSet;
 Begin
 {Check Buffer first}
   if KeySend<>KeyPut then
@@ -931,9 +931,9 @@ Begin
 { Only if none are waiting! (JM) }
   if not sysKeyPressed then
     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;
 
   ch:=ttyRecvChar;
@@ -1370,7 +1370,7 @@ Begin
       CrtRead := 0;
       exit;
     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 }
   for i:=1to F.BufEnd do
    begin
@@ -1461,7 +1461,7 @@ const
 Procedure Sound(Hz: Word);
 begin
   if not OutputRedir then
-    ioctl(TextRec(Output).Handle, KIOCSOUND, Pointer(1193180 div Hz));
+    fpIoctl(TextRec(Output).Handle, KIOCSOUND, Pointer(1193180 div Hz));
 end;
 
 
@@ -1469,7 +1469,7 @@ end;
 Procedure NoSound;
 begin
   if not OutputRedir then
-    ioctl(TextRec(Output).Handle, KIOCSOUND, nil);
+    fpIoctl(TextRec(Output).Handle, KIOCSOUND, nil);
 end;
 
 
@@ -1571,7 +1571,7 @@ End;
 
 procedure GetXY(var x,y:byte);
 var
-  fds    : fdSet;
+  fds    : tfdSet;
   i,j,
   readed : longint;
   buf    : array[0..255] of char;
@@ -1580,12 +1580,12 @@ begin
   x:=0;
   y:=0;
   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
    begin
-     readed:=fdRead(1,buf,sizeof(buf));
+     readed:=fpRead(1,buf,sizeof(buf));
      i:=0;
      while (i+5<readed) and (buf[i]<>#27) and (buf[i+1]<>'[') do
       inc(i);
@@ -1613,7 +1613,7 @@ var
 begin
   if Assigned(ConsoleBuf) then
    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
      ScreenWidth:=Wininfo.ws_col;
      ScreenHeight:=Wininfo.ws_row;
@@ -1682,7 +1682,10 @@ Finalization
 End.
 {
   $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
 
   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
 
 Uses
-  Strings,Unix;
+  Strings,Unix,BaseUnix;
 
 {******************************************************************************
                            --- Link C Lib if set ---
@@ -206,13 +206,9 @@ Var
   Rel    : LongInt;
   info   : utsname;
 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;
   TmpPos:=Pos('.',TmpStr);
   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
 Begin
   LastDosExitCode:=0;
-  pid:=Fork;
+  pid:=fpFork;
   if pid=0 then
    begin
    {The child does the actual exec, and then exits}
@@ -337,7 +333,7 @@ Begin
      else
       Execl(Path+' '+ComLine);
    {If the execve fails, we return an exitvalue of 127, to let it be known}
-     ExitProcess(127);
+     fpExit(127);
    end
   else
    if pid=-1 then         {Fork failed}
@@ -463,7 +459,7 @@ Begin
       Begin
         RtlFindRecs[i].SearchNum:=0;
         if f.dirptr<>0 then
-         closedir(pdir(f.dirptr));
+         fpclosedir(pdir(f.dirptr)^);
       End;
    end;
   f.dirptr:=0;
@@ -474,18 +470,18 @@ Function FindGetFileInfo(const s:string;var f:SearchRec):boolean;
 var
   DT   : DateTime;
   Info : RtlInfoType;
-  st   : stat;
+  st   : baseunix.stat;
 begin
   FindGetFileInfo:=false;
-  if not Fstat(s,st) then
+  if not fpstat(s,st)>=0 then
    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
   else
    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;
   If ((Info.FMode and Not(f.searchattr))=0) Then
    Begin
@@ -565,12 +561,12 @@ Begin
            Move(f.SearchSpec[1], DirName[0], f.NamePos);
            DirName[f.NamePos] := #0;
          End;
-        f.DirPtr := longint(opendir(@(DirName)));
+        f.DirPtr := longint(fpopendir(@(DirName)));
         If f.DirPtr <> 0 Then
          begin
            ArrayPos:=FindLastUsed;
            If RtlFindRecs[ArrayPos].SearchNum > 0 Then
-            CloseDir(pdir(rtlfindrecs[arraypos].dirptr));
+            FpCloseDir((pdir(rtlfindrecs[arraypos].dirptr)^));
            RtlFindRecs[ArrayPos].SearchNum := f.SearchNum;
            RtlFindRecs[ArrayPos].DirPtr := f.DirPtr;
            if f.searchpos>0 then
@@ -586,11 +582,11 @@ Begin
   Finished:=(f.dirptr=0);
   While Not Finished Do
    Begin
-     p:=readdir(pdir(f.dirptr));
+     p:=fpreaddir(pdir(f.dirptr)^);
      if p=nil then
       FName:=''
      else
-      FName:=Strpas(@p^.name);
+      FName:=Strpas(@p^.d_name);
      If FName='' Then
       Finished:=True
      Else
@@ -682,9 +678,9 @@ End;
 
 Function FSearch(path : pathstr;dirlist : string) : pathstr;
 Var
-  info:stat;
+  info : BaseUnix.stat;
 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
   else
     FSearch:=Unix.FSearch(path,dirlist);
@@ -694,25 +690,25 @@ End;
 
 Procedure GetFAttr(var f; var attr : word);
 Var
-  info : stat;
+  info    : baseunix.stat;
   LinAttr : longint;
 Begin
   DosError:=0;
-  if not FStat(strpas(@textrec(f).name),info) then
+  if FPStat(strpas(@textrec(f).name),info)<0 then
    begin
      Attr:=0;
      DosError:=3;
      exit;
    end
   else
-   LinAttr:=Info.Mode;
-  if S_ISDIR(LinAttr) then
+   LinAttr:=Info.st_Mode;
+  if fpISDIR(LinAttr) then
    Attr:=$10
   else
    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;
-  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;
 end;
 
@@ -720,18 +716,18 @@ end;
 
 Procedure getftime (var f; var time : longint);
 Var
-  Info: stat;
+  Info: baseunix.stat;
   DT: DateTime;
 Begin
   doserror:=0;
-  if not fstat(filerec(f).handle,info) then
+  if fpfstat(filerec(f).handle,info)<0 then
    begin
      Time:=0;
      doserror:=6;
      exit
    end
   else
-   UnixDateToDT(Info.mTime,DT);
+   UnixDateToDT(Info.st_mTime,DT);
   PackTime(DT,Time);
 End;
 
@@ -782,7 +778,7 @@ Function GetEnv(EnvVar: String): String;
 var
   p     : pchar;
 Begin
-  p:=Unix.GetEnv(EnvVar);
+  p:=BaseUnix.fpGetEnv(EnvVar);
   if p=nil then
    GetEnv:=''
   else
@@ -855,7 +851,7 @@ Begin
     end;
   for Index:=0 to FilerecNameLength-1 do
     path[Index+1]:=filerec(f).name[Index];
-  if not utime(path,utim) then
+  if fputime(path,@utim)<0 then
     begin
     Time:=0;
     doserror:=3;
@@ -910,7 +906,10 @@ End.
 
 {
   $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
 
   Revision 1.14  2003/05/14 13:51:03  florian

+ 6 - 3
rtl/unix/genfuncs.inc

@@ -96,16 +96,16 @@ Begin
 	exit(cp+1);
    inc(p);
   end;
+ fpgetenv:=nil;
 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
   returns a pchar to it's value.
   A pchar is used to accomodate for strings of length > 255
 }
 
-
 Begin
   name:=name+'=';            {Else HOST will also find HOSTNAME, etc}
   fpgetenv:=fpgetenv(@name[1]);
@@ -113,7 +113,10 @@ end;
 
 {
   $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
 
   Revision 1.2  2002/10/27 17:21:30  marco

+ 5 - 2
rtl/unix/gpm.pp

@@ -16,7 +16,7 @@
 unit gpm;
 interface
 uses
-  Unix;
+  baseUnix;
 
 {$linklib gpm}
 {$linklib c}
@@ -206,7 +206,10 @@ end;
 end.
 {
   $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
 
 }

+ 5 - 2
rtl/unix/graph.pp

@@ -85,7 +85,7 @@ Const
 implementation
 
 uses
-  Unix;
+  Unix,x86;
 
 const
   InternalDriverName = 'LinuxVGA';
@@ -601,7 +601,10 @@ initialization
 end.
 {
   $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
 
 }

+ 13 - 10
rtl/unix/ipc.pp

@@ -239,7 +239,7 @@ Function semctl(semid:longint; semnum:longint; cmd:longint; var arg: tsemun): lo
 
 implementation
 
-uses Unix;
+uses BaseUnix,Syscall;
 
 { The following definitions come from linux/ipc.h }
 
@@ -261,30 +261,30 @@ Const
 function ipccall(Call,First,Second,Third : Longint; P : Pointer) : longint;
 
 {$ifndef bsd}
-Var SR : SysCallRegs;
+//Var SR : SysCallRegs;
 {$endif}
 begin
  {$IFNDEF bsd}
-  SR.Reg2:=Call;
+{  SR.Reg2:=Call;
   SR.reg3:=first;
   SR.reg4:=second;
   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}
- ipcerror:=Errno;
+ ipcerror:=fpgetErrno;
 end;
 
 Function ftok (Path : String; ID : char) : TKey;
 
-Var Info : Stat;
+Var Info : TStat;
 
 begin
-  If not fstat(path,info) then
+  If fpstat(path,info)<0 then
     ftok:=-1
   else
     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;
 
@@ -372,7 +372,10 @@ end;
 end.
 {
   $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
 
 }

+ 48 - 45
rtl/unix/keyboard.pp

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

+ 190 - 87
rtl/unix/linux.pp

@@ -16,17 +16,24 @@
 Unit Linux;
 Interface
 
+Uses BaseUnix;
+
 { Get Types and Constants }
 {$i sysconst.inc}
 {$i systypes.inc}
 
-{ Get System call numbers and error-numbers}
+{$i ptypes.inc}
+{$i ostypes.inc}
 {$i sysnr.inc}
+{$i syscallh.inc}
+
+{ Get System call numbers and error-numbers}
 {$i errno.inc}
 {$I signal.inc}
 
+Type stat=baseunix.tstat;
+
 var
-  ErrNo,
   LinuxError : Longint;
 
 
@@ -159,20 +166,6 @@ Type
                             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
 ***************************}
@@ -268,7 +261,7 @@ Function  fdOpen(pathname:string;flags,mode:longint):longint;
 Function  fdOpen(pathname:pchar;flags:longint):longint;
 Function  fdOpen(pathname:pchar;flags,mode:longint):longint;
 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  fdTruncate(fd,size:longint):boolean;
 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(var oldfile,newfile:text):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 :Longint):Longint;
 
@@ -359,7 +352,7 @@ Function  Uname(var unamerec:utsname):Boolean;
         Signal
 ***************************}
 
-Procedure SigAction(Signum:longint;Act,OldAct:PSigActionRec );
+Procedure SigAction(Signum:longint;Act,OldAct:baseunix.PSigActionRec );
 Procedure SigProcMask (How:longint;SSet,OldSSet:PSigSet);
 Function  SigPending:SigSet;
 Procedure SigSuspend(Mask:Sigset);
@@ -476,10 +469,10 @@ Function  StringToPPChar(S : Pchar):ppchar;
 Function  GetFS(var T:Text):longint;
 Function  GetFS(Var F:File):longint;
 {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}
 Function S_ISLNK(m:word):boolean;
 Function S_ISREG(m:word):boolean;
@@ -497,7 +490,7 @@ Function S_ISSOCK(m:word):boolean;
 
 Implementation
 
-Uses Strings,baseunix;
+Uses Strings,Unix;
 
 
 { Get the definitions of textrec and filerec }
@@ -505,10 +498,13 @@ Uses Strings,baseunix;
 {$i filerec.inc}
 
 { Raw System calls are in Syscalls.inc}
+{$DEFINE FROMLINUXUNIT}
 {$i syscalls.inc}
 
 {$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
@@ -898,9 +894,9 @@ var
   t : timeval;
 begin
   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;
 
 
@@ -954,7 +950,7 @@ var
 begin
   sr.reg2:=longint(@t);
   SysCall(Syscall_nr_stime,sr);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
    stime:=linuxerror=0;
 end;
 {$endif}
@@ -1004,6 +1000,120 @@ end;
 { Include timezone handling routines which use /usr/share/timezone info }
 {$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
@@ -1013,7 +1123,6 @@ Function fdOpen(pathname:string;flags:longint):longint;
 begin
   pathname:=pathname+#0;
   fdOpen:=Sys_Open(@pathname[1],flags,438);
-  LinuxError:=Errno;
 end;
 
 
@@ -1021,7 +1130,6 @@ Function fdOpen(pathname:string;flags,mode:longint):longint;
 begin
   pathname:=pathname+#0;
   fdOpen:=Sys_Open(@pathname[1],flags,mode);
-  LinuxError:=Errno;
 end;
 
 
@@ -1029,7 +1137,6 @@ end;
 Function  fdOpen(pathname:pchar;flags:longint):longint;
 begin
   fdOpen:=Sys_Open(pathname,flags,0);
-  LinuxError:=Errno;
 end;
 
 
@@ -1037,7 +1144,6 @@ end;
 Function  fdOpen(pathname:pchar;flags,mode:longint):longint;
 begin
   fdOpen:=Sys_Open(pathname,flags,mode);
-  LinuxError:=Errno;
 end;
 
 
@@ -1045,15 +1151,13 @@ end;
 Function fdClose(fd:longint):boolean;
 begin
   fdClose:=(Sys_Close(fd)=0);
-  LinuxError:=Errno;
 end;
 
 
 
-Function fdRead(fd:longint;var buf;size:longint):longint;
+Function fdRead(fd:longint;var buf;tsize:longint):longint;
 begin
-  fdRead:=Sys_Read(fd,pchar(@buf),size);
-  LinuxError:=Errno;
+  fdRead:=Sys_Read(fd,pchar(@buf),tsize);
 end;
 
 
@@ -1061,7 +1165,6 @@ end;
 Function fdWrite(fd:longint;const buf;size:longint):longint;
 begin
   fdWrite:=Sys_Write(fd,pchar(@buf),size);
-  LinuxError:=Errno;
 end;
 
 
@@ -1074,7 +1177,7 @@ Function  fdSeek (fd,pos,seektype :longint): longint;
 }
 begin
    fdseek:=Sys_LSeek (fd,pos,seektype);
-   LinuxError:=Errno;
+   linuxerror:=fpgeterrno;
 end;
 
 {$ifdef BSD}
@@ -1093,7 +1196,7 @@ begin
      Linuxerror:=fpfcntl(fd,cmd,0);
      if linuxerror=-1 then
       begin
-        linuxerror:=errno;
+        linuxerror:=fpgeterrno;
         fcntl:=0;
       end
      else
@@ -1123,7 +1226,7 @@ begin
   if (cmd in [F_SetFd,F_SetFl,F_GetLk,F_SetLk,F_SetLkw,F_SetOwn]) then
    begin
      fpfcntl(fd,cmd,arg);
-     LinuxError:=ErrNo;
+     linuxerror:=fpgeterrno;
    end
   else
    linuxerror:=ESyseinval;
@@ -1164,7 +1267,7 @@ Function FStat(Path:Pathstr;Var Info:stat):Boolean;
 begin
   path:=path+#0;
   FStat:=(Sys_stat(@(path[1]),Info)=0);
-  LinuxError:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -1196,7 +1299,7 @@ begin
   oldpath:=oldpath+#0;
   newpath:=newpath+#0;
   Symlink:=Sys_symlink(pchar(@(oldpath[1])),pchar(@(newpath[1])))=0;
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -1206,7 +1309,7 @@ Function ReadLink(name,linkname:pchar;maxlen:longint):longint;
 }
 begin
   Readlink:=Sys_readlink(Name,LinkName,maxlen);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -1238,7 +1341,7 @@ Function UnLink(Path:pathstr):boolean;
 begin
   path:=path+#0;
   Unlink:=Sys_unlink(pchar(@(path[1])))=0;
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -1249,14 +1352,14 @@ Function  UnLink(Path:pchar):Boolean;
 }
 begin
   Unlink:=(Sys_unlink(path)=0);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
 Function  FRename (OldName,NewName : Pchar) : Boolean;
 begin
   FRename:=Sys_rename(OldName,NewName)=0;
-  LinuxError:=Errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -1330,9 +1433,7 @@ begin
   Dup2:=Dup2(filerec(oldfile).handle,filerec(newfile).handle);
 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
   have changed.
@@ -1346,8 +1447,8 @@ begin
    p:=nil
   else
    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;
    end;
   Select:=Select(N,Readfds,WriteFds,ExceptFds,p);
@@ -1357,7 +1458,7 @@ end;
 
 Function SelectText(var T:Text;TimeOut :PTimeval):Longint;
 Var
-  F:FDSet;
+  F:tfdset;
 begin
   if textrec(t).mode=fmclosed then
    begin
@@ -1382,8 +1483,8 @@ begin
    p:=nil
   else
    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;
    end;
   SelectText:=SelectText(T,p);
@@ -1398,7 +1499,7 @@ Function OpenDir(F:String):PDir;
 begin
   F:=F+#0;
   OpenDir:=OpenDir(@F[1]);
-  LinuxError:=ErrNo;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -1406,17 +1507,16 @@ procedure SeekDir(p:pdir;off:longint);
 begin
   if p=nil then
    begin
-     errno:=ESysEBadf;
+     fpseterrno(ESysEBadf);
      exit;
    end;
- {$ifndef bsd}                          {Should be ifdef Linux, but can't because
-                                                of 1.0.5 cycle}
+ {$ifndef bsd}                         
   {$ifndef Solaris}
-  p^.nextoff:=Sys_lseek(p^.fd,off,seek_set);
+  p^.dd_nextoff:=Sys_lseek(p^.dd_fd,off,seek_set);
   {$endif}
  {$endif}
-  p^.size:=0;
-  p^.loc:=0;
+  p^.dd_size:=0;
+  p^.dd_loc:=0;
 end;
 
 
@@ -1424,11 +1524,11 @@ function TellDir(p:pdir):longint;
 begin
   if p=nil then
    begin
-     errno:=ESysEBadf;
+     fpseterrno(ESysEBadf);
      telldir:=-1;
      exit;
    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
     kernel, this gives nothing... This may have to do with
     the readdir implementation of libc... I also didn't find any trace of
@@ -1441,7 +1541,7 @@ end;
 Function ReadDir(P:pdir):pdirent;
 begin
   ReadDir:=Sys_ReadDir(p);
-  LinuxError:=Errno;
+  linuxerror:=fpgeterrno;
 end;
 
 
@@ -1943,11 +2043,11 @@ Var
   Sysn : utsname;
 begin
   Uname(Sysn);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
   If linuxerror<>0 then
    getdomainname:=''
   else
-   getdomainname:=strpas(@Sysn.domainname[0]);
+   getdomainname:=strpas(@Sysn.domain[0]);
 end;
 
 
@@ -1960,7 +2060,7 @@ Var
   Sysn : utsname;
 begin
   uname(Sysn);
-  linuxerror:=errno;
+  linuxerror:=fpgeterrno;
   If linuxerror<>0 then
    gethostname:=''
   else
@@ -2011,7 +2111,7 @@ begin
   {$endif}
   else
    begin
-     ErrNo:=ESysEINVAL;
+     fpsetErrNo(ESysEINVAL);
      TCSetAttr:=false;
      exit;
    end;
@@ -2178,15 +2278,15 @@ var
     d:=Readdir(dirstream);
     while (d<>nil) do
      begin
-       name:=n+'/'+strpas(@(d^.name));
+       name:=n+'/'+strpas(@(d^.d_name));
        fstat(name,st);
        if linuxerror=0 then
         begin
           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}
              if mysearch(name) then
               begin                 {the device is here}
@@ -2195,7 +2295,7 @@ var
                 exit;
               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
              closedir(dirstream);
              ttyname:=name;
@@ -2212,7 +2312,7 @@ var
 begin
   TTYName:='';
   fstat(handle,st);
-  if (errno<>0) and isatty (handle) then
+  if (fpgeterrno<>0) and isatty (handle) then
    exit;
   mydev:=st.dev;
   myino:=st.ino;
@@ -2554,13 +2654,13 @@ begin
   if thedir=nil then
    begin
      glob:=nil;
-     linuxerror:=errno;
+     linuxerror:=fpgeterrno;
      exit;
    end;
   temp:=basename(path,''); { get the pattern }
-  if thedir^.fd<0 then
+  if thedir^.dd_fd<0 then
    begin
-     linuxerror:=errno;
+     linuxerror:=fpgeterrno;
      glob:=nil;
      exit;
    end;
@@ -2571,7 +2671,7 @@ begin
     buffer:=Sys_readdir(thedir);
     if buffer=nil then
      break;
-    temp2:=strpas(@(buffer^.name[0]));
+    temp2:=strpas(@(buffer^.d_name[0]));
     if fnmatch(temp,temp2) then
      begin
        if root=nil then
@@ -2598,7 +2698,7 @@ begin
           globfree(root);
           break;
         end;
-       move(buffer^.name[0],current^.name^,length(temp2)+1);
+       move(buffer^.d_name[0],current^.name^,length(temp2)+1);
      end;
   until false;
   closedir(thedir);
@@ -2610,17 +2710,17 @@ end;
       FiledescriptorSets
 --------------------------------}
 
-Procedure FD_Zero(var fds:fdSet);
+Procedure FD_Zero(var fds:tfdset);
 {
   Clear the set of filedescriptors
 }
 begin
-  FillChar(fds,sizeof(fdSet),0);
+  FillChar(fds,sizeof(tfdset),0);
 end;
 
 
 
-Procedure FD_Clr(fd:longint;var fds:fdSet);
+Procedure FD_Clr(fd:longint;var fds:tfdset);
 {
   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
 }
@@ -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
 }
@@ -3032,7 +3132,10 @@ End.
 
 {
   $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.
 
   Revision 1.29  2003/05/30 19:37:14  marco

+ 13 - 10
rtl/unix/mouse.pp

@@ -26,7 +26,7 @@ interface
 implementation
 
 uses
-  Unix,Video
+  BaseUnix,Video
 {$ifndef NOGPM}
   ,gpm
 {$endif ndef NOGPM}
@@ -129,7 +129,7 @@ begin
       connect.MinMod:=0;
       connect.MaxMod:=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
           gpm_fs:=-1;
           Gpm_Close;
@@ -145,7 +145,7 @@ begin
   if gpm_fs<>-1 then
     ShowMouse;
 {$else ifdef NOGPM}
-      if (getenv('TERM')='xterm') then
+      if (fpgetenv('TERM')='xterm') then
         begin
           gpm_fs:=-2;
           Write(#27'[?1001s'); { save old hilit tracking }
@@ -187,7 +187,7 @@ begin
       connect.MinMod:=0;
       connect.MaxMod:=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
           Gpm_Close;
           gpm_fs:=-1;
@@ -206,7 +206,7 @@ begin
   else
     SysDetectMouse:=0;
 {$else ifdef NOGPM}
-  if (getenv('TERM')='xterm') then
+  if (fpgetenv('TERM')='xterm') then
     SysDetectMouse:=2;
 {$endif NOGPM}
 end;
@@ -335,7 +335,7 @@ function SysPollMouseEvent(var MouseEvent: TMouseEvent):boolean;
 {$ifndef NOGPM}
 var
   e : TGPMEvent;
-  fds : FDSet;
+  fds : tFDSet;
 {$endif ndef NOGPM}
 begin
   fillchar(MouseEvent,SizeOf(TMouseEvent),#0);
@@ -344,10 +344,10 @@ begin
    exit(false);
   if gpm_fs>0 then
     begin
-      FD_Zero(fds);
-      FD_Set(gpm_fs,fds);
+      fpfdemptyset(fds);
+      fpFDaddset(fds,gpm_fs);
     end;
-  if (Select(gpm_fs+1,@fds,nil,nil,1)>0) then
+  if (fpSelect(gpm_fs+1,@fds,nil,nil,1)>0) then
    begin
      FillChar(e,SizeOf(e),#0);
      { Gpm_snapshot does not work here PM }
@@ -418,7 +418,10 @@ end.
 
 {
   $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
 
   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
-Uses Unix,Strings;
+Uses Unix,BaseUnix,Strings;
 
 {
   include definition of textrec
@@ -87,7 +87,7 @@ begin
   f:=f+#0;
   if lpr='' then
    exit;
-  i:=Fork;
+  i:=fpFork;
   if i<0 then
    exit; { No printing was done. We leave the file where it is.}
   if i=0 then
@@ -102,18 +102,18 @@ begin
      pp^:=@f[1];
      inc(pp);
      pp^:=nil;
-     Execve(lpr,p,envp);
+     fpExecve(lpr,p,envp);
      { In trouble here ! }
      halt(128)
    end
   else
    begin
    { We're in the parent. }
-     waitpid (i,@j,0);
+     fpwaitpid (i,j,0);
      if j<>0 then
       exit;
    { Erase the file }
-     Unlink(f);
+     fpUnlink(f);
    end;
 end;
 
@@ -136,7 +136,7 @@ begin
  If textrec(f).mode <> fmoutput then
   exit;
  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
   textrec(f).mode:=fmclosed
  else
@@ -150,11 +150,11 @@ begin
 {$IFDEF PRINTERDEBUG}
   writeln ('Printer : In CloseLstFile');
 {$ENDIF}
-  fdclose (textrec(f).handle);
+  fpclose (textrec(f).handle);
 { 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
    begin
-     Unlink(StrPas(textrec(f).name));
+     fpUnlink(StrPas(textrec(f).name));
      exit
    end;
 { Non empty : needs printing ? }
@@ -174,7 +174,7 @@ begin
    exit;
   if textrec(f).bufpos<>0 then
    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;
 end;
 
@@ -189,7 +189,7 @@ begin
   if i=0 then
    exit;
   delete (s,i,3);
-  str(GetPid,temp);
+  str(fpGetPid,temp);
   insert(temp,s,i);
 {$IFDEF PRINTERDEBUG}
   writeln ('Print : Filename became : ',s);
@@ -254,7 +254,10 @@ end.
 
 {
   $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
 
 }

+ 20 - 17
rtl/unix/serial.pp

@@ -10,7 +10,7 @@ unit Serial;
 
 interface
 
-uses Unix;
+uses BaseUnix,Unix;
 
 type
 
@@ -70,12 +70,12 @@ implementation
 
 function SerOpen(const DeviceName: String): TSerialHandle;
 begin
-  Result := fdOpen(DeviceName, OPEN_RDWR or OPEN_NOCTTY);
+  Result := fpopen(DeviceName, OPEN_RDWR or OPEN_NOCTTY);
 end;
 
 procedure SerClose(Handle: TSerialHandle);
 begin
-  fdClose(Handle);
+  fpClose(Handle);
 end;
 
 procedure SerFlush(Handle: TSerialHandle);
@@ -85,12 +85,12 @@ end;
 
 function SerRead(Handle: TSerialHandle; var Buffer; Count: LongInt): LongInt;
 begin
-  Result := fdRead(Handle, Buffer, Count);
+  Result := fpRead(Handle, Buffer, Count);
 end;
 
 function SerWrite(Handle: TSerialHandle; var Buffer; Count: LongInt): LongInt;
 begin
-  Result := fdWrite(Handle, Buffer, Count);
+  Result := fpWrite(Handle, Buffer, Count);
 end;
 
 procedure SerSetParams(Handle: TSerialHandle; BitsPerSec: LongInt;
@@ -153,17 +153,17 @@ end;
 
 function SerSaveState(Handle: TSerialHandle): TSerialState;
 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);
 
 end;
 
 procedure SerRestoreState(Handle: TSerialHandle; State: TSerialState);
 begin
-//  ioctl(Handle, TCSETS, @State.tios);
+//  fpioctl(Handle, TCSETS, @State.tios);
     TCSetAttr(handle,TCSANOW,State.tios);
-    ioctl(Handle, TIOCMSET, @State.LineState);
+    fpioctl(Handle, TIOCMSET, @State.LineState);
 end;
 
 procedure SerSetDTR(Handle: TSerialHandle; State: Boolean);
@@ -171,9 +171,9 @@ const
   DTR: Cardinal = TIOCM_DTR;
 begin
   if State then
-    ioctl(Handle, TIOCMBIS, @DTR)
+    fpioctl(Handle, TIOCMBIS, @DTR)
   else
-    ioctl(Handle, TIOCMBIC, @DTR);
+    fpioctl(Handle, TIOCMBIC, @DTR);
 end;
 
 procedure SerSetRTS(Handle: TSerialHandle; State: Boolean);
@@ -181,16 +181,16 @@ const
   RTS: Cardinal = TIOCM_RTS;
 begin
   if State then
-    ioctl(Handle, TIOCMBIS, @RTS)
+    fpioctl(Handle, TIOCMBIS, @RTS)
   else
-    ioctl(Handle, TIOCMBIC, @RTS);
+    fpioctl(Handle, TIOCMBIC, @RTS);
 end;
 
 function SerGetCTS(Handle: TSerialHandle): Boolean;
 var
   Flags: Cardinal;
 begin
-  ioctl(Handle, TIOCMGET, @Flags);
+  fpioctl(Handle, TIOCMGET, @Flags);
   Result := (Flags and TIOCM_CTS) <> 0;
 end;
 
@@ -198,7 +198,7 @@ function SerGetDSR(Handle: TSerialHandle): Boolean;
 var
   Flags: Cardinal;
 begin
-  ioctl(Handle, TIOCMGET, @Flags);
+  fpioctl(Handle, TIOCMGET, @Flags);
   Result := (Flags and TIOCM_DSR) <> 0;
 end;
 
@@ -206,7 +206,7 @@ function SerGetRI(Handle: TSerialHandle): Boolean;
 var
   Flags: Cardinal;
 begin
-  ioctl(Handle, TIOCMGET, @Flags);
+  fpioctl(Handle, TIOCMGET, @Flags);
   Result := (Flags and TIOCM_RI) <> 0;
 end;
 
@@ -215,7 +215,10 @@ end.
 
 {
   $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
 
   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
 
-Uses Unix;
+Uses BaseUnix,SysCall;
 
 { Include filerec and textrec structures }
 {$i filerec.inc}
 {$i textrec.inc}
-
 {******************************************************************************
                           Kernel Socket Callings
 ******************************************************************************}
@@ -152,7 +151,10 @@ end.
 
 {
   $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
 
 }

+ 14 - 4
rtl/unix/systhrds.pp

@@ -45,9 +45,13 @@ interface
 
 implementation
 
+Uses BaseUnix;
+
 {*****************************************************************************
                              Generic overloaded
 *****************************************************************************}
+{$i ostypes.inc}
+{$i ossysch.inc}
 
 { Include generic overloaded routines }
 {$i thread.inc}
@@ -106,6 +110,7 @@ const
   MAP_PRIVATE   =2;
   MAP_ANONYMOUS =$20;
 
+{
 type
   SysCallRegs=record
     reg1,reg2,reg3,reg4,reg5,reg6 : longint;
@@ -149,7 +154,7 @@ begin
   t.reg3:=len;
   Fpmunmap:=syscall(syscall_nr_munmap,t);
 end;
-
+}
 {$else}
 CONST
   { Constansts for MMAP. These are still private for *BSD }
@@ -157,9 +162,7 @@ CONST
   MAP_ANONYMOUS =$1000;
 
   // include some non posix internal types.
-  {$i ostypes.inc}
   // *BSD POSIX. Include headers to syscalls.
-  {$I ossysch.inc}
 
 {$endif}
 
@@ -203,7 +206,11 @@ CONST
 
     procedure SysReleaseThreadVars;
       begin
+	{$ifdef ver1_0}
         Fpmunmap(longint(pthread_getspecific(tlskey)),threadvarblocksize);
+	{$else}
+        Fpmunmap(pointer(pthread_getspecific(tlskey)),threadvarblocksize);
+	{$endif}
       end;
 
 { Include OS independent Threadvar initialization }
@@ -425,7 +432,10 @@ initialization
 end.
 {
   $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
 
   Revision 1.7  2003/01/05 19:11:32  marco

+ 32 - 27
rtl/unix/sysutils.pp

@@ -33,6 +33,8 @@ type
 
 implementation
 
+Uses Baseunix;
+
 { Include platform independent implementation part }
 {$i sysutils.inc}
 
@@ -52,7 +54,7 @@ BEGIN
     1 : LinuxFlags:=LinuxFlags or Open_WrOnly;
     2 : LinuxFlags:=LinuxFlags or Open_RdWr;
   end;
-  FileOpen:=fdOpen (FileName,LinuxFlags);
+  FileOpen:=fpOpen (FileName,LinuxFlags);
   //!! We need to set locking based on Mode !!
 end;
 
@@ -60,7 +62,7 @@ end;
 Function FileCreate (Const FileName : String) : Longint;
 
 begin
-  FileCreate:=fdOpen(FileName,Open_RdWr or Open_Creat or Open_Trunc);
+  FileCreate:=fpOpen(FileName,Open_RdWr or Open_Creat or Open_Trunc);
 end;
 
 
@@ -75,28 +77,28 @@ BEGIN
     1 : LinuxFlags:=LinuxFlags or Open_WrOnly;
     2 : LinuxFlags:=LinuxFlags or Open_RdWr;
   end;
-  FileCreate:=fdOpen(FileName,LinuxFlags or Open_Creat or Open_Trunc);
+  FileCreate:=fpOpen(FileName,LinuxFlags or Open_Creat or Open_Trunc);
 end;
 
 
 Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint;
 
 begin
-  FileRead:=fdRead (Handle,Buffer,Count);
+  FileRead:=fpRead (Handle,Buffer,Count);
 end;
 
 
 Function FileWrite (Handle : Longint; const Buffer; Count : Longint) : Longint;
 
 begin
-  FileWrite:=fdWrite (Handle,Buffer,Count);
+  FileWrite:=fpWrite (Handle,Buffer,Count);
 end;
 
 
 Function FileSeek (Handle,FOffset,Origin : Longint) : Longint;
 
 begin
-  FileSeek:=fdSeek (Handle,FOffset,Origin);
+  FileSeek:=fplSeek (Handle,FOffset,Origin);
 end;
 
 
@@ -104,20 +106,20 @@ Function FileSeek (Handle : Longint; FOffset,Origin : Int64) : Int64;
 
 begin
   {$warning need to add 64bit call }
-  FileSeek:=fdSeek (Handle,FOffset,Origin);
+  FileSeek:=fplSeek (Handle,FOffset,Origin);
 end;
 
 
 Procedure FileClose (Handle : Longint);
 
 begin
-  fdclose(Handle);
+  fpclose(Handle);
 end;
 
 Function FileTruncate (Handle,Size: Longint) : boolean;
 
 begin
-  FileTruncate:=fdtruncate(Handle,Size);
+  FileTruncate:=fpftruncate(Handle,Size)>=0;
 end;
 
 Function FileAge (Const FileName : String): Longint;
@@ -126,11 +128,11 @@ Var Info : Stat;
     Y,M,D,hh,mm,ss : word;
 
 begin
-  If not fstat (FileName,Info) then
+  If  fpstat (FileName,Info)<0 then
     exit(-1)
   else
     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));
     end;
 end;
@@ -141,7 +143,7 @@ Function FileExists (Const FileName : String) : Boolean;
 Var Info : Stat;
 
 begin
-  FileExists:=fstat(filename,Info);
+  FileExists:=fpstat(filename,Info)>=0;
 end;
 
 
@@ -150,8 +152,8 @@ Function DirectoryExists (Const Directory : String) : Boolean;
 Var Info : Stat;
 
 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;
 
 
@@ -159,13 +161,13 @@ Function LinuxToWinAttr (FN : Pchar; Const Info : Stat) : Longint;
 
 begin
   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;
   If (FN[0]='.') and (not (FN[1] in [#0,'.']))  then
     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;
-  If (Info.Mode and
+  If (Info.st_Mode and
       (STAT_IFSOCK or STAT_IFBLK or STAT_IFCHR or STAT_IFIFO))<>0 then
      Result:=Result or faSysFile;
 end;
@@ -196,7 +198,7 @@ begin
   If Result then
     begin
     GlobSearchRec^.GlobHandle:=P^.Next;
-    Result:=Fstat(GlobSearchRec^.Path+StrPas(p^.name),SInfo);
+    Result:=Fpstat(GlobSearchRec^.Path+StrPas(p^.name),SInfo)>=0;
     If Result then
       begin
       Info.Attr:=LinuxToWinAttr(p^.name,SInfo);
@@ -207,8 +209,8 @@ begin
            Attr:=Info.Attr;
            If P^.Name<>Nil then
            Name:=strpas(p^.name);
-           Time:=Sinfo.mtime;
-           Size:=Sinfo.Size;
+           Time:=Sinfo.st_mtime;
+           Size:=Sinfo.st_Size;
            end;
       end;
     P^.Next:=Nil;
@@ -270,10 +272,10 @@ Function FileGetDate (Handle : Longint) : Longint;
 Var Info : Stat;
 
 begin
-  If Not(FStat(Handle,Info)) then
+  If (fpFStat(Handle,Info))<0 then
     Result:=-1
   else
-    Result:=Info.Mtime;
+    Result:=Info.st_Mtime;
 end;
 
 
@@ -290,7 +292,7 @@ Function FileGetAttr (Const FileName : String) : Longint;
 Var Info : Stat;
 
 begin
-  If Not FStat (FileName,Info) then
+  If  FpStat (FileName,Info)<0 then
     Result:=-1
   Else
     Result:=LinuxToWinAttr(Pchar(FileName),Info);
@@ -307,14 +309,14 @@ end;
 Function DeleteFile (Const FileName : String) : Boolean;
 
 begin
-  Result:=UnLink (FileName);
+  Result:=fpUnLink (FileName)>=0;
 end;
 
 
 Function RenameFile (Const OldName, NewName : String) : Boolean;
 
 begin
-  RenameFile:=Unix.FRename(OldNAme,NewName);
+  RenameFile:=BaseUnix.FpRename(OldNAme,NewName)>=0;
 end;
 
 
@@ -477,7 +479,7 @@ end;
 Function GetEnvironmentVariable(Const EnvVar : String) : String;
 
 begin
-  Result:=StrPas(Unix.Getenv(PChar(EnvVar)));
+  Result:=StrPas(BaseUnix.FPGetenv(PChar(EnvVar)));
 end;
 
 
@@ -494,7 +496,10 @@ end.
 {
 
   $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
 
   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
 
 uses
-  Unix;
+  baseUnix;
 
 function putp(Ndx: Longint): Longint;
 var
@@ -651,7 +651,7 @@ begin
   if not assigned(cur_term) then
     RunError(219);
   P := cur_term_strings^[Ndx];
-  putp := fdWrite(cur_term_common^.filedes, P^, StrLen(P));
+  putp := fpWrite(cur_term_common^.filedes, P^, StrLen(P));
 end;
 
 function tputs(Ndx: Word; L1: Longint; F: WriterFunc): Longint;
@@ -741,7 +741,10 @@ function tparam(const char *, char *, int, ...): PChar; cdecl; external;}
 end.
 {
   $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
 
 }

+ 24 - 21
rtl/unix/timezone.inc

@@ -154,17 +154,17 @@ begin
    fn:='localtime';
   if fn[1]<>'/' then
    begin
-     tzdir:=getenv('TZDIR');
+     tzdir:=fpgetenv('TZDIR');
      if tzdir='' then
       tzdir:='/usr/share/zoneinfo';
      if tzdir[length(tzdir)]<>'/' then
       tzdir:=tzdir+'/';
      fn:=tzdir+fn;
    end;
-  f:=fdopen(fn,Open_RdOnly);
+  f:=fpopen(fn,Open_RdOnly);
   if f<0 then
    exit;
-  i:=fdread(f,tzhead,sizeof(tzhead));
+  i:=fpread(f,tzhead,sizeof(tzhead));
   if i<>sizeof(tzhead) then
    exit;
   decode(tzhead.tzh_timecnt);
@@ -184,44 +184,44 @@ begin
   reallocmem(zone_names,chars);
   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
    decode(transitions[i]);
 
   for i:=0 to num_types-1 do
    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);
      types[i].isstd:=0;
      types[i].isgmt:=0;
    end;
 
-  fdread(f,zone_names^,chars);
+  fpread(f,zone_names^,chars);
 
   for i:=0 to num_leaps-1 do
    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].change);
    end;
 
   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
    types[i].isstd:=byte(buf[i]<>0);
   freemem(buf);
 
   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
    types[i].isgmt:=byte(buf[i]<>0);
   freemem(buf);
-  fdclose(f);
+  fpclose(f);
 end;
 
 Const
@@ -240,22 +240,22 @@ var
 
 begin
   GetTimezoneFile:='';
-  f:=fdopen(TimeZoneLocationFile,Open_RdOnly);
+  f:=fpopen(TimeZoneLocationFile,Open_RdOnly);
   if f>0 then
     begin
-    len:=fdread(f,s[1],high(s));
+    len:=fpread(f,s[1],high(s));
     s[0]:=chr(len);
     len:=pos(#10,s);
     if len<>0 then
      s[0]:=chr(len-1);
-    fdclose(f);
+    fpclose(f);
     GetTimezoneFile:=s;
     end
   // Try SuSE
-  else if fstat(TimeZoneFile,info) then
+  else if fpstat(TimeZoneFile,info)>=0 then
     GetTimeZoneFile:=TimeZoneFile
   // Try RedHat
-  else If fstat(AltTimeZoneFile,Info) then
+  else If fpstat(AltTimeZoneFile,Info)>=0 then
       GetTimeZoneFile:=AltTimeZoneFile;
 end;
 
@@ -263,7 +263,7 @@ end;
 procedure InitLocalTime;
 begin
   ReadTimezoneFile(GetTimezoneFile);
-  GetLocalTimezone(GetTimeOfDay);
+  GetLocalTimezone(fptime);
 end;
 
 
@@ -286,7 +286,10 @@ end;
 
 {
   $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
 
 }

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 57 - 500
rtl/unix/unix.pp


+ 16 - 13
rtl/unix/video.pp

@@ -23,7 +23,7 @@ interface
 implementation
 
 uses
-  Unix, Strings, TermInfo;
+  BaseUnix, Unix, Strings, TermInfo;
 
 {$i video.inc}
 
@@ -155,7 +155,7 @@ begin
      pdelay:=strpos(p,'$<');
      if assigned(pdelay) then
        pdelay^:=#0;
-     fdWrite(TTYFd, P^, StrLen(P));
+     fpWrite(TTYFd, P^, StrLen(P));
      SendEscapeSeqNdx:=true;
      if assigned(pdelay) then
        pdelay^:='$';
@@ -165,7 +165,7 @@ end;
 
 procedure SendEscapeSeq(const S: String);
 begin
-  fdWrite(TTYFd, S[1], Length(S));
+  fpWrite(TTYFd, S[1], Length(S));
 end;
 
 
@@ -367,7 +367,7 @@ end;
        blockwrite(f,outbuf,outptr);
        blockwrite(f,nl,1);
 {$endif logging}
-       fdWrite(TTYFd,outbuf,outptr);
+       fpWrite(TTYFd,outbuf,outptr);
        outptr:=0;
      end;
   end;
@@ -476,7 +476,7 @@ begin
   blockwrite(f,outbuf,outptr);
   blockwrite(f,nl,1);
 {$endif logging}
-  fdWrite(TTYFd,outbuf,outptr);
+  fpWrite(TTYFd,outbuf,outptr);
   if InACS then
     SendEscapeSeqNdx(exit_alt_charset_mode);
  {turn autowrap on}
@@ -580,14 +580,14 @@ begin
      { save current terminal characteristics and remove rawness }
      prepareInitVideo;
      { 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 }
      if (Copy(ThisTTY, 1, 8) = '/dev/tty') and
         (ThisTTY[9] >= '0') and (ThisTTY[9] <= '9') then
       begin
         { running on the console }
         FName:='/dev/vcsa' + ThisTTY[9];
-        TTYFd:=fdOpen(FName, Octal(666), Open_RdWr); { open console }
+        TTYFd:=fpOpen(FName, Octal(666), Open_RdWr); { open console }
       end
      else
       TTYFd:=-1;
@@ -600,7 +600,7 @@ begin
         LowAscii:=false;
         TTYFd:=stdoutputhandle;
       end;
-     ioctl(stdinputhandle, TIOCGWINSZ, @WS);
+     fpioctl(stdinputhandle, TIOCGWINSZ, @WS);
      if WS.ws_Col=0 then
       WS.ws_Col:=80;
      if WS.ws_Row=0 then
@@ -739,8 +739,8 @@ begin
    exit;
   if Console then
    begin
-     fdSeek(TTYFd, 4, Seek_Set);
-     fdWrite(TTYFd, VideoBuf^,VideoBufSize);
+     fplSeek(TTYFd, 4, Seek_Set);
+     fpWrite(TTYFd, VideoBuf^,VideoBufSize);
    end
   else
    begin
@@ -763,10 +763,10 @@ var
 begin
   if Console then
    begin
-     fdSeek(TTYFd, 2, Seek_Set);
+     fplSeek(TTYFd, 2, Seek_Set);
      Pos[1]:=NewCursorX;
      Pos[2]:=NewCursorY;
-     fdWrite(TTYFd, Pos, 2);
+     fpWrite(TTYFd, Pos, 2);
    end
   else
    begin
@@ -826,7 +826,10 @@ initialization
 end.
 {
   $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
 
   Revision 1.12  2002/09/07 16:01:28  peter

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác