mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-24 10:49:18 +02:00
* Killing off old syscall convention anywhere except for oldlinux
This commit is contained in:
parent
9d55df2bd5
commit
221f926099
172
rtl/linux/sysc11.inc
Normal file
172
rtl/linux/sysc11.inc
Normal file
@ -0,0 +1,172 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1999-2000 by Michael Van Canneyt,
|
||||
member of the Free Pascal development team.
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
{ Include syscall itself }
|
||||
{i syscallo.inc}
|
||||
|
||||
Function Sys_mmap(adr,len,prot,flags,fdes,off:longint):longint; // moved from sysunix.inc, used in sbrk
|
||||
|
||||
begin
|
||||
fpmmap(pointer(adr),size_t(len),cint(prot),cint(flags),cint(fdes),off_t(off));
|
||||
end;
|
||||
|
||||
Function Sys_munmap(adr,len:longint):longint; // moved from sysunix.inc, used in sbrk
|
||||
begin
|
||||
fpmunmap(pointer(adr),cint(len));
|
||||
end;
|
||||
|
||||
|
||||
function Clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint;
|
||||
begin
|
||||
if (pointer(func)=nil) or (sp=nil) then
|
||||
exit(-1); // give an error result
|
||||
{$ifdef cpui386}
|
||||
asm
|
||||
{ Insert the argument onto the new stack. }
|
||||
movl sp,%ecx
|
||||
subl $8,%ecx
|
||||
movl args,%eax
|
||||
movl %eax,4(%ecx)
|
||||
|
||||
{ Save the function pointer as the zeroth argument.
|
||||
It will be popped off in the child in the ebx frobbing below. }
|
||||
movl func,%eax
|
||||
movl %eax,0(%ecx)
|
||||
|
||||
{ Do the system call }
|
||||
pushl %ebx
|
||||
movl flags,%ebx
|
||||
movl SysCall_nr_clone,%eax
|
||||
int $0x80
|
||||
popl %ebx
|
||||
test %eax,%eax
|
||||
jnz .Lclone_end
|
||||
|
||||
{ We're in the new thread }
|
||||
subl %ebp,%ebp { terminate the stack frame }
|
||||
call *%ebx
|
||||
{ exit process }
|
||||
movl %eax,%ebx
|
||||
movl $1,%eax
|
||||
int $0x80
|
||||
|
||||
.Lclone_end:
|
||||
movl %eax,__RESULT
|
||||
end;
|
||||
{$endif cpui386}
|
||||
{$ifdef cpum68k}
|
||||
{ No yet translated, my m68k assembler is too weak for such things PM }
|
||||
(*
|
||||
asm
|
||||
{ Insert the argument onto the new stack. }
|
||||
movl sp,%ecx
|
||||
subl $8,%ecx
|
||||
movl args,%eax
|
||||
movl %eax,4(%ecx)
|
||||
|
||||
{ Save the function pointer as the zeroth argument.
|
||||
It will be popped off in the child in the ebx frobbing below. }
|
||||
movl func,%eax
|
||||
movl %eax,0(%ecx)
|
||||
|
||||
{ Do the system call }
|
||||
pushl %ebx
|
||||
movl flags,%ebx
|
||||
movl SysCall_nr_clone,%eax
|
||||
int $0x80
|
||||
popl %ebx
|
||||
test %eax,%eax
|
||||
jnz .Lclone_end
|
||||
|
||||
{ We're in the new thread }
|
||||
subl %ebp,%ebp { terminate the stack frame }
|
||||
call *%ebx
|
||||
{ exit process }
|
||||
movl %eax,%ebx
|
||||
movl $1,%eax
|
||||
int $0x80
|
||||
|
||||
.Lclone_end:
|
||||
movl %eax,__RESULT
|
||||
end;
|
||||
*)
|
||||
{$endif cpum68k}
|
||||
end;
|
||||
|
||||
|
||||
{
|
||||
Interface to Unix ioctl call.
|
||||
Performs various operations on the filedescriptor Handle.
|
||||
Ndx describes the operation to perform.
|
||||
Data points to data needed for the Ndx function. The structure of this
|
||||
data is function-dependent.
|
||||
}
|
||||
Function Sys_IOCtl(Handle,Ndx: Longint;Data: Pointer):LongInt; // This was missing here, instead hardcode in Do_IsDevice
|
||||
|
||||
begin
|
||||
sys_ioctl:=fpioctl(handle,ndx,data);
|
||||
end;
|
||||
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2003-10-30 16:42:25 marco
|
||||
* Killing off old syscall convention anywhere except for oldlinux
|
||||
|
||||
Revision 1.19 2003/10/17 20:56:24 olle
|
||||
* Changed m68k to cpum68k, i386 to cpui386
|
||||
|
||||
Revision 1.18 2003/09/14 20:15:01 marco
|
||||
* Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
|
||||
|
||||
Revision 1.17 2002/12/18 16:43:26 marco
|
||||
* new unix rtl, linux part.....
|
||||
|
||||
Revision 1.16 2002/11/11 21:40:26 marco
|
||||
* rename syscall.inc -> syscallo.inc
|
||||
|
||||
Revision 1.15 2002/10/14 19:39:17 peter
|
||||
* threads unit added for thread support
|
||||
|
||||
Revision 1.14 2002/09/10 21:32:14 jonas
|
||||
+ added "nop" after sc instruction, since normally in case of success,
|
||||
sc returns to the second instruction after itself
|
||||
|
||||
Revision 1.13 2002/09/07 16:01:19 peter
|
||||
* old logs removed and tabs fixed
|
||||
|
||||
Revision 1.12 2002/09/07 13:14:04 florian
|
||||
* hopefully final fix for ppc syscall BTW: The regX numbering is somehow messy
|
||||
|
||||
Revision 1.11 2002/09/03 21:37:54 florian
|
||||
* hopefully final fix for ppc syscall
|
||||
|
||||
Revision 1.10 2002/09/02 20:42:22 florian
|
||||
* another ppc syscall fix
|
||||
|
||||
Revision 1.9 2002/09/02 20:03:20 florian
|
||||
* ppc syscall code fixed
|
||||
|
||||
Revision 1.8 2002/08/19 18:24:05 jonas
|
||||
+ ppc support for do_syscall
|
||||
|
||||
Revision 1.7 2002/07/29 21:28:17 florian
|
||||
* several fixes to get further with linux/ppc system unit compilation
|
||||
|
||||
Revision 1.6 2002/07/28 20:43:48 florian
|
||||
* several fixes for linux/powerpc
|
||||
* several fixes to MT
|
||||
|
||||
}
|
@ -15,21 +15,14 @@
|
||||
|
||||
|
||||
Function fdFlush (fd : Longint) : Boolean;
|
||||
var
|
||||
SR: SysCallRegs;
|
||||
begin
|
||||
SR.reg2 := fd;
|
||||
fdFlush := (SysCall(syscall_nr_fsync, SR)=0);
|
||||
fdFlush := (do_SysCall(syscall_nr_fsync, fd)=0);
|
||||
LinuxError:=fpgetErrno;
|
||||
end;
|
||||
|
||||
Function Flock (fd,mode : longint) : boolean;
|
||||
var
|
||||
sr : Syscallregs;
|
||||
begin
|
||||
sr.reg2:=fd;
|
||||
sr.reg3:=mode;
|
||||
flock:=Syscall(Syscall_nr_flock,sr)=0;
|
||||
flock:=do_Syscall(Syscall_nr_flock,fd,mode)=0;
|
||||
LinuxError:=fpgeterrno;
|
||||
end;
|
||||
|
||||
@ -39,30 +32,20 @@ Function StatFS(Path:Pathstr;Var Info:tstatfs):Boolean;
|
||||
Path is the name of a file/directory on the fileSystem you wish to
|
||||
investigate.
|
||||
}
|
||||
var
|
||||
regs : SysCallregs;
|
||||
begin
|
||||
path:=path+#0;
|
||||
regs.reg2:=longint(@path[1]);
|
||||
regs.reg3:=longint(@Info);
|
||||
StatFS:=(SysCall(SysCall_nr_statfs,regs)=0);
|
||||
StatFS:=(do_SysCall(SysCall_nr_statfs,longint(@path[1]),longint(@Info))=0);
|
||||
LinuxError:=fpgeterrno;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Function StatFS(Fd:Longint;Var Info:tstatfs):Boolean;
|
||||
{
|
||||
Get all information on a fileSystem, and return it in Info.
|
||||
Fd is the file descriptor of a file/directory on the fileSystem
|
||||
you wish to investigate.
|
||||
}
|
||||
var
|
||||
regs : SysCallregs;
|
||||
begin
|
||||
regs.reg2:=Fd;
|
||||
regs.reg3:=longint(@Info);
|
||||
StatFS:=(SysCall(SysCall_nr_fstatfs,regs)=0);
|
||||
StatFS:=(do_SysCall(SysCall_nr_fstatfs,fd,longint(@info))=0);
|
||||
LinuxError:=fpgeterrno;
|
||||
end;
|
||||
|
||||
@ -75,10 +58,8 @@ Function AssignPipe(var pipe_in,pipe_out:longint):boolean; [public, alias : 'FPC
|
||||
}
|
||||
var
|
||||
pip : tpipe;
|
||||
regs : SysCallregs;
|
||||
begin
|
||||
regs.reg2:=longint(@pip);
|
||||
SysCall(SysCall_nr_pipe,regs);
|
||||
do_SysCall(SysCall_nr_pipe,longint(@pip));
|
||||
pipe_in:=pip[1];
|
||||
pipe_out:=pip[2];
|
||||
linuxerror:=fpgeterrno;
|
||||
@ -87,12 +68,10 @@ end;
|
||||
|
||||
Function PClose(Var F:text) :longint;
|
||||
var
|
||||
sr : syscallregs;
|
||||
pl : ^longint;
|
||||
res : longint;
|
||||
begin
|
||||
sr.reg2:=Textrec(F).Handle;
|
||||
SysCall (syscall_nr_close,sr);
|
||||
do_SysCall (syscall_nr_close,Textrec(F).Handle);
|
||||
{ closed our side, Now wait for the other - this appears to be needed ?? }
|
||||
pl:=@(textrec(f).userdata[2]);
|
||||
fpwaitpid(pl^,@res,0);
|
||||
@ -101,12 +80,10 @@ end;
|
||||
|
||||
Function PClose(Var F:file) : longint;
|
||||
var
|
||||
sr : syscallregs;
|
||||
pl : ^longint;
|
||||
res : longint;
|
||||
begin
|
||||
sr.reg2:=FileRec(F).Handle;
|
||||
SysCall (Syscall_nr_close,sr);
|
||||
do_SysCall (Syscall_nr_close,filerec(F).Handle);
|
||||
{ closed our side, Now wait for the other - this appears to be needed ?? }
|
||||
pl:=@(filerec(f).userdata[2]);
|
||||
fpwaitpid(pl^,@res,0);
|
||||
@ -125,23 +102,15 @@ Function IOperm (From,Num : Cardinal; Value : Longint) : boolean;
|
||||
this works ONLY as root.
|
||||
}
|
||||
|
||||
Var
|
||||
Sr : Syscallregs;
|
||||
begin
|
||||
Sr.Reg2:=From;
|
||||
Sr.Reg3:=Num;
|
||||
Sr.Reg4:=Value;
|
||||
IOPerm:=Syscall(Syscall_nr_ioperm,sr)=0;
|
||||
IOPerm:=do_Syscall(Syscall_nr_ioperm,from,num,value)=0;
|
||||
LinuxError:=fpgetErrno;
|
||||
end;
|
||||
|
||||
Function IoPL(Level : longint) : Boolean;
|
||||
|
||||
Var
|
||||
Sr : Syscallregs;
|
||||
begin
|
||||
Sr.Reg2:=Level;
|
||||
IOPL:=Syscall(Syscall_nr_iopl,sr)=0;
|
||||
IOPL:=do_Syscall(Syscall_nr_iopl,level)=0;
|
||||
LinuxError:=fpgetErrno;
|
||||
end;
|
||||
|
||||
@ -149,7 +118,10 @@ end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.14 2003-10-17 22:11:28 olle
|
||||
Revision 1.15 2003-10-30 16:42:25 marco
|
||||
* Killing off old syscall convention anywhere except for oldlinux
|
||||
|
||||
Revision 1.14 2003/10/17 22:11:28 olle
|
||||
* changed i386 to cpui386
|
||||
|
||||
Revision 1.13 2003/09/20 12:45:34 marco
|
||||
|
Loading…
Reference in New Issue
Block a user