소스 검색

* 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 -

marco 19 년 전
부모
커밋
24c0b496dd
2개의 변경된 파일45개의 추가작업 그리고 5개의 파일을 삭제
  1. 40 2
      rtl/linux/bunxsysc.inc
  2. 5 3
      rtl/unix/bunxh.inc

+ 40 - 2
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;
 

+ 5 - 3
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';