浏览代码

* Linux 64-bit FS patch from neli for FPC_USE_LIBC

git-svn-id: trunk@6517 -
marco 18 年之前
父节点
当前提交
57cfd89fbd
共有 9 个文件被更改,包括 107 次插入47 次删除
  1. 0 6
      rtl/i386/fastmove.inc
  2. 2 2
      rtl/i386/i386.inc
  3. 27 16
      rtl/linux/i386/stat.inc
  4. 10 3
      rtl/linux/osmacro.inc
  5. 8 6
      rtl/linux/powerpc/stat.inc
  6. 4 2
      rtl/linux/ptypes.inc
  7. 31 0
      rtl/linux/sparc/stat.inc
  8. 1 1
      rtl/linux/sysos.inc
  9. 24 11
      rtl/unix/oscdeclh.inc

+ 0 - 6
rtl/i386/fastmove.inc

@@ -857,10 +857,4 @@ procedure setup_fastmove;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 
 {$endif  FPC_SYSTEM_HAS_MOVE}
 {$endif  FPC_SYSTEM_HAS_MOVE}
 
 
-{$else}
-
-procedure setup_fastmove;{$ifdef SYSTEMINLINE}inline;{$endif}
-  begin
-  end;
-
 {$endif}
 {$endif}

+ 2 - 2
rtl/i386/i386.inc

@@ -94,7 +94,7 @@ function mmx_support : boolean;
        mmx_support:=false;
        mmx_support:=false;
   end;
   end;
 
 
-{$if not defined(INTERNALMOVEFILLCHAR) and not defined(Darwin)}
+{$if not defined(INTERNALMOVEFILLCHAR) and not defined(FPC_SYSTEM_HAS_MOVE)}
 {$define USE_FASTMOVE}
 {$define USE_FASTMOVE}
 {$i fastmove.inc}
 {$i fastmove.inc}
 {$endif INTERNALMOVEFILLCHAR}
 {$endif INTERNALMOVEFILLCHAR}
@@ -1227,7 +1227,7 @@ procedure fpc_cpucodeinit;
     has_sse_support:=sse_support;
     has_sse_support:=sse_support;
     has_mmx_support:=mmx_support;
     has_mmx_support:=mmx_support;
     SysResetFPU;
     SysResetFPU;
-{$ifndef darwin}
+{$ifdef USE_FASTMOVE}
     setup_fastmove;
     setup_fastmove;
 {$endif}
 {$endif}
   end;
   end;

+ 27 - 16
rtl/linux/i386/stat.inc

@@ -41,26 +41,37 @@
 {$packrecords C}
 {$packrecords C}
   Stat =  Record  // No unix typing because of differences
   Stat =  Record  // No unix typing because of differences
                               // kernel <->libc
                               // kernel <->libc
-    st_dev     : int64;
+    st_dev     : dev_t;
     pad1       : word;
     pad1       : word;
-    st_ino     : longint;
-    st_mode,
-    st_nlink,
-    st_uid,
-    st_gid        : longint;
-    st_rdev       : int64;
-    pad2          : word;
-    st_size,
-    st_blksize,
-    st_blocks,
+{$ifdef fs32bit}
+    st_ino     : ino_t;
+{$else}
+    __st_ino   : ino_t;
+{$endif}    
+    st_mode    : mode_t;
+    st_nlink   : nlink_t;
+    st_uid     : uid_t;
+    st_gid     : gid_t;
+    st_rdev    : dev_t;
+    pad2       : word;
+    st_size    : off_t;
+    st_blksize : blksize_t;
+{$ifdef fs32bit}
+    st_blocks  : blkcnt_t;
+{$else}    
+    st_blocks  : blkcnt64_t;
+{$endif}    
     st_atime,
     st_atime,
-    unused1,
+    st_atime_nsec,
     st_mtime,
     st_mtime,
-    unused2,
+    st_mtime_nsec,
     st_ctime,
     st_ctime,
-    unused3,
-    unused4,
-    unused5   : longint;
+    st_ctime_nsec : culong;
+{$ifdef fs32bit}
+    unused4, unused5: culong;
+{$else}    
+    st_ino     : ino64_t;
+{$endif}    
   end;
   end;
 
 
 
 

+ 10 - 3
rtl/linux/osmacro.inc

@@ -90,9 +90,9 @@ end;
 
 
 
 
 {$ifdef FPC_USE_LIBC}
 {$ifdef FPC_USE_LIBC}
-function __fxstat(__ver,filedes : cint; var __stat: tstat): cint; cdecl; external clib name '__fxstat';
-function __xstat(__ver : cint;FileName: PChar; var __stat: tstat): cint; cdecl; external clib name '__xstat';
-function __lxstat(__ver : cint; FileName: PChar; var __stat: tstat): cint; cdecl; external clib name '__lxstat';
+function __fxstat(__ver,filedes : cint; var __stat: tstat): cint; cdecl; external clib name '__fxstat'+suffix64bit;
+function __xstat(__ver : cint;FileName: PChar; var __stat: tstat): cint; cdecl; external clib name '__xstat'+suffix64bit;
+function __lxstat(__ver : cint; FileName: PChar; var __stat: tstat): cint; cdecl; external clib name '__lxstat'+suffix64bit;
 {
 {
 function __fxstat64(__ver : cint; FileDes: Integer; var __stat: tstat): cint; cdecl; external clib name '__fxstat64';
 function __fxstat64(__ver : cint; FileDes: Integer; var __stat: tstat): cint; cdecl; external clib name '__fxstat64';
 function __xstat64(__ver : cint; FileName: PChar; var __stat: tstat): cint; cdecl; external clib name '__xstat64';
 function __xstat64(__ver : cint; FileName: PChar; var __stat: tstat): cint; cdecl; external clib name '__xstat64';
@@ -117,4 +117,11 @@ function  FpStat(path: pchar; var buf : stat): cint;inline;
     __xstat(_STAT_VER,path,buf);
     __xstat(_STAT_VER,path,buf);
   end;
   end;
 
 
+{$ifndef fs32bit}
+function  FpOpen    (path: pchar; flags : cint; mode: TMode):cint; inline;
+  begin
+    FpOpen:=__fpopen(path, flags or O_LARGEFILE, mode);
+  end;
+{$endif}
+
 {$endif FPC_USE_LIBC}
 {$endif FPC_USE_LIBC}

+ 8 - 6
rtl/linux/powerpc/stat.inc

@@ -63,15 +63,16 @@
         st_uid     : uid_t;
         st_uid     : uid_t;
         st_gid     : gid_t;
         st_gid     : gid_t;
         st_rdev    : cULongLong;
         st_rdev    : cULongLong;
+        __pad2     : cushort;
         st_size    : cLongLong;
         st_size    : cLongLong;
         st_blksize : cULong;
         st_blksize : cULong;
-        st_blocks  : cULong;
+        st_blocks  : cULongLong;
         st_atime,
         st_atime,
-        __unused1,
+        st_atime_nsec,
         st_mtime,
         st_mtime,
-        __unused2,
+        st_mtime_nsec,
         st_ctime,
         st_ctime,
-        __unused3,
+        st_ctime_nsec,
         __unused4,
         __unused4,
         __unused5  : cULong);
         __unused5  : cULong);
       1: (
       1: (
@@ -82,9 +83,10 @@
         uid    : uid_t;
         uid    : uid_t;
         gid    : gid_t;
         gid    : gid_t;
         rdev   : cULongLong;
         rdev   : cULongLong;
+        __pad2_: cushort;
         size   : cLongLong;
         size   : cLongLong;
-        blksize,
-        blocks,
+        blksize: cULong;
+        blocks : cULongLong;
         atime,
         atime,
         __unused1_dummy,
         __unused1_dummy,
         mtime,
         mtime,

+ 4 - 2
rtl/linux/ptypes.inc

@@ -20,7 +20,9 @@
 {***********************************************************************}
 {***********************************************************************}
 
 
 { Introduced defines
 { Introduced defines
-    - fs64bit   (should be on if libc switches to a 64-bit system.
+    - fs32bit, should be on if libc only supports sizeof(off_t)=4
+               we assume one typically compiles C applications with 
+               #define _FILE_OFFSET_BITS 64
 
 
 All three tested systems (PPC,Alpha,2x i386) gave the same POSIX limits,
 All three tested systems (PPC,Alpha,2x i386) gave the same POSIX limits,
 and all three 32-bit systems returned completely identical types too
 and all three 32-bit systems returned completely identical types too
@@ -65,7 +67,7 @@ Type
     TnLink   = nlink_t;
     TnLink   = nlink_t;
     pnLink   = ^nlink_t;
     pnLink   = ^nlink_t;
 
 
-{$if not defined(FPC_USE_LIBC) or defined(fs64bit)}
+{$if not defined(fs32bit)}
     off_t    = cint64;          { used for file sizes          }
     off_t    = cint64;          { used for file sizes          }
 {$else}
 {$else}
     off_t    = cint;
     off_t    = cint;

+ 31 - 0
rtl/linux/sparc/stat.inc

@@ -12,6 +12,8 @@
 
 
  **********************************************************************}
  **********************************************************************}
 
 
+{$IFNDEF FPC_USE_LIBC}
+
   Stat = packed record  // No unix typing because of differences
   Stat = packed record  // No unix typing because of differences
     st_dev    : culonglong;
     st_dev    : culonglong;
     st_ino    : culonglong;
     st_ino    : culonglong;
@@ -35,3 +37,32 @@
     __unused5 : cuint;
     __unused5 : cuint;
   end;
   end;
 
 
+{$ELSE FPC_USE_LIBC}
+
+{$PACKRECORDS C}
+
+  Stat = record
+    case byte of
+      st_dev     : cULongLong;
+      st_ino     : cULongLong;
+      st_mode    : mode_t;
+      st_nlink   : nlink_t;
+      st_uid     : uid_t;
+      st_gid     : gid_t;
+      st_rdev    : cULongLong;
+      __pad2     : cushort;
+      st_size    : cLongLong;
+      st_blksize : cULong;
+      st_blocks  : cULongLong;
+      st_atime,
+      st_atime_nsec,
+      st_mtime,
+      st_mtime_nsec,
+      st_ctime,
+      st_ctime_nsec,
+      __unused4,
+      __unused5  : cULong;
+  end;
+
+{$ENDIF FPC_USE_LIBC}
+

+ 1 - 1
rtl/linux/sysos.inc

@@ -57,7 +57,6 @@ end;
 
 
 {$I errno.inc}                          // error numbers
 {$I errno.inc}                          // error numbers
 {$I ostypes.inc}                        // c-types, unix base types, unix base structures
 {$I ostypes.inc}                        // c-types, unix base types, unix base structures
-{$I osmacro.inc}
 
 
 {$ifdef FPC_USE_LIBC}
 {$ifdef FPC_USE_LIBC}
   {$Linklib c}
   {$Linklib c}
@@ -69,6 +68,7 @@ end;
   {$I ossysc.inc}
   {$I ossysc.inc}
 {$endif}
 {$endif}
 
 
+{$I osmacro.inc}
 
 
 {*****************************************************************************
 {*****************************************************************************
                             Error conversion
                             Error conversion

+ 24 - 11
rtl/unix/oscdeclh.inc

@@ -24,6 +24,13 @@ Type TGrpArr = Array [0..0] of TGid;            { C style array workarounds}
      TFilDes = Array [0..1] of cInt;
      TFilDes = Array [0..1] of cInt;
      pFilDes = ^TFilDes;
      pFilDes = ^TFilDes;
 
 
+const
+{$if defined(linux) and defined(cpu32) and not defined(fs32bit)}
+    suffix64bit = '64';
+{$else}    
+    suffix64bit = '';
+{$endif}    
+
     function  FpAccess  (pathname : pchar; amode : cint): cint; cdecl; external clib name 'access';
     function  FpAccess  (pathname : pchar; amode : cint): cint; cdecl; external clib name 'access';
     function  FpChdir   (path : pchar): cint; cdecl; external clib name 'chdir';
     function  FpChdir   (path : pchar): cint; cdecl; external clib name 'chdir';
     function  FpClose   (fd : cint): cint; cdecl; external clib name 'close';
     function  FpClose   (fd : cint): cint; cdecl; external clib name 'close';
@@ -34,14 +41,20 @@ Type TGrpArr = Array [0..0] of TGid;            { C style array workarounds}
     function  FpExecve  (path : pchar; argv : ppchar; envp: ppchar): cint; cdecl; external clib name 'execve';
     function  FpExecve  (path : pchar; argv : ppchar; envp: ppchar): cint; cdecl; external clib name 'execve';
     function  FpFork  : TPid; cdecl; external clib name 'fork';
     function  FpFork  : TPid; cdecl; external clib name 'fork';
     function  FpvFork  : TPid; cdecl; external clib name 'vfork';
     function  FpvFork  : TPid; cdecl; external clib name 'vfork';
-    function  FpFtruncate(fd : cint; flength : TOff): cint; cdecl; external clib name 'ftruncate';
-    function  FpLseek   (fd : cint; offset : TOff; whence : cint): TOff; cdecl; external clib name 'lseek';
+    function  FpFtruncate(fd : cint; flength : TOff): cint; cdecl; external clib name 'ftruncate'+suffix64bit;
+    function  FpLseek   (fd : cint; offset : TOff; whence : cint): TOff; cdecl; external clib name 'lseek'+suffix64bit;
     function  FpMkdir   (path : pchar; mode: TMode):cint; cdecl; external clib name 'mkdir';
     function  FpMkdir   (path : pchar; mode: TMode):cint; cdecl; external clib name 'mkdir';
-    function  FpOpen    (path: pchar; flags : cint; mode: TMode):cint; cdecl; external clib name 'open';
+    function  FpOpen    (path: pchar; flags : cint; mode: TMode):cint;
+{$if defined(linux) and not defined(fs32bit)}
+    { we need a wrapper for linux to automatically pass O_LARGEFILE with flags }
+                                              {$ifdef FPC_IS_SYSTEM}forward;{$endif} inline;
+    function  __FpOpen  (path: pchar; flags : cint; mode: TMode):cint; 
+{$endif}
+                                                                        cdecl; external clib name 'open';
     function  FpOpendir (dirname : pchar): pdir; cdecl; external clib name 'opendir';
     function  FpOpendir (dirname : pchar): pdir; cdecl; external clib name 'opendir';
     function  FpRead    (fd: cint; buf: pchar; nbytes : TSize): TSSize; cdecl; external clib name 'read';
     function  FpRead    (fd: cint; buf: pchar; nbytes : TSize): TSSize; cdecl; external clib name 'read';
-    function  FpReaddir (dirp : pdir) : pdirent;cdecl; external clib name 'readdir';
-    Function  FpReaddir    (var dirp : Dir) : pDirent;cdecl; external clib name 'readdir';
+    function  FpReaddir (dirp : pdir) : pdirent;cdecl; external clib name 'readdir'+suffix64bit;
+    Function  FpReaddir (var dirp : Dir) : pDirent;cdecl; external clib name 'readdir'+suffix64bit;
     function  FpRename  (old : pchar; newpath: pchar): cint; cdecl;external clib name 'rename';
     function  FpRename  (old : pchar; newpath: pchar): cint; cdecl;external clib name 'rename';
     function  FpRmdir   (path : pchar): cint; cdecl; external clib name 'rmdir';
     function  FpRmdir   (path : pchar): cint; cdecl; external clib name 'rmdir';
     function  FpSigaction (sig: cint;var act : sigactionrec; var oact : sigactionrec): cint; cdecl; external clib name 'sigaction';
     function  FpSigaction (sig: cint;var act : sigactionrec; var oact : sigactionrec): cint; cdecl; external clib name 'sigaction';
@@ -59,7 +72,7 @@ Type TGrpArr = Array [0..0] of TGid;            { C style array workarounds}
     function  FpWaitpid (pid : TPid; stat_loc : pcint; options: cint): TPid; cdecl; external clib name 'waitpid';
     function  FpWaitpid (pid : TPid; stat_loc : pcint; options: cint): TPid; cdecl; external clib name 'waitpid';
     function  FpWrite   (fd: cint;buf:pchar; nbytes : TSize): TSSize; cdecl; external clib name 'write';
     function  FpWrite   (fd: cint;buf:pchar; nbytes : TSize): TSSize; cdecl; external clib name 'write';
     procedure FpExit    (status : cint); cdecl; external clib name '_exit';
     procedure FpExit    (status : cint); cdecl; external clib name '_exit';
-    function  fpmmap    (addr:pointer;len:size_t;prot:cint;flags:cint;fd:cint;ofs:off_t):pointer; cdecl; external clib name 'mmap';
+    function  fpmmap    (addr:pointer;len:size_t;prot:cint;flags:cint;fd:cint;ofs:off_t):pointer; cdecl; external clib name 'mmap'+suffix64bit;
     function  fpmunmap  (addr:pointer;len:size_t):cint; cdecl; external clib name 'munmap';
     function  fpmunmap  (addr:pointer;len:size_t):cint; cdecl; external clib name 'munmap';
     function  FpIOCtl   (Handle:cint;Ndx: culong;Data: Pointer):cint; cdecl; external clib name 'ioctl';
     function  FpIOCtl   (Handle:cint;Ndx: culong;Data: Pointer):cint; cdecl; external clib name 'ioctl';
     Function  FPSelect  (N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint; cdecl; external clib name 'select';
     Function  FPSelect  (N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint; cdecl; external clib name 'select';
@@ -109,14 +122,14 @@ Type TGrpArr = Array [0..0] of TGid;            { C style array workarounds}
     function  FpStat      (path: pchar; var buf : stat): cint;inline;
     function  FpStat      (path: pchar; var buf : stat): cint;inline;
 {$endif FPC_IS_SYSTEM}
 {$endif FPC_IS_SYSTEM}
 {$else linux}
 {$else linux}
-    function  FpFstat   (fd : cint; var sb : stat): cint; cdecl; external clib name 'fstat';
-    Function  fpLstat       (path:pchar;Info:pstat):cint;     cdecl; external clib name 'lstat';
-    function  FpStat      (path: pchar; var buf : stat): cint; cdecl; external clib name 'stat';
+    function  FpFstat   (fd : cint; var sb : stat): cint; cdecl; external clib name 'fstat'+suffix64bit;
+    Function  fpLstat   (path:pchar;Info:pstat):cint;     cdecl; external clib name 'lstat'+suffix64bit;
+    function  FpStat    (path: pchar; var buf : stat): cint; cdecl; external clib name 'stat'+suffix64bit;
 {$endif linux}
 {$endif linux}
 
 
-    Function  FpPRead      (fd : cInt; buf: pChar; nbytes : TSize; offset:Toff): TSsize;   cdecl; external clib name 'pread';
+    Function  FpPRead      (fd : cInt; buf: pChar; nbytes : TSize; offset:Toff): TSsize;   cdecl; external clib name 'pread'+suffix64bit;
     function  FpReadV	   (fd: cint; const iov : piovec; iovcnt : cint):TSSize;  cdecl; external clib name 'readv';
     function  FpReadV	   (fd: cint; const iov : piovec; iovcnt : cint):TSSize;  cdecl; external clib name 'readv';
-    Function  FpPWrite     (fd : cInt; buf:pChar; nbytes : TSize; offset:Toff): TSSize;  cdecl; external clib name 'pwrite';
+    Function  FpPWrite     (fd : cInt; buf:pChar; nbytes : TSize; offset:Toff): TSSize;  cdecl; external clib name 'pwrite'+suffix64bit;
     function  FpWriteV	   (fd: cint; const iov : piovec; iovcnt : cint):TSSize;  cdecl; external clib name 'writev';
     function  FpWriteV	   (fd: cint; const iov : piovec; iovcnt : cint):TSSize;  cdecl; external clib name 'writev';
 
 
 {$ifdef linux}
 {$ifdef linux}