+ Add pread/pwrite system calls

* Optimize video using pwrite

git-svn-id: trunk@2705 -
This commit is contained in:
daniel 2006-02-27 23:18:35 +00:00
parent 98bced6f63
commit 740c68106b
8 changed files with 79 additions and 40 deletions

View File

@ -527,7 +527,18 @@ Function fpSymlink(oldname,newname:pchar):cint;
} }
begin begin
fpsymlink:=do_syscall(syscall_nr_symlink,TSysParam(oldname),TSysParam(newname)); fpsymlink:=do_syscall(syscall_nr_symlink,TSysParam(oldname),TSysParam(newname));
end; end;
function Fppread(fd: cint; buf: pchar; nbytes : size_t; offset:Toff): ssize_t; [public, alias : 'FPC_SYSC_PREAD'];
begin
Fppread:=do_syscall(syscall_nr_pread,Fd,TSysParam(buf),nbytes,offset,0);
end;
function Fppwrite(fd: cint;buf:pchar; nbytes : size_t; offset:Toff): ssize_t; [public, alias : 'FPC_SYSC_PWRITE'];
begin
Fppwrite:=do_syscall(syscall_nr_pwrite,Fd,TSysParam(buf),nbytes,offset,0);
end;

View File

@ -61,7 +61,19 @@ function Fpwrite(fd: cint;buf:pchar; nbytes : size_t): ssize_t; [public, alias :
begin begin
Fpwrite:=do_syscall(syscall_nr_write,Fd,TSysParam(buf),nbytes); Fpwrite:=do_syscall(syscall_nr_write,Fd,TSysParam(buf),nbytes);
end; end;
{
function Fppread(fd: cint; buf: pchar; nbytes : size_t; offset:Toff): ssize_t; [public, alias : 'FPC_SYSC_PREAD'];
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'];
begin
Fpwrite:=do_syscall(syscall_nr_pwrite,Fd,TSysParam(buf),nbytes,offset);
end;
}
function Fpunlink(path: pchar): cint; [public, alias : 'FPC_SYSC_UNLINK']; function Fpunlink(path: pchar): cint; [public, alias : 'FPC_SYSC_UNLINK'];
begin begin

View File

@ -59,7 +59,7 @@ Uses Sysctl;
{$ifndef FPC_USE_LIBC} {$ifndef FPC_USE_LIBC}
{$i syscallh.inc} // do_syscall declarations themselves {$i syscallh.inc} // do_syscall declarations themselves
{$i sysnr.inc} // syscall numbers. {$i sysnr.inc} // syscall numbers.
{$i bsyscall.inc} // cpu specific syscalls {$i bsyscall.inc} // cpu specific syscalls
{$i bunxsysc.inc} // syscalls in system unit. {$i bunxsysc.inc} // syscalls in system unit.
{$i settimeo.inc} {$i settimeo.inc}
{$endif} {$endif}

View File

@ -79,7 +79,13 @@ Type TGrpArr = Array [0..0] of TGid; { C style array workarounds}
Function FpClose (fd : cInt): cInt; external name 'FPC_SYSC_CLOSE'; Function FpClose (fd : cInt): cInt; external name 'FPC_SYSC_CLOSE';
Function FpRead (fd : cInt; buf: pChar; nbytes : TSize): TSsize; external name 'FPC_SYSC_READ'; Function FpRead (fd : cInt; buf: pChar; nbytes : TSize): TSsize; external name 'FPC_SYSC_READ';
{$ifdef linux}
Function FppRead (fd : cInt; buf: pChar; nbytes : TSize; offset:Toff): TSsize;
{$endif}
Function FpWrite (fd : cInt; buf:pChar; nbytes : TSize): TSsize; external name 'FPC_SYSC_WRITE'; Function FpWrite (fd : cInt; buf:pChar; nbytes : TSize): TSsize; external name 'FPC_SYSC_WRITE';
{$ifdef linux}
Function FppWrite (fd : cInt; buf:pChar; nbytes : TSize; offset:Toff): TSsize;
{$endif}
Function FpLseek (fd : cInt; offset : TOff; whence : cInt): TOff; external name 'FPC_SYSC_LSEEK'; Function FpLseek (fd : cInt; offset : TOff; whence : cInt): TOff; external name 'FPC_SYSC_LSEEK';
Function FpTime (var tloc : TTime): TTime; external name 'FPC_SYSC_TIME'; Function FpTime (var tloc : TTime): TTime; external name 'FPC_SYSC_TIME';
Function FpFtruncate (fd : cInt; flength : TOff): cInt; external name 'FPC_SYSC_FTRUNCATE'; Function FpFtruncate (fd : cInt; flength : TOff): cInt; external name 'FPC_SYSC_FTRUNCATE';

View File

@ -175,6 +175,20 @@ begin
FpWrite:=FpWrite(fd,pchar(@buf),nbytes); FpWrite:=FpWrite(fd,pchar(@buf),nbytes);
end; end;
{$ifdef linux}
function FppRead (fd : cInt;var buf; nbytes : TSize; offset:Toff): TSsize; {$ifdef VER2_0}inline;{$endif}
begin
FppRead:=FppRead(fd,pchar(@buf),nbytes,offset);
end;
function FppWrite (fd : cInt;const buf; nbytes : TSize; offset:Toff): TSsize; {$ifdef VER2_0}inline;{$endif}
begin
FppWrite:=FppWrite(fd,pchar(@buf),nbytes,offset);
end;
{$endif}
Function FpOpen (path : pChar; flags : cInt):cInt; {$ifdef VER2_0}inline;{$endif} Function FpOpen (path : pChar; flags : cInt):cInt; {$ifdef VER2_0}inline;{$endif}
begin begin

View File

@ -48,6 +48,10 @@ Function FPFStat (var F:File;Var Info:stat):Boolean; inline;
Function FpSignal (signum:longint;Handler:signalhandler):signalhandler; Function FpSignal (signum:longint;Handler:signalhandler):signalhandler;
Function FpRead (fd : cInt; var buf; nbytes : TSize): TSsize; inline; Function FpRead (fd : cInt; var buf; nbytes : TSize): TSsize; inline;
Function FpWrite (fd : cInt; const buf; nbytes : TSize): TSsize; inline; Function FpWrite (fd : cInt; const buf; nbytes : TSize): TSsize; inline;
{$ifdef linux}
function FppRead (fd : cInt; var buf; nbytes : TSize; offset:Toff): TSsize; inline;
function FppWrite (fd : cInt; const buf; nbytes : TSize; offset:Toff): TSsize; inline;
{$endif}
Function FpDup (var oldfile,newfile:text):cint; Function FpDup (var oldfile,newfile:text):cint;
Function FpDup (var oldfile,newfile:file):cint; Function FpDup (var oldfile,newfile:file):cint;
Function FpDup2 (var oldfile,newfile:text):cint; Function FpDup2 (var oldfile,newfile:text):cint;

View File

@ -201,23 +201,22 @@ var oldesc0,oldesc1,oldesc2,oldesc4,oldesc8:word;
procedure prepare_patching; procedure prepare_patching;
var e:^chgentry; var entry : kbentry;
entry : kbentry;
i:longint; i:longint;
begin begin
for i:=low(kbdchange) to high(kbdchange) do for i:=low(kbdchange) to high(kbdchange) do
begin with kbdchange[i] do
e:=@kbdchange[i]; begin
entry.kb_table:=e^.tab; entry.kb_table:=tab;
entry.kb_index:=e^.idx; entry.kb_index:=idx;
fpIoctl(stdinputhandle,KDGKBENT,@entry); fpIoctl(stdinputhandle,KDGKBENT,@entry);
e^.oldval:=entry.kb_value; oldval:=entry.kb_value;
entry.kb_table:=e^.oldtab; entry.kb_table:=oldtab;
entry.kb_index:=e^.oldidx; entry.kb_index:=oldidx;
fpioctl(stdinputhandle,KDGKBENT,@entry); fpioctl(stdinputhandle,KDGKBENT,@entry);
e^.newval:=entry.kb_value; newval:=entry.kb_value;
end; end;
{Save old escape code.} {Save old escape code.}
entry.kb_index:=1; entry.kb_index:=1;
entry.kb_table:=0; entry.kb_table:=0;
@ -239,7 +238,6 @@ end;
procedure PatchKeyboard; procedure PatchKeyboard;
var var
e : ^chgentry;
entry : kbentry; entry : kbentry;
sentry : kbsentry; sentry : kbsentry;
i:longint; i:longint;
@ -248,13 +246,13 @@ begin
meta:=K_ESCPREFIX; meta:=K_ESCPREFIX;
fpIoctl(stdinputhandle,KDSKBMETA,@meta); fpIoctl(stdinputhandle,KDSKBMETA,@meta);
for i:=low(kbdchange) to high(kbdchange) do for i:=low(kbdchange) to high(kbdchange) do
begin with kbdchange[i] do
e:=@kbdchange[i]; begin
entry.kb_table:=e^.tab; entry.kb_table:=tab;
entry.kb_index:=e^.idx; entry.kb_index:=idx;
entry.kb_value:=e^.newval; entry.kb_value:=newval;
fpioctl(stdinputhandle,KDSKBENT,@entry); fpioctl(stdinputhandle,KDSKBENT,@entry);
end; end;
{Map kernel escape key code to symbol F32.} {Map kernel escape key code to symbol F32.}
entry.kb_index:=1; entry.kb_index:=1;
@ -286,13 +284,13 @@ begin
if oldmeta in [K_ESCPREFIX,K_METABIT] then if oldmeta in [K_ESCPREFIX,K_METABIT] then
fpioctl(stdinputhandle,KDSKBMETA,@oldmeta); fpioctl(stdinputhandle,KDSKBMETA,@oldmeta);
for i:=low(kbdchange) to high(kbdchange) do for i:=low(kbdchange) to high(kbdchange) do
begin with kbdchange[i] do
e:=@kbdchange[i]; begin
entry.kb_table:=e^.tab; entry.kb_table:=tab;
entry.kb_index:=e^.idx; entry.kb_index:=idx;
entry.kb_value:=e^.oldval; entry.kb_value:=oldval;
fpioctl(stdinputhandle,KDSKBENT,@entry); fpioctl(stdinputhandle,KDSKBENT,@entry);
end; end;
entry.kb_index:=1; entry.kb_index:=1;
entry.kb_table:=0; entry.kb_table:=0;

View File

@ -973,8 +973,7 @@ begin
{$ifdef linux} {$ifdef linux}
if Console=ttylinux then if Console=ttylinux then
begin begin
fplSeek(TTYFd, 4, Seek_Set); fppwrite(TTYFd, VideoBuf^,VideoBufSize,4);
fpWrite(TTYFd, VideoBuf^,VideoBufSize);
end end
else else
begin begin
@ -1003,19 +1002,14 @@ begin
{$ifdef linux} {$ifdef linux}
if Console=ttylinux then if Console=ttylinux then
begin begin
fplSeek(TTYFd, 2, Seek_Set);
Pos[1]:=NewCursorX; Pos[1]:=NewCursorX;
Pos[2]:=NewCursorY; Pos[2]:=NewCursorY;
fpWrite(TTYFd, Pos, 2); fppwrite(ttyfd,pos,2,2);
end end
else else
begin
{$endif}
{ newcursorx,y and CursorX,Y are 0 based ! }
SendEscapeSeq(XY2Ansi(NewCursorX+1,NewCursorY+1,CursorX+1,CursorY+1));
{$ifdef linux}
end;
{$endif} {$endif}
{ newcursorx,y and CursorX,Y are 0 based ! }
SendEscapeSeq(XY2Ansi(NewCursorX+1,NewCursorY+1,CursorX+1,CursorY+1));
CursorX:=NewCursorX; CursorX:=NewCursorX;
CursorY:=NewCursorY; CursorY:=NewCursorY;
end; end;