Browse Source

* fix linux/sysutils 64 bit file handling: make off_t 64 bit

git-svn-id: trunk@5152 -
micha 19 years ago
parent
commit
0043aff24d

+ 0 - 11
rtl/linux/bunxsysc.inc

@@ -509,13 +509,8 @@ begin
 	    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;
@@ -527,14 +522,8 @@ begin
            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;

+ 12 - 6
rtl/linux/ossysc.inc

@@ -41,14 +41,14 @@ begin
  Fpclose:=do_syscall(syscall_nr_close,fd);
 end;
 
-function Fplseek(fd : cint; offset : off64_t; whence : cint): off64_t; [public, alias : 'FPC_SYSC_LSEEK'];
+function Fplseek(fd : cint; offset : off_t; whence : cint): off_t; [public, alias : 'FPC_SYSC_LSEEK'];
 begin
 {$if defined(cpu64) and not defined(cpupowerpc64)}
   result:=do_syscall(syscall_nr_lseek,tsysparam(fd),tsysparam(offset),tsysparam(whence));
 {$else}
-  if do_syscall(syscall_nr__llseek,tsysparam(fd),tsysparam(offset shr 32),tsysparam(offset),
+  if do_syscall(syscall_nr__llseek,tsysparam(fd),tsysparam(hi(offset)),tsysparam(lo(offset)),
       tsysparam(@result), tsysparam(whence)) = -1 then
-    result:=off64_t(-1);
+    result:=off_t(-1);
 {$endif}    
 end;
 
@@ -65,13 +65,13 @@ begin
 end;
 {
 function Fppread(fd: cint; buf: pchar; nbytes : size_t; offset:Toff): ssize_t; [public, alias : 'FPC_SYSC_PREAD'];
-
+   !! check 64 bit off_t sycall 
 begin
   Fpread:=do_syscall(syscall_nr_pread,Fd,TSysParam(buf),nbytes,offset);
 end;
 
 function Fppwrite(fd: cint;buf:pchar; nbytes : size_t; offset:Toff): ssize_t; [public, alias : 'FPC_SYSC_PWRITE'];
-
+   !! check 64 bit off_t sycall 
 begin
  Fpwrite:=do_syscall(syscall_nr_pwrite,Fd,TSysParam(buf),nbytes,offset);
 end;
@@ -299,7 +299,12 @@ function Fpftruncate(fd : cint; flength : off_t): cint; [public, alias : 'FPC_SY
 doesn't have the returnvalue 64-bit problem)}
 
 begin
+{$if defined(cpu64) and not defined(cpupowerpc64)}
  Fpftruncate:=Do_syscall(syscall_nr_ftruncate,TSysParam(fd),TSysParam(flength));
+{$else}
+ Fpftruncate:=Do_syscall(syscall_nr_ftruncate64,TSysParam(fd),TSysParam(lo(flength)),
+  TSysParam(hi(flength)));
+{$endif} 
 end;
 
 function Fpfstat(fd : cint; var sb : stat): cint;  [public, alias : 'FPC_SYSC_FSTAT'];
@@ -482,8 +487,9 @@ begin
 end;
 {$else OLDMMAP}
 begin
+  {$message warning need mmap64 syscall, hi(off) not used}
   Fpmmap:= pointer(do_syscall(syscall_nr_mmap,TSysParam(adr),TSysParam(len),
-    TSysParam(prot),TSysParam(flags),TSysParam(fd),TSysParam(off)));
+    TSysParam(prot),TSysParam(flags),TSysParam(fd),TSysParam(lo(off))));
 end;
 {$endif OLDMMAP}
 

+ 3 - 3
rtl/linux/ostypes.inc

@@ -92,7 +92,7 @@ type
 
   Dirent   = packed record
                 d_fileno      : ino64_t;                        // file number of entry
-                d_off         : off64_t;
+                d_off         : off_t;
                 d_reclen      : cushort;                        // length of string in d_name
                 d_type        : cuchar;                         // file type, see below
                 d_name        : array[0..(255 + 1)-1] of char;  // name must be no longer than this
@@ -140,8 +140,8 @@ type
    FLock     = Record
                 l_type  : cshort;       { lock type: read/write, etc. }
                 l_whence: cshort;       { type of l_start }
-                l_start : off64_t;      { starting offset }
-                l_len   : off64_t;      { len = 0 means until end of file }
+                l_start : off_t;        { starting offset }
+                l_len   : off_t;        { len = 0 means until end of file }
                 l_pid   : pid_t;        { lock owner }
                End;
 

+ 2 - 6
rtl/linux/ptypes.inc

@@ -20,7 +20,7 @@
 {***********************************************************************}
 
 { Introduced defines
-    - 64bitfs   (should be on if libc switches to a 64-bit system.
+    - fs64bit   (should be on if libc switches to a 64-bit system.
 
 All three tested systems (PPC,Alpha,2x i386) gave the same POSIX limits,
 and all three 32-bit systems returned completely identical types too
@@ -65,17 +65,13 @@ Type
     TnLink   = nlink_t;
     pnLink   = ^nlink_t;
 
-{$ifdef cpu64}
+{$if not defined(FPC_USE_LIBC) or defined(fs64bit)}
     off_t    = cint64;          { used for file sizes          }
 {$else}
     off_t    = cint;
 {$endif}
-    off64_t  = cint64;
-
     TOff     = off_t;
     pOff     = ^off_t;
-    toff64   = off64_t;
-    poff64   = ^off64_t;
 
     pid_t    = cint32;          { used as process identifier   }
     TPid     = pid_t;

+ 2 - 2
rtl/objpas/sysutils/filutilh.inc

@@ -76,8 +76,8 @@ Function FileCreate (Const FileName : String) : THandle;
 Function FileCreate (Const FileName : String; Mode : Integer) : THandle;
 Function FileRead (Handle : THandle; Var Buffer; Count : longint) : Longint;
 Function FileWrite (Handle : THandle; const Buffer; Count : Longint) : Longint;
-Function FileSeek (Handle : THandle;FOffset,Origin : Longint) : Longint;
-Function FileSeek (Handle : THandle; FOffset,Origin : Int64) : Int64;
+Function FileSeek (Handle : THandle; FOffset, Origin: Longint) : Longint;
+Function FileSeek (Handle : THandle; FOffset: Int64; Origin: Longint) : Int64;
 Procedure FileClose (Handle : THandle);
 Function FileTruncate (Handle : THandle;Size: Longint) : boolean;
 Function FileAge (Const FileName : String): Longint;

+ 0 - 4
rtl/unix/bunxh.inc

@@ -85,11 +85,7 @@ Type TGrpArr = Array [0..0] of TGid;            { C style array workarounds}
     Function  FpPWrite     (fd : cInt; buf:pChar; nbytes : TSize; offset:Toff): TSSize;
     function  FpWriteV	   (fd: cint; const iov : piovec; iovcnt : cint):TSSize; 
 
-{$ifndef linux}
     Function  FpLseek      (fd : cInt; offset : TOff; whence : cInt): TOff; external name 'FPC_SYSC_LSEEK';
-{$else linux}
-    Function  FpLseek      (fd : cInt; offset : TOff64; whence : cInt): TOff64; external name 'FPC_SYSC_LSEEK';
-{$endif linux}
     Function  FpTime       (var tloc : TTime): TTime; external name 'FPC_SYSC_TIME';
     Function  FpFtruncate  (fd : cInt; flength : TOff): cInt;  external name 'FPC_SYSC_FTRUNCATE';
     Function  FPSigaction  (sig: cInt; act : pSigActionRec; oact : pSigActionRec): cint;  external name 'FPC_SYSC_SIGACTION';

+ 2 - 4
rtl/unix/sysutils.pp

@@ -222,14 +222,12 @@ end;
 Function FileSeek (Handle,FOffset,Origin : Longint) : Longint;
 
 begin
-  FileSeek:=fplSeek (Handle,FOffset,Origin);
+  result:=longint(FileSeek(Handle,int64(FOffset),Origin));
 end;
 
 
-Function FileSeek (Handle : Longint; FOffset,Origin : Int64) : Int64;
-
+Function FileSeek (Handle : Longint; FOffset : Int64; Origin : Longint) : Int64;
 begin
-  {$warning need to add 64bit call }
   FileSeek:=fplSeek (Handle,FOffset,Origin);
 end;