summaryrefslogtreecommitdiff
path: root/rtl
diff options
context:
space:
mode:
authormicha <micha@3ad0048d-3df7-0310-abae-a5850022a9f2>2006-11-01 16:32:12 +0000
committermicha <micha@3ad0048d-3df7-0310-abae-a5850022a9f2>2006-11-01 16:32:12 +0000
commitbbe3db7e821adcfce17093771220b40ea71a8873 (patch)
tree049bce5dbba5d4f4637845974840596f0aaca934 /rtl
parent2cbae614c387881473ef41d14b503ba1be1d949f (diff)
downloadfpc-bbe3db7e821adcfce17093771220b40ea71a8873.tar.gz
* fix linux/sysutils 64 bit file handling: make off_t 64 bit
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@5152 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'rtl')
-rw-r--r--rtl/linux/bunxsysc.inc11
-rw-r--r--rtl/linux/ossysc.inc18
-rw-r--r--rtl/linux/ostypes.inc6
-rw-r--r--rtl/linux/ptypes.inc8
-rw-r--r--rtl/objpas/sysutils/filutilh.inc4
-rw-r--r--rtl/unix/bunxh.inc4
-rw-r--r--rtl/unix/sysutils.pp6
7 files changed, 21 insertions, 36 deletions
diff --git a/rtl/linux/bunxsysc.inc b/rtl/linux/bunxsysc.inc
index 14adfff67f..7c0da95d53 100644
--- a/rtl/linux/bunxsysc.inc
+++ b/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;
diff --git a/rtl/linux/ossysc.inc b/rtl/linux/ossysc.inc
index d6f8af1898..fcefc0fb11 100644
--- a/rtl/linux/ossysc.inc
+++ b/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}
diff --git a/rtl/linux/ostypes.inc b/rtl/linux/ostypes.inc
index aa33756011..78e09bca23 100644
--- a/rtl/linux/ostypes.inc
+++ b/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;
diff --git a/rtl/linux/ptypes.inc b/rtl/linux/ptypes.inc
index 51a47d366c..26108977d6 100644
--- a/rtl/linux/ptypes.inc
+++ b/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;
diff --git a/rtl/objpas/sysutils/filutilh.inc b/rtl/objpas/sysutils/filutilh.inc
index e693f35f8e..157011f012 100644
--- a/rtl/objpas/sysutils/filutilh.inc
+++ b/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;
diff --git a/rtl/unix/bunxh.inc b/rtl/unix/bunxh.inc
index 78b03436ec..1b0928f7e6 100644
--- a/rtl/unix/bunxh.inc
+++ b/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';
diff --git a/rtl/unix/sysutils.pp b/rtl/unix/sysutils.pp
index 75d259191e..f3c3441d6c 100644
--- a/rtl/unix/sysutils.pp
+++ b/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;