+ add splice and sync_file_range linux-only syscalls

git-svn-id: trunk@12107 -
This commit is contained in:
micha 2008-11-15 15:43:52 +00:00
parent 341cec908d
commit d7e90f9e48
2 changed files with 36 additions and 8 deletions

View File

@ -22,7 +22,7 @@ unit Linux;
interface interface
uses uses
BaseUnix;//, ctypes; BaseUnix, unixtype;
type type
TSysInfo = record TSysInfo = record
@ -312,14 +312,21 @@ const
function vmsplice (fdout: cInt; iov: PIOVec; count: size_t; flags: cuInt): cInt; {$ifdef FPC_USE_LIBC} cdecl; external name 'vmsplice'; {$ENDIF} function vmsplice (fdout: cInt; iov: PIOVec; count: size_t; flags: cuInt): cInt; {$ifdef FPC_USE_LIBC} cdecl; external name 'vmsplice'; {$ENDIF}
{* Splice two files together. *} {* Splice two files together. *}
// NOTE: offin and offout should be "off64_t" but we don't have that type. It's an "always 64 bit offset" so I use cint64 function splice (fdin: cInt; offin: off64_t; fdout: cInt;
function splice (fdin: cInt; offin: cInt64; fdout: cInt; offout: off64_t; len: size_t; flags: cuInt): cInt; {$ifdef FPC_USE_LIBC} cdecl; external name 'splice'; {$ENDIF}
offout: cInt64; len: size_t; flags: cuInt): cInt; {$ifdef FPC_USE_LIBC} cdecl; external name 'splice'; {$ENDIF}
function tee(fd_in: cInt; fd_out: cInt; len: size_t; flags: cuInt): cInt; {$ifdef FPC_USE_LIBC} cdecl; external name 'tee'; {$ENDIF} function tee(fd_in: cInt; fd_out: cInt; len: size_t; flags: cuInt): cInt; {$ifdef FPC_USE_LIBC} cdecl; external name 'tee'; {$ENDIF}
{$endif} // x86 {$endif} // x86
const
{ flags for sync_file_range }
SYNC_FILE_RANGE_WAIT_BEFORE = 1;
SYNC_FILE_RANGE_WRITE = 2;
SYNC_FILE_RANGE_WAIT_AFTER = 4;
function sync_file_range(fd: cInt; offset, nbytes: off64_t; flags: cuInt): cInt; {$ifdef FPC_USE_LIBC} cdecl; external name 'sync_file_range'; {$ENDIF}
implementation implementation
@ -446,13 +453,14 @@ end;
function vmsplice (fdout: cInt; iov: PIOVec; count: size_t; flags: cuInt): cInt; function vmsplice (fdout: cInt; iov: PIOVec; count: size_t; flags: cuInt): cInt;
begin begin
vmsplice := do_syscall(syscall_nr_vmsplice, TSysParam(fdout), TSysParam(iov), TSysParam(count), TSysParam(flags)); vmsplice := do_syscall(syscall_nr_vmsplice, TSysParam(fdout), TSysParam(iov),
TSysParam(count), TSysParam(flags));
end; end;
function splice (fdin: cInt; offin: cint64; fdout: cInt; offout: cint64; len: size_t; flags: cuInt): cInt; function splice (fdin: cInt; offin: off64_t; fdout: cInt; offout: off64_t; len: size_t; flags: cuInt): cInt;
begin begin
splice := do_syscall(syscall_nr_splice, TSysParam(fdin), TSysParam(offin), TSysParam(fdout), TSysParam(offout), splice := do_syscall(syscall_nr_splice, TSysParam(fdin), TSysParam(@offin),
TSysParam(len), TSysParam(flags)); TSysParam(fdout), TSysParam(@offout), TSysParam(len), TSysParam(flags));
end; end;
function tee(fd_in: cInt; fd_out: cInt; len: size_t; flags: cuInt): cInt; function tee(fd_in: cInt; fd_out: cInt; len: size_t; flags: cuInt): cInt;
@ -463,6 +471,22 @@ end;
{$endif} // x86 {$endif} // x86
function sync_file_range(fd: cInt; offset: off64_t; nbytes: off64_t; flags: cuInt): cInt;
begin
{$ifdef cpu64}
sync_file_range := do_syscall(syscall_nr_sync_file_range, TSysParam(fd), TSysParam(offset),
TSysParam(nbytes), TSysParam(flags));
{$else}
{$if defined(cpupowerpc) or defined(cpuarm)}
sync_file_range := do_syscall(syscall_nr_sync_file_range2, TSysParam(fd), TSysParam(flags),
TSysParam(hi(offset)), TSysParam(lo(offset)), TSysParam(hi(nbytes)), TSysParam(lo(nbytes)));
{$else}
sync_file_range := do_syscall(syscall_nr_sync_file_range, TSysParam(fd), TSysParam(lo(offset)),
TSysParam(hi(offset)), TSysParam(lo(nbytes)), TSysParam(hi(nbytes)), TSysParam(flags));
{$endif}
{$endif}
end;
{$endif} // non-libc {$endif} // non-libc
{ FUTEX_OP is a macro, doesn't exist in libC as function} { FUTEX_OP is a macro, doesn't exist in libC as function}

View File

@ -71,6 +71,10 @@ Type
TOff = off_t; TOff = off_t;
pOff = ^off_t; pOff = ^off_t;
off64_t = cint64;
TOff64 = off64_t;
pOff64 = ^off64_t;
pid_t = cint; { used as process identifier } pid_t = cint; { used as process identifier }
TPid = pid_t; TPid = pid_t;
pPid = ^pid_t; pPid = ^pid_t;