From 24c0b496dd219dad1f673df54cfc202212a32368 Mon Sep 17 00:00:00 2001 From: marco Date: Sat, 4 Mar 2006 12:40:45 +0000 Subject: [PATCH] * commit of the syscall based linux support for pwrite/writev, still under {$ifdef linux}. This to fix x86_64 breakage. git-svn-id: trunk@2731 - --- rtl/linux/bunxsysc.inc | 42 ++++++++++++++++++++++++++++++++++++++++-- rtl/unix/bunxh.inc | 8 +++++--- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/rtl/linux/bunxsysc.inc b/rtl/linux/bunxsysc.inc index ab060065b7..405946fcef 100644 --- a/rtl/linux/bunxsysc.inc +++ b/rtl/linux/bunxsysc.inc @@ -533,12 +533,50 @@ end; function Fppread(fd: cint; buf: pchar; nbytes : size_t; offset:Toff): ssize_t; [public, alias : 'FPC_SYSC_PREAD']; begin - Fppread:=do_syscall(syscall_nr_pread,Fd,TSysParam(buf),nbytes,offset,0); + + {$ifdef CPU64} + Fppread:=do_syscall(syscall_nr_pread64,Fd,TSysParam(buf),nbytes,TSysParam(OffSet}); + {$else} + Fppread:=do_syscall(syscall_nr_pread,Fd,TSysParam(buf),nbytes, + {$ifdef 64bitfs} + {$ifdef FPC_BIG_ENDIAN} hi(offset),lo(offset){$endif} + {$ifdef FPC_LITTLE_ENDIAN} lo(offset),hi(offset){$endif} + {$else} + {$ifdef FPC_BIG_ENDIAN} 0,lo(offset){$endif} + {$ifdef FPC_LITTLE_ENDIAN} lo(offset),0{$endif} + {$endif} + ); + {$endif} end; function Fppwrite(fd: cint;buf:pchar; nbytes : size_t; offset:Toff): ssize_t; [public, alias : 'FPC_SYSC_PWRITE']; begin - Fppwrite:=do_syscall(syscall_nr_pwrite,Fd,TSysParam(buf),nbytes,offset,0); + {$ifdef CPU64} + Fppwrite:=do_syscall(syscall_nr_pwrite64,Fd,TSysParam(buf),nbytes,TSysParam(OffSet}); + {$else} + Fppwrite:=do_syscall(syscall_nr_pwrite,Fd,TSysParam(buf),nbytes, + // ,0 = possible alignment here. + {$ifdef 64bitfs} + {$ifdef FPC_BIG_ENDIAN} hi(offset),lo(offset){$endif} + {$ifdef FPC_LITTLE_ENDIAN} lo(offset),hi(offset){$endif} + {$else} + {$ifdef FPC_BIG_ENDIAN} 0,lo(offset){$endif} + {$ifdef FPC_LITTLE_ENDIAN} lo(offset),0{$endif} + {$endif} + ); + {$endif} +end; + +function Fpreadv(fd: cint; const iov : piovec; iovcnt : cint):ssize_t; [public, alias : 'FPC_SYSC_READV']; + +begin + Fpreadv:=do_syscall(syscall_nr_readv,Fd,TSysParam(iov),iovcnt); +end; + +function Fpwritev(fd: cint; const iov : piovec; iovcnt : cint):ssize_t; [public, alias : 'FPC_SYSC_WRITEV']; + +begin + Fpwritev:=do_syscall(syscall_nr_writev,Fd,TSysParam(iov),iovcnt); end; diff --git a/rtl/unix/bunxh.inc b/rtl/unix/bunxh.inc index 2643825b20..cf2fc917a3 100644 --- a/rtl/unix/bunxh.inc +++ b/rtl/unix/bunxh.inc @@ -80,11 +80,13 @@ Type TGrpArr = Array [0..0] of TGid; { C style array workarounds} Function FpRead (fd : cInt; buf: pChar; nbytes : TSize): TSsize; external name 'FPC_SYSC_READ'; {$ifdef linux} - Function FppRead (fd : cInt; buf: pChar; nbytes : TSize; offset:Toff): TSsize; + Function FpPRead (fd : cInt; buf: pChar; nbytes : TSize; offset:Toff): TSsize; + function FpReadV (fd: cint; const iov : piovec; iovcnt : cint):TSSize; {$endif} - Function FpWrite (fd : cInt; buf:pChar; nbytes : TSize): TSsize; external name 'FPC_SYSC_WRITE'; + Function FpWrite (fd : cInt; buf:pChar; nbytes : TSize): TSsize; external name 'FPC_SYSC_WRITE'; {$ifdef linux} - Function FppWrite (fd : cInt; buf:pChar; nbytes : TSize; offset:Toff): TSsize; + Function FpPWrite (fd : cInt; buf:pChar; nbytes : TSize; offset:Toff): TSSize; + function FpWriteV (fd: cint; const iov : piovec; iovcnt : cint):TSSize; {$endif} Function FpLseek (fd : cInt; offset : TOff; whence : cInt): TOff; external name 'FPC_SYSC_LSEEK'; Function FpTime (var tloc : TTime): TTime; external name 'FPC_SYSC_TIME';