mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 11:29:24 +02:00
+ Add pread/pwrite system calls
* Optimize video using pwrite git-svn-id: trunk@2705 -
This commit is contained in:
parent
98bced6f63
commit
740c68106b
@ -527,7 +527,18 @@ Function fpSymlink(oldname,newname:pchar):cint;
|
||||
}
|
||||
|
||||
begin
|
||||
fpsymlink:=do_syscall(syscall_nr_symlink,TSysParam(oldname),TSysParam(newname));
|
||||
fpsymlink:=do_syscall(syscall_nr_symlink,TSysParam(oldname),TSysParam(newname));
|
||||
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;
|
||||
|
||||
|
@ -61,7 +61,19 @@ function Fpwrite(fd: cint;buf:pchar; nbytes : size_t): ssize_t; [public, alias :
|
||||
begin
|
||||
Fpwrite:=do_syscall(syscall_nr_write,Fd,TSysParam(buf),nbytes);
|
||||
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'];
|
||||
|
||||
begin
|
||||
|
@ -59,7 +59,7 @@ Uses Sysctl;
|
||||
{$ifndef FPC_USE_LIBC}
|
||||
{$i syscallh.inc} // do_syscall declarations themselves
|
||||
{$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 settimeo.inc}
|
||||
{$endif}
|
||||
|
@ -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 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';
|
||||
{$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 FpTime (var tloc : TTime): TTime; external name 'FPC_SYSC_TIME';
|
||||
Function FpFtruncate (fd : cInt; flength : TOff): cInt; external name 'FPC_SYSC_FTRUNCATE';
|
||||
|
@ -175,6 +175,20 @@ begin
|
||||
FpWrite:=FpWrite(fd,pchar(@buf),nbytes);
|
||||
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}
|
||||
|
||||
begin
|
||||
|
@ -48,6 +48,10 @@ Function FPFStat (var F:File;Var Info:stat):Boolean; inline;
|
||||
Function FpSignal (signum:longint;Handler:signalhandler):signalhandler;
|
||||
Function FpRead (fd : cInt; var 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:file):cint;
|
||||
Function FpDup2 (var oldfile,newfile:text):cint;
|
||||
|
@ -201,23 +201,22 @@ var oldesc0,oldesc1,oldesc2,oldesc4,oldesc8:word;
|
||||
|
||||
procedure prepare_patching;
|
||||
|
||||
var e:^chgentry;
|
||||
entry : kbentry;
|
||||
var entry : kbentry;
|
||||
i:longint;
|
||||
|
||||
begin
|
||||
for i:=low(kbdchange) to high(kbdchange) do
|
||||
begin
|
||||
e:=@kbdchange[i];
|
||||
entry.kb_table:=e^.tab;
|
||||
entry.kb_index:=e^.idx;
|
||||
fpIoctl(stdinputhandle,KDGKBENT,@entry);
|
||||
e^.oldval:=entry.kb_value;
|
||||
entry.kb_table:=e^.oldtab;
|
||||
entry.kb_index:=e^.oldidx;
|
||||
fpioctl(stdinputhandle,KDGKBENT,@entry);
|
||||
e^.newval:=entry.kb_value;
|
||||
end;
|
||||
with kbdchange[i] do
|
||||
begin
|
||||
entry.kb_table:=tab;
|
||||
entry.kb_index:=idx;
|
||||
fpIoctl(stdinputhandle,KDGKBENT,@entry);
|
||||
oldval:=entry.kb_value;
|
||||
entry.kb_table:=oldtab;
|
||||
entry.kb_index:=oldidx;
|
||||
fpioctl(stdinputhandle,KDGKBENT,@entry);
|
||||
newval:=entry.kb_value;
|
||||
end;
|
||||
{Save old escape code.}
|
||||
entry.kb_index:=1;
|
||||
entry.kb_table:=0;
|
||||
@ -239,7 +238,6 @@ end;
|
||||
|
||||
procedure PatchKeyboard;
|
||||
var
|
||||
e : ^chgentry;
|
||||
entry : kbentry;
|
||||
sentry : kbsentry;
|
||||
i:longint;
|
||||
@ -248,13 +246,13 @@ begin
|
||||
meta:=K_ESCPREFIX;
|
||||
fpIoctl(stdinputhandle,KDSKBMETA,@meta);
|
||||
for i:=low(kbdchange) to high(kbdchange) do
|
||||
begin
|
||||
e:=@kbdchange[i];
|
||||
entry.kb_table:=e^.tab;
|
||||
entry.kb_index:=e^.idx;
|
||||
entry.kb_value:=e^.newval;
|
||||
fpioctl(stdinputhandle,KDSKBENT,@entry);
|
||||
end;
|
||||
with kbdchange[i] do
|
||||
begin
|
||||
entry.kb_table:=tab;
|
||||
entry.kb_index:=idx;
|
||||
entry.kb_value:=newval;
|
||||
fpioctl(stdinputhandle,KDSKBENT,@entry);
|
||||
end;
|
||||
|
||||
{Map kernel escape key code to symbol F32.}
|
||||
entry.kb_index:=1;
|
||||
@ -286,13 +284,13 @@ begin
|
||||
if oldmeta in [K_ESCPREFIX,K_METABIT] then
|
||||
fpioctl(stdinputhandle,KDSKBMETA,@oldmeta);
|
||||
for i:=low(kbdchange) to high(kbdchange) do
|
||||
begin
|
||||
e:=@kbdchange[i];
|
||||
entry.kb_table:=e^.tab;
|
||||
entry.kb_index:=e^.idx;
|
||||
entry.kb_value:=e^.oldval;
|
||||
fpioctl(stdinputhandle,KDSKBENT,@entry);
|
||||
end;
|
||||
with kbdchange[i] do
|
||||
begin
|
||||
entry.kb_table:=tab;
|
||||
entry.kb_index:=idx;
|
||||
entry.kb_value:=oldval;
|
||||
fpioctl(stdinputhandle,KDSKBENT,@entry);
|
||||
end;
|
||||
|
||||
entry.kb_index:=1;
|
||||
entry.kb_table:=0;
|
||||
|
@ -973,8 +973,7 @@ begin
|
||||
{$ifdef linux}
|
||||
if Console=ttylinux then
|
||||
begin
|
||||
fplSeek(TTYFd, 4, Seek_Set);
|
||||
fpWrite(TTYFd, VideoBuf^,VideoBufSize);
|
||||
fppwrite(TTYFd, VideoBuf^,VideoBufSize,4);
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -1003,19 +1002,14 @@ begin
|
||||
{$ifdef linux}
|
||||
if Console=ttylinux then
|
||||
begin
|
||||
fplSeek(TTYFd, 2, Seek_Set);
|
||||
Pos[1]:=NewCursorX;
|
||||
Pos[2]:=NewCursorY;
|
||||
fpWrite(TTYFd, Pos, 2);
|
||||
fppwrite(ttyfd,pos,2,2);
|
||||
end
|
||||
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}
|
||||
{ newcursorx,y and CursorX,Y are 0 based ! }
|
||||
SendEscapeSeq(XY2Ansi(NewCursorX+1,NewCursorY+1,CursorX+1,CursorY+1));
|
||||
CursorX:=NewCursorX;
|
||||
CursorY:=NewCursorY;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user