Browse Source

* First series POSIX calls commits. Including getcwd.

marco 23 năm trước cách đây
mục cha
commit
9b47bcfe9b

+ 296 - 6
rtl/bsd/bsdfuncs.inc

@@ -3,8 +3,7 @@
     This file is part of the Free Pascal run time library.
     Copyright (c) 2001 by Free Pascal development team
 
-    An *BSD implementation of Uname and in the future some more
-     calls.
+    Calls needed for the POSIX unit.    
 
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
@@ -15,6 +14,214 @@
 
  **********************************************************************}
 
+{$i syscallh.inc}
+{$i sysnr.inc}
+{$i bsdsysch.inc}
+
+Function sys_Kill(Pid:pid_t;Sig:cint):cint;
+{
+  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
+ sys_kill:=do_syscall(syscall_nr_kill,pid,sig);
+// if kill<0 THEN
+//  Kill:=0;
+end;
+
+Const 
+   SIG_MAXSIG = 128;
+   
+function sys_sigaddset(var _set : sigset_t;signo:cint): cint;
+
+Begin
+   if (signo<=0) or (signo > SIG_MAXSIG) Then
+     Begin
+       seterrno(sys_EINVAL);
+       exit(-1);
+     End;
+   _set[(signo-1) shr 5]:=_set[(signo-1) shr 5] OR (1 shl ((signo-1) and 31));
+   sys_sigaddset:=0;
+End;   
+
+function sys_sigdelset(var _set : sigset_t;signo:cint): cint;
+
+Begin
+   if (signo<=0) or (signo > SIG_MAXSIG) Then
+     Begin
+       seterrno(sys_EINVAL);
+       exit(-1);
+     End;
+   _set[(signo-1) shr 5]:=_set[(signo-1) shr 5] AND NOT (1 shl ((signo-1) and 31));
+   sys_sigdelset:=0;
+End;
+
+function sys_sigemptyset(var _set : sigset_t):cint;
+
+var i :longint;
+
+Begin
+  for i:=0 to 3 DO _set[i]:=0;
+  sys_sigemptyset:=0;
+End;
+
+function sys_sigfillset(var _set : sigset_t):cint;
+
+var i :longint;
+
+Begin
+  for i:=0 to 3 DO _set[i]:=NOT 0;
+  sys_sigfillset:=0;
+End;
+
+function sys_sigismember(const _set : sigset_t;signo:cint): cint;
+
+Begin
+   if (signo<=0) or (signo > SIG_MAXSIG) Then
+     Begin
+       seterrno(sys_EINVAL);
+       exit(-1);
+     End;
+    if ((_set[(signo-1) shr 5]) and (1 shl ((signo-1) and 31)))>0 Then
+     sys_sigismember:=1
+    else 
+     sys_sigismember:=0;
+End;      
+
+function sys_SigProcMask(how:cint;var _set : sigset_t; var _oset : sigset_t):cint;
+{
+  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
+  sys_sigprocmask:=do_syscall(syscall_nr_sigprocmask,longint(how),longint(@_set),longint(@_oset));
+end;
+
+Function sys_SigPending(var _set: sigset_t):cint;
+{
+  Allows examination of pending signals. The signal mask of pending
+  signals is set in SSet
+}
+begin
+  sys_sigpending:=do_syscall(syscall_nr_sigpending,longint(@_set));
+end;
+
+function sys_sigsuspend(const sigmask:sigset_t):cint;
+{
+ Set the signal mask with Mask, and suspend the program until a signal
+ is received.
+}
+
+begin
+  sys_sigsuspend:= do_syscall(syscall_nr_sigsuspend,longint(@sigmask));
+end;
+
+Type // implementation side for now. Should move to BSD unit.
+  ITimerVal= Record
+              It_Interval,
+              It_Value      : TimeVal;
+             end;
+
+Const   ITimer_Real    =0;
+  ITimer_Virtual =1;
+  ITimer_Prof    =2;
+
+
+Function SetITimer(Which : Longint;Const value : ItimerVal; VarOValue:ItimerVal):Longint;
+
+Begin
+ SetItimer:=Do_Syscall(syscall_nr_setitimer,Which,Longint(@Value),longint(@value));
+End;
+
+Function GetITimer(Which : Longint;Var value : ItimerVal):Longint;
+
+Begin
+ GetItimer:=Do_Syscall(syscall_nr_getItimer,Which,Longint(@value));
+End;
+
+Function sys_alarm(Seconds: cuint):cuint;
+
+Var it,oitv : Itimerval;
+
+Begin
+//      register struct itimerval *itp = &it;
+
+ it.it_interval.sec:=0;
+ it.it_interval.usec:=0;
+ it.it_value.sec:=seconds;
+ 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);
+ sys_Alarm:=oitv.it_value.sec;
+End;
+
+function sigblock(mask:cuint):cint;
+{Depreciated, but used by pause.}
+
+var nset,oset: sigset_t;
+
+begin
+ sys_sigemptyset(nset); 
+ nset[0]:=mask;
+ sigblock:= sys_sigprocmask(SIG_BLOCK,nset,oset);   // SIG_BLOCK=1
+ if sigblock=0 Then
+  sigblock:=oset[0];
+end;
+
+function sigpause(sigmask:cint):cint;
+{Depreciated, but used by pause.}
+
+var nset: sigset_t;
+
+begin
+ sys_sigemptyset(nset); 
+ nset[0]:=sigmask;
+ sigpause:= sys_sigsuspend(nset);
+end;
+
+function sys_pause:cint;
+
+begin
+  sys_pause:=sigpause(sigblock(cuint(0)));
+end;
+
+
+function sys_sleep(seconds:cuint):cuint;
+
+var time_to_sleep,time_remaining : timespec;
+
+begin
+	{
+	 * Avoid overflow when `seconds' is huge.  This assumes that
+	 * the maximum value for a time_t is >= INT_MAX.
+	 }
+	if seconds > high(cint) Then
+		sys_sleep:= (seconds - high(cint)) + sys_sleep(HIGH(cint));
+
+	time_to_sleep.tv_sec := seconds;
+	time_to_sleep.tv_nsec := 0;
+	if (sys_nanosleep(time_to_sleep, time_remaining) <> -1) Then
+	 Exit(0);
+	if (geterrno <> sys_EINTR) Then
+	 Exit (seconds);		     { best guess }
+	sys_sleep:= time_remaining.tv_sec;
+	if   (time_remaining.tv_nsec <> 0) Then 
+         inc(sys_sleep);
+End;
+
 function sys_uname(var name:utsname):cint; [public,alias:'FPC_SYSC_UNAME'];
 
 Var
@@ -85,9 +292,95 @@ begin
 	  GetHostName:=0;
 End;
 
+const WAIT_ANY = -1;
+
+function sys_wait(var stat_loc:cint): pid_t;
+{
+  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 // actually a wait4() call with 4th arg 0.
+ sys_Wait:=do_syscall(syscall_nr_WaitPID,WAIT_ANY,longint(@Stat_loc),0,0);
+end;
+
+//function sys_getpid : pid_t;
+
+// begin
+//  sys_getpid:=do_syscall(syscall_nr_getpid);
+// end;
+
+function sys_getppid : pid_t;
+
+begin
+ sys_getppid:=do_syscall(syscall_nr_getppid);
+end;
+
+function sys_getuid : uid_t;
+
+begin
+ sys_getuid:=do_syscall(syscall_nr_getuid);
+end;
+
+function sys_geteuid : uid_t;
+
+begin
+ sys_geteuid:=do_syscall(syscall_nr_geteuid);
+end;
+
+function sys_getgid : gid_t;
+
+begin
+ sys_getgid:=do_syscall(syscall_nr_getgid);
+end;
+
+function sys_getegid : gid_t;
+
+begin
+ sys_getegid:=do_syscall(syscall_nr_getegid);
+end;
+
+function sys_setuid(uid : uid_t): cint;
+
+begin
+ sys_setuid:=do_syscall(syscall_nr_setuid,uid);
+end;
+
+function sys_setgid(gid : gid_t): cint;
+
+begin
+ sys_setgid:=do_syscall(syscall_nr_setgid,gid);
+end;
+
+// type tgrparr=array[0..0] of gid_t;
+
+function sys_getgroups(gidsetsize : cint; var grouplist:tgrparr): cint;
+
+begin
+ sys_getgroups:=do_syscall(syscall_nr_getgroups,gidsetsize,longint(@grouplist));
+end;
+
+function sys_getpgrp : pid_t;
+
+begin
+ sys_getpgrp:=do_syscall(syscall_nr_getpgrp);
+end;
+
+function sys_setsid : pid_t;
+
+begin
+ sys_setsid:=do_syscall(syscall_nr_setsid);
+end;
+
+
 {
  $Log$
- Revision 1.5  2002-10-25 15:46:48  marco
+ Revision 1.6  2002-10-26 18:27:51  marco
+  * First series POSIX calls commits. Including getcwd.
+
+ Revision 1.5  2002/10/25 15:46:48  marco
   * Should be alias.
 
  Revision 1.4  2002/09/08 16:20:27  marco
@@ -104,9 +397,6 @@ End;
 
  Revision 1.1  2002/08/08 11:39:30  marco
   * Initial versions, to allow support for uname in posix.pp
-
-
-
 }
 
 

+ 16 - 5
rtl/bsd/bsdmacro.inc

@@ -51,27 +51,38 @@ end;
 
 function wifexited(status : cint): cint;
 begin
- wifexited:=cint((status AND %1111111) =0);
+ wifexited:=cint((status AND &177) =0);
 end;
 
 function wexitstatus(status : cint): cint;
 begin
- wexitstatus:=(status and %1111111) shl 8;
+ wexitstatus:=(status and &177) shl 8;
 end;
 
 function wstopsig(status : cint): cint;
 begin
- wstopsig:=(status and %1111111) shl 8;
+ wstopsig:=(status and &177) shl 8;
 end;
 
+const wstopped=&177;
+
 function wifsignaled(status : cint): cint;
 begin
- wifsignaled:=cint(((status and %1111111)<>%1111111) and ((status and %1111111)<>0));
+ wifsignaled:=cint(((status and &177)<>wstopped) and ((status and &177)<>0));
+end;
+
+function wtermsig(status : cint):cint;
+
+begin
+ wtermsig:=cint(status and &177);
 end;
 
 {
   $Log$
-  Revision 1.2  2002-09-07 16:01:17  peter
+  Revision 1.3  2002-10-26 18:27:51  marco
+   * First series POSIX calls commits. Including getcwd.
+
+  Revision 1.2  2002/09/07 16:01:17  peter
     * old logs removed and tabs fixed
 
   Revision 1.1  2002/08/19 12:29:11  marco

+ 60 - 3
rtl/bsd/bsdsysc.inc

@@ -395,8 +395,8 @@ function sys_waitpid(pid : pid_t; var stat_loc : cint; options: cint): pid_t; [p
   be a longint.
 }
 
-begin
- sys_WaitPID:=do_syscall(syscall_nr_WaitPID,PID,longint(Stat_loc),options,0);
+begin // actually a wait4() call with 4th arg 0.
+ sys_WaitPID:=do_syscall(syscall_nr_WaitPID,PID,longint(@Stat_loc),options,0);
 end;
 
 function sys_access(const pathname : pchar; amode : cint): cint; [public, alias : 'FPC_SYSC_ACCESS'];
@@ -525,13 +525,70 @@ begin
   sys_readlink:=do_syscall(syscall_nr_readlink, longint(name),longint(linkname),maxlen);
 end;
 
+Function sys_NanoSleep(const req : timespec;var rem : timespec) : longint; [public, alias : 'FPC_SYSC_NANOSLEEP'];
+begin
+  sys_NanoSleep:=Do_SysCall(syscall_nr_nanosleep,longint(@req),longint(@rem));
+end;
 
+function sys_getcwd(pt:pchar; _size:size_t):pchar;[public, alias :'FPC_SYSC_GETCWD'];
+
+const intpathmax = 1024-4;	// didn't use POSIX data in libc
+				// implementation.
+var ept,bpt : pchar;
+    c	    : char;
+    ret	    : cint;
+
+begin
+   if pt=NIL Then
+    begin 
+      // POSIX: undefined. (exit(nil) ?)
+      // BSD  : allocate mem for path.
+      getmem(pt,intpathmax); 
+      if pt=nil Then 
+        exit(nil);
+      ept:=pt+intpathmax;
+    end 
+   else
+    Begin
+      if (_size=0) Then
+        Begin
+          seterrno(sys_EINVAL);
+	  exit(nil);
+        End; 
+      if (_size=1) Then
+        Begin
+          seterrno(sys_ERANGE);
+	  exit(nil);
+        End; 
+      ept:=pt+_size;
+    end; 
+
+    ret := do_syscall(syscall_nr___getcwd,longint(pt),longint( ept - pt));
+    If (ret = 0) Then 
+	If (pt[0] <> '/') Then
+	   Begin
+	     bpt := pt;
+	     ept := pt + strlen(pt) - 1;
+	     While (bpt < ept) Do
+	       Begin
+  		 c := bpt^;
+ 		 bpt^:=ept^;
+		 inc(bpt);
+		 ept^:=c;
+		 dec(ept);		
+               End;
+           End;
+ sys_getcwd:=pt;
+end;
 
 {$endif}
 
 {
  $Log$
- Revision 1.5  2002-10-18 12:19:58  marco
+ Revision 1.6  2002-10-26 18:27:51  marco
+  * First series POSIX calls commits. Including getcwd.
+
+ Revision 1.5  2002/10/18 12:19:58  marco
   * Fixes to get the generic *BSD RTL compiling again + fixes for thread
     support. Still problems left in fexpand. (inoutres?) Therefore fixed
     sysposix not yet commited

+ 6 - 0
rtl/bsd/bsdsysch.inc

@@ -4,3 +4,9 @@ Function Sys_munmap(adr:longint;len:size_t):longint;  external name 'FPC_SYSC_MU
 Function Sys_IOCtl(Handle,Ndx: Longint;Data: Pointer):LongInt;  external name  'FPC_SYSC_IOCTL';
 Function sys_GetPid:LongInt;   external name  'FPC_SYSC_GETPID';
 Function Sys_ReadLink(name,linkname:pchar;maxlen:longint):longint;  external name  'FPC_SYSC_READLINK';
+
+{ Needed in both POSIX (for implementation of sleep()) as POSIX realtime extensions or  Unix/freebsd}
+Function sys_NanoSleep (const req : timespec;var rem : timespec) : longint; external name 'FPC_SYSC_NANOSLEEP';
+
+{ can be used for getdir?}
+Function sys_getcwd (pt:pchar; _size:size_t):pchar; external name 'FPC_SYSC_GETCWD';

+ 6 - 3
rtl/bsd/osposix.inc

@@ -99,8 +99,8 @@ function sys_waitpid(pid : pid_t; var stat_loc : cint; options: cint): pid_t; ex
 function sys_access(const pathname : pchar; amode : cint): cint;external name 'FPC_SYSC_ACCESS';
 function sys_Dup(oldd:cint):cint;  external name 'FPC_SYSC_DUP';
 function sys_Dup2(oldd:cint;newd:cint):cint; external name 'FPC_SYSC_DUP2';
-function geterrno:longint; external name  'FPC_SYS_GETERRNO';
-procedure seterrno (i:longint); external name  'FPC_SYS_SETERRNO';
+function geterrno:cint; external name  'FPC_SYS_GETERRNO';
+procedure seterrno (i:cint); external name  'FPC_SYS_SETERRNO';
 
 {$endif}
 
@@ -110,7 +110,10 @@ procedure seterrno (i:longint); external name  'FPC_SYS_SETERRNO';
 
 {
  $Log$
- Revision 1.5  2002-09-07 16:01:17  peter
+ Revision 1.6  2002-10-26 18:27:51  marco
+  * First series POSIX calls commits. Including getcwd.
+
+ Revision 1.5  2002/09/07 16:01:17  peter
    * old logs removed and tabs fixed
 
  Revision 1.4  2002/08/21 07:03:16  marco

+ 10 - 1
rtl/bsd/system.pp

@@ -34,6 +34,12 @@ begin
  GetErrno:=Errno;
 end;
 
+procedure seterrno(err:longint); [public, alias: 'FPC_SYS_SETERRNO'];
+
+begin
+ Errno:=err;
+end;
+
 { OS independant parts}
 
 {$I system.inc}
@@ -91,7 +97,10 @@ End.
 
 {
   $Log$
-  Revision 1.4  2002-10-18 12:19:58  marco
+  Revision 1.5  2002-10-26 18:27:51  marco
+   * First series POSIX calls commits. Including getcwd.
+
+  Revision 1.4  2002/10/18 12:19:58  marco
    * Fixes to get the generic *BSD RTL compiling again + fixes for thread
      support. Still problems left in fexpand. (inoutres?) Therefore fixed
      sysposix not yet commited

+ 4 - 2
rtl/freebsd/Makefile

@@ -1,5 +1,5 @@
 #
-# Don't edit, this file is generated by FPCMake Version 1.1 [2002/10/20]
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/10/17]
 #
 default: all
 MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx
@@ -240,7 +240,7 @@ GRAPHDIR=$(INC)/graph
 ifndef USELIBGGI
 USELIBGGI=NO
 endif
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas strings $(LINUXUNIT) unix initc dos crt objects printer sysutils typinfo math varutils cpu mmx charset ucomplex getopts heaptrc lineinfo errors sockets gpm ipc terminfo video mouse keyboard console serial variants types systhrds
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas strings $(LINUXUNIT) unix initc dos crt objects printer sysutils typinfo math varutils cpu mmx charset ucomplex getopts heaptrc lineinfo errors sockets gpm ipc terminfo video mouse keyboard console serial variants types systhrds sysctl posix
 override TARGET_LOADERS+=prt0 cprt0
 override TARGET_RSTS+=math varutils typinfo
 override INSTALL_FPCPACKAGE=y y
@@ -1254,3 +1254,5 @@ errors$(PPUEXT) : $(UNIXINC)/errors.pp strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 ipc$(PPUEXT) : $(UNIXINC)/ipc.pp unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 terminfo$(PPUEXT) : terminfo.pp unix$(PPUEXT)
 callspec$(PPUEXT) : $(INC)/callspec.pp $(SYSTEMUNIT)$(PPUEXT)
+sysctl$(PPUEXT) : $(BSDINC)/sysctl.pp $(SYSTEMUNIT)$(PPUEXT)
+posix$(PPUEXT) : $(POSIXINC)/posix.pp sysctl$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)

+ 5 - 1
rtl/freebsd/Makefile.fpc

@@ -16,7 +16,7 @@ units=$(SYSTEMUNIT) objpas strings \
       sysutils typinfo math varutils \
       cpu mmx charset ucomplex getopts heaptrc lineinfo \
       errors sockets gpm ipc terminfo \
-      video mouse keyboard console serial variants types systhrds
+      video mouse keyboard console serial variants types systhrds sysctl posix
 rsts=math varutils typinfo
 
 [require]
@@ -210,3 +210,7 @@ ipc$(PPUEXT) : $(UNIXINC)/ipc.pp unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 terminfo$(PPUEXT) : terminfo.pp unix$(PPUEXT)
 
 callspec$(PPUEXT) : $(INC)/callspec.pp $(SYSTEMUNIT)$(PPUEXT)
+
+sysctl$(PPUEXT) : $(BSDINC)/sysctl.pp $(SYSTEMUNIT)$(PPUEXT)
+
+posix$(PPUEXT) : $(POSIXINC)/posix.pp sysctl$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)

+ 5 - 2
rtl/freebsd/signal.inc

@@ -77,7 +77,7 @@ const
  * those in mcontext_t.
  }
 
-type sigset_t = array[0..15] of byte;
+type sigset_t = array[0..3] of Longint;
 
     PSigContextRec = ^SigContextRec;
     SigContextRec = record
@@ -152,7 +152,10 @@ type sigset_t = array[0..15] of byte;
 
 {
   $Log$
-  Revision 1.5  2002-10-18 12:19:59  marco
+  Revision 1.6  2002-10-26 18:27:52  marco
+   * First series POSIX calls commits. Including getcwd.
+
+  Revision 1.5  2002/10/18 12:19:59  marco
    * Fixes to get the generic *BSD RTL compiling again + fixes for thread
      support. Still problems left in fexpand. (inoutres?) Therefore fixed
      sysposix not yet commited

+ 11 - 8
rtl/freebsd/sysnr.inc

@@ -36,7 +36,6 @@ const
  syscall_nr_getpid                      = 20;
  syscall_nr_mount                       = 21;
  syscall_nr_unmount                     = 22;
- syscall_nr_setuid                      = 23;
  syscall_nr_getuid                      = 24;
  syscall_nr_geteuid                     = 25;
  syscall_nr_ptrace                      = 26;
@@ -76,9 +75,7 @@ const
  syscall_nr_mprotect                    = 74;
  syscall_nr_madvise                     = 75;
  syscall_nr_mincore                     = 78;
- syscall_nr_getgroups                   = 79;
  syscall_nr_setgroups                   = 80;
- syscall_nr_getpgrp                     = 81;
  syscall_nr_setpgid                     = 82;
  syscall_nr_swapon                      = 85;
 
@@ -107,7 +104,7 @@ const
  syscall_nr_rmdir                       =137;
  syscall_nr_utimes                      =138;
  syscall_nr_adjtime                     =140;
- syscall_nr_setsid                      =147;
+
  syscall_nr_quotactl                    =148;
  syscall_nr_nfssvc                      =155;
  syscall_nr_statfs                      =157;
@@ -124,7 +121,6 @@ const
  syscall_nr_pread                       =173;
  syscall_nr_pwrite                      =174;
  syscall_nr_ntp_adjtime                 =176;
- syscall_nr_setgid                      =181;
  syscall_nr_setegid                     =182;
  syscall_nr_seteuid                     =183;
  syscall_nr_stat                        =188;
@@ -202,7 +198,6 @@ syscall_nr_getdirentries                =196;
  syscall_nr_thr_wakeup                  =323;
  syscall_nr_mlockall                    =324;
  syscall_nr_munlockall                  =325;
- syscall_nr___getcwd                    =326;
  syscall_nr_sched_setparam              =327;
  syscall_nr_sched_getparam              =328;
  syscall_nr_sched_setscheduler          =329;
@@ -240,10 +235,15 @@ syscall_nr_getdirentries                =196;
 }
 
 {More or less checked BSD syscalls}
+ syscall_nr___getcwd                    =326;
  syscall_nr_getitimer                   = 86;
  syscall_nr_setitimer                   = 83;
  syscall_nr___syscall                   =198;
-
+ syscall_nr_setsid                      =147;
+ syscall_nr_getpgrp                     = 81;
+ syscall_nr_setuid                      = 23;
+ syscall_nr_setgid                      =181;
+ syscall_nr_getgroups                   = 79;
  syscall_nr_sysarch                     = 165;
  syscall_nr_accept                      =  30;
  syscall_nr_access                      =  33;
@@ -318,7 +318,10 @@ syscall_nr_getdirentries                =196;
 
 {
   $Log$
-  Revision 1.7  2002-09-07 16:01:18  peter
+  Revision 1.8  2002-10-26 18:27:52  marco
+   * First series POSIX calls commits. Including getcwd.
+
+  Revision 1.7  2002/09/07 16:01:18  peter
     * old logs removed and tabs fixed
 
   Revision 1.6  2002/08/19 12:32:34  marco

+ 14 - 3
rtl/posix/sysposix.inc

@@ -434,19 +434,26 @@ Begin
    InOutRes:=3;
 End;
 
-
+{$define usegetcwd}
 
 procedure getdir(drivenr : byte;var dir : shortstring);
 var
+{$ifndef usegetcwd}
   cwdinfo      : stat;
   rootinfo     : stat;
   thedir,dummy : string[255];
   dirstream    : pdir;
   d            : pdirent;
   name         : string[255];
-  tmp          : string[255];
   thisdir      : stat;
+{$endif}
+  tmp          : string[255];
+
 begin
+{$ifdef usegetcwd}
+ sys_getcwd(@tmp[1],255);
+ dir:=tmp;		
+{$else}
   dir:='';
   thedir:='';
   dummy:='';
@@ -522,6 +529,7 @@ begin
         exit;
       end;
   until false;
+ {$endif}
 end;
 
 
@@ -649,7 +657,10 @@ End.
 *)
 {
  $Log$
- Revision 1.4  2002-09-07 16:01:26  peter
+ Revision 1.5  2002-10-26 18:27:52  marco
+  * First series POSIX calls commits. Including getcwd.
+
+ Revision 1.4  2002/09/07 16:01:26  peter
    * old logs removed and tabs fixed
 
  Revision 1.3  2002/08/20 12:50:22  marco

+ 6 - 1
rtl/unix/systhrds.pp

@@ -156,6 +156,8 @@ CONST
   MAP_PRIVATE   =2;
   MAP_ANONYMOUS =$1000;
 
+  // include some non posix internal types.
+  {$i bsdtypes.inc}
   // *BSD POSIX. Include headers to syscalls.
   {$I bsdsysch.inc}
 
@@ -380,7 +382,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.3  2002-10-18 18:05:06  marco
+  Revision 1.4  2002-10-26 18:27:52  marco
+   * First series POSIX calls commits. Including getcwd.
+
+  Revision 1.3  2002/10/18 18:05:06  marco
    * $I pthread.inc instead of pthreads.inc
 
   Revision 1.2  2002/10/18 12:19:59  marco