* Linux 64-bit FS patch from neli for FPC_USE_LIBC

git-svn-id: trunk@6517 -
This commit is contained in:
marco 2007-02-16 22:16:54 +00:00
parent 0926c4c64d
commit 57cfd89fbd
9 changed files with 107 additions and 47 deletions

View File

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

View File

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

View File

@ -41,26 +41,37 @@
{$packrecords C}
Stat = Record // No unix typing because of differences
// kernel <->libc
st_dev : int64;
st_dev : dev_t;
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,
unused1,
st_atime_nsec,
st_mtime,
unused2,
st_mtime_nsec,
st_ctime,
unused3,
unused4,
unused5 : longint;
st_ctime_nsec : culong;
{$ifdef fs32bit}
unused4, unused5: culong;
{$else}
st_ino : ino64_t;
{$endif}
end;

View File

@ -90,9 +90,9 @@ end;
{$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 __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);
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}

View File

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

View File

@ -20,7 +20,9 @@
{***********************************************************************}
{ 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,
and all three 32-bit systems returned completely identical types too
@ -65,7 +67,7 @@ Type
TnLink = 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 }
{$else}
off_t = cint;

View File

@ -12,6 +12,8 @@
**********************************************************************}
{$IFNDEF FPC_USE_LIBC}
Stat = packed record // No unix typing because of differences
st_dev : culonglong;
st_ino : culonglong;
@ -35,3 +37,32 @@
__unused5 : cuint;
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}

View File

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

View File

@ -24,6 +24,13 @@ Type TGrpArr = Array [0..0] of TGid; { C style array workarounds}
TFilDes = Array [0..1] of cInt;
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 FpChdir (path : pchar): cint; cdecl; external clib name 'chdir';
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 FpFork : TPid; cdecl; external clib name 'fork';
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 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 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 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';
@ -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 FpWrite (fd: cint;buf:pchar; nbytes : TSize): TSSize; cdecl; external clib name 'write';
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 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';
@ -109,14 +122,14 @@ Type TGrpArr = Array [0..0] of TGid; { C style array workarounds}
function FpStat (path: pchar; var buf : stat): cint;inline;
{$endif FPC_IS_SYSTEM}
{$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}
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 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';
{$ifdef linux}