From 87f0147dff51955d453982f605b0ce286bd08d99 Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 27 Sep 2003 13:04:58 +0000 Subject: [PATCH] * fpISxxx renamed --- rtl/bsd/bunxmacr.inc | 33 +++++++++++---------- rtl/bsd/osmain.inc | 13 +++++---- rtl/bsd/ossysc.inc | 68 +++++++++++++++++++++++--------------------- rtl/bsd/unxsysc.inc | 18 ++++++++++++ rtl/bsd/unxsysch.inc | 1 + 5 files changed, 81 insertions(+), 52 deletions(-) diff --git a/rtl/bsd/bunxmacr.inc b/rtl/bsd/bunxmacr.inc index f87ad989f1..a87590f37a 100644 --- a/rtl/bsd/bunxmacr.inc +++ b/rtl/bsd/bunxmacr.inc @@ -22,42 +22,42 @@ ****************************************************************************} -function FPISDIR(m : TMode): boolean; +function FPS_ISDIR(m : TMode): boolean; begin - FPISDIR:=((m and S_IFMT) = S_IFDIR); + FPS_ISDIR:=((m and S_IFMT) = S_IFDIR); end; -function FPISCHR(m : TMode): boolean; +function FPS_ISCHR(m : TMode): boolean; begin - FPISCHR:=((m and S_IFMT) = S_IFCHR); + FPS_ISCHR:=((m and S_IFMT) = S_IFCHR); end; -function FPISBLK(m : TMode): boolean; +function FPS_ISBLK(m : TMode): boolean; begin - FPISBLK:=((m and S_IFMT) = S_IFBLK); + FPS_ISBLK:=((m and S_IFMT) = S_IFBLK); end; -function FPISREG(m : TMode): boolean; +function FPS_ISREG(m : TMode): boolean; begin - FPISREG:=((m and S_IFMT) = S_IFREG); + FPS_ISREG:=((m and S_IFMT) = S_IFREG); end; -function FPISFIFO(m : TMode): boolean; +function FPS_ISFIFO(m : TMode): boolean; begin - FPISFIFO:=((m and S_IFMT) = S_IFIFO); + FPS_ISFIFO:=((m and S_IFMT) = S_IFIFO); end; -Function FPISLNK(m:TMode):boolean; +Function FPS_ISLNK(m:TMode):boolean; begin - FPISLNK:=((m and S_IFMT) = S_IFLNK); + FPS_ISLNK:=((m and S_IFMT) = S_IFLNK); end; -Function FPISSOCK(m:TMode):boolean; +Function FPS_ISSOCK(m:TMode):boolean; begin - FPISSOCK:=((m and S_IFMT) = S_IFSOCK); + FPS_ISSOCK:=((m and S_IFMT) = S_IFSOCK); end; function wifexited(status : cint): cint; @@ -90,7 +90,10 @@ end; { $Log$ - Revision 1.4 2003-09-17 11:52:05 marco + Revision 1.5 2003-09-27 13:04:58 peter + * fpISxxx renamed + + Revision 1.4 2003/09/17 11:52:05 marco * stat macro fixes voor BSD Revision 1.3 2003/09/14 20:15:01 marco diff --git a/rtl/bsd/osmain.inc b/rtl/bsd/osmain.inc index 33343e1aa6..0932517d82 100644 --- a/rtl/bsd/osmain.inc +++ b/rtl/bsd/osmain.inc @@ -172,7 +172,7 @@ Begin Errno2Inoutres; exit; end; - if FpISDIR(fileinfo.st_mode) then + if FpS_ISDIR(fileinfo.st_mode) then begin InOutRes := 2; exit; @@ -425,7 +425,7 @@ var begin {$ifdef usegetcwd} Fpgetcwd(@tmp[1],255); - dir:=tmp; + dir:=tmp; {$else} dir:=''; thedir:=''; @@ -467,8 +467,8 @@ begin end else begin - if (Errno<>ESysENOENT) then - Exit; + if (Errno<>ESysENOENT) then + Exit; end; until (name<>''); if Fpclosedir(dirstream)<0 then @@ -613,7 +613,10 @@ End. { $Log$ - Revision 1.2 2003-05-29 20:54:09 marco + Revision 1.3 2003-09-27 13:04:58 peter + * fpISxxx renamed + + Revision 1.2 2003/05/29 20:54:09 marco * progname fix. Revision 1.1 2003/01/05 19:01:28 marco diff --git a/rtl/bsd/ossysc.inc b/rtl/bsd/ossysc.inc index 92cab5f2c1..051eee4d4d 100644 --- a/rtl/bsd/ossysc.inc +++ b/rtl/bsd/ossysc.inc @@ -114,7 +114,7 @@ end; {$endif} {$ifdef netbsdmacppc} -{$i sysofft.inc} // odd ball calling convention. +{$i sysofft.inc} // odd ball calling convention. {$else} // generic versions. function Fplseek(fd : cint; offset : off_t; whence : cint): off_t; [public, alias : 'FPC_SYSC_LSEEK']; @@ -477,12 +477,13 @@ begin Fpmunmap:=do_syscall(syscall_nr_munmap,TSysParam(start),Len); end; -Function sbrk(size : longint) : cint; +Function sbrk(size : longint) : pointer; begin - sbrk:=longint(Fpmmap(0,Size,3,MAP_PRIVATE+MAP_ANONYMOUS,-1,0)); // ugh - if sbrk<>(-1) then - errno:=0; - {! It must be -1, not 0 as before, see heap.inc. Should be in sysmmap?} + sbrk:=Fpmmap(0,Size,3,MAP_PRIVATE+MAP_ANONYMOUS,-1,0); + if sbrk=pointer(-1) then + sbrk:=nil + else + errno:=0; end; { @@ -542,50 +543,50 @@ end; function Fpgetcwd(pt:pchar; _size:size_t):pchar;[public, alias :'FPC_SYSC_GETCWD']; {$ifndef darwin} -const intpathmax = 1024-4; // didn't use POSIX data in libc - // implementation. +const intpathmax = 1024-4; // didn't use POSIX data in libc + // implementation. var ept,bpt : pchar; - c : char; - ret : cint; + c : char; + ret : cint; begin if pt=NIL Then - begin + begin // POSIX: undefined. (exit(nil) ?) // BSD : allocate mem for path. - getmem(pt,intpathmax); - if pt=nil Then + getmem(pt,intpathmax); + if pt=nil Then exit(nil); ept:=pt+intpathmax; - end + end else Begin if (_size=0) Then Begin seterrno(ESysEINVAL); - exit(nil); - End; + exit(nil); + End; if (_size=1) Then Begin seterrno(ESysERANGE); - exit(nil); - End; + exit(nil); + End; ept:=pt+_size; - end; + end; ret := do_syscall(syscall_nr___getcwd,TSysParam(pt),TSysParam( 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); + 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; Fpgetcwd:=pt; @@ -598,7 +599,10 @@ end; { $Log$ - Revision 1.10 2003-09-20 12:38:29 marco + Revision 1.11 2003-09-27 13:04:58 peter + * fpISxxx renamed + + Revision 1.10 2003/09/20 12:38:29 marco * FCL now compiles for FreeBSD with new 1.1. Now Linux. Revision 1.9 2003/09/17 16:02:31 marco diff --git a/rtl/bsd/unxsysc.inc b/rtl/bsd/unxsysc.inc index 09e8785fb0..16caf402aa 100644 --- a/rtl/bsd/unxsysc.inc +++ b/rtl/bsd/unxsysc.inc @@ -97,3 +97,21 @@ begin end; +Function fpReadLink(Name:pathstr):pathstr; +{ + Read a link (where it points to) +} +var + LinkName : pathstr; + i : cint; +begin + Name:=Name+#0; + i:=fpReadLink(@Name[1],@LinkName[1],high(linkname)); + if i>0 then + begin + linkname[0]:=chr(i); + fpReadLink:=LinkName; + end + else + fpReadLink:=''; +end; diff --git a/rtl/bsd/unxsysch.inc b/rtl/bsd/unxsysch.inc index 292ef7cfcf..32d996efb0 100644 --- a/rtl/bsd/unxsysch.inc +++ b/rtl/bsd/unxsysch.inc @@ -6,6 +6,7 @@ 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; +Function fpReadLink(name:PathStr):PathStr; Function Fpmmap(start:pointer;len:size_t;prot:cint;flags:cint;fd:cint;offst:off_t):pointer; external name 'FPC_SYSC_MMAP'; Function Fpmunmap(start:pointer;len:size_t):cint; external name 'FPC_SYSC_MUNMAP'; function fpgettimeofday(tp: ptimeval;tzp:ptimezone):cint; external name 'FPC_SYSC_GETTIMEOFDAY';