mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 21:09:27 +02:00
* linux unit moved and renamed.
git-svn-id: trunk@2543 -
This commit is contained in:
parent
a0ee97efb1
commit
c2d5016d77
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -3913,6 +3913,7 @@ rtl/linux/i386/syscallh.inc svneol=native#text/plain
|
|||||||
rtl/linux/i386/sysnr.inc svneol=native#text/plain
|
rtl/linux/i386/sysnr.inc svneol=native#text/plain
|
||||||
rtl/linux/ipccall.inc svneol=native#text/plain
|
rtl/linux/ipccall.inc svneol=native#text/plain
|
||||||
rtl/linux/ipcsys.inc svneol=native#text/plain
|
rtl/linux/ipcsys.inc svneol=native#text/plain
|
||||||
|
rtl/linux/linux.pp svneol=native#text/plain
|
||||||
rtl/linux/linuxvcs.pp -text
|
rtl/linux/linuxvcs.pp -text
|
||||||
rtl/linux/m68k/bsyscall.inc svneol=native#text/plain
|
rtl/linux/m68k/bsyscall.inc svneol=native#text/plain
|
||||||
rtl/linux/m68k/cprt0.as -text
|
rtl/linux/m68k/cprt0.as -text
|
||||||
@ -3924,6 +3925,7 @@ rtl/linux/m68k/prt0.as -text
|
|||||||
rtl/linux/m68k/prt1.as -text
|
rtl/linux/m68k/prt1.as -text
|
||||||
rtl/linux/m68k/signal.inc svneol=native#text/plain
|
rtl/linux/m68k/signal.inc svneol=native#text/plain
|
||||||
rtl/linux/m68k/stat.inc svneol=native#text/plain
|
rtl/linux/m68k/stat.inc svneol=native#text/plain
|
||||||
|
rtl/linux/oldlinux.pp svneol=native#text/plain
|
||||||
rtl/linux/osdefs.inc svneol=native#text/plain
|
rtl/linux/osdefs.inc svneol=native#text/plain
|
||||||
rtl/linux/osmacro.inc svneol=native#text/plain
|
rtl/linux/osmacro.inc svneol=native#text/plain
|
||||||
rtl/linux/ossysc.inc svneol=native#text/plain
|
rtl/linux/ossysc.inc svneol=native#text/plain
|
||||||
|
@ -82,10 +82,12 @@ _haltproc2: # GAS <= 2.15 bug: generates larger jump if a label is e
|
|||||||
jmp _haltproc2
|
jmp _haltproc2
|
||||||
|
|
||||||
.data
|
.data
|
||||||
|
.type __fpucw,@object
|
||||||
|
.size __fpucw,4
|
||||||
|
.global __fpucw
|
||||||
___fpucw:
|
___fpucw:
|
||||||
.long 0x1332
|
.long 0x1332
|
||||||
|
|
||||||
|
|
||||||
.bss
|
.bss
|
||||||
.type __stkptr,@object
|
.type __stkptr,@object
|
||||||
.size __stkptr,4
|
.size __stkptr,4
|
||||||
|
145
rtl/linux/linux.pp
Normal file
145
rtl/linux/linux.pp
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
{
|
||||||
|
This file is part of the Free Pascal run time library.
|
||||||
|
Copyright (c) 1999-2000 by Michael Van Canneyt,
|
||||||
|
BSD parts (c) 2000 by Marco van de Voort
|
||||||
|
members of the Free Pascal development team.
|
||||||
|
|
||||||
|
New linux unit. Linux only calls only. Will be renamed to linux.pp
|
||||||
|
when 1.0.x support is killed off.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
**********************************************************************}
|
||||||
|
unit Linux;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
Type
|
||||||
|
TSysinfo = packed record
|
||||||
|
uptime : longint;
|
||||||
|
loads : array[1..3] of longint;
|
||||||
|
totalram,
|
||||||
|
freeram,
|
||||||
|
sharedram,
|
||||||
|
bufferram,
|
||||||
|
totalswap,
|
||||||
|
freeswap : longint;
|
||||||
|
procs : integer;
|
||||||
|
s : string[18];
|
||||||
|
end;
|
||||||
|
PSysInfo = ^TSysInfo;
|
||||||
|
|
||||||
|
Function Sysinfo(var Info:TSysinfo):Boolean; {$ifdef FPC_USE_LIBC} cdecl; external name 'sysinfo'; {$endif}
|
||||||
|
|
||||||
|
Const
|
||||||
|
CSIGNAL = $000000ff; // signal mask to be sent at exit
|
||||||
|
CLONE_VM = $00000100; // set if VM shared between processes
|
||||||
|
CLONE_FS = $00000200; // set if fs info shared between processes
|
||||||
|
CLONE_FILES = $00000400; // set if open files shared between processes
|
||||||
|
CLONE_SIGHAND = $00000800; // set if signal handlers shared
|
||||||
|
CLONE_PID = $00001000; // set if pid shared
|
||||||
|
|
||||||
|
type
|
||||||
|
TCloneFunc=function(args:pointer):longint;cdecl;
|
||||||
|
|
||||||
|
function Clone(func:TCloneFunc;sp:pointer;flags:longint;args:pointer):longint; {$ifdef FPC_USE_LIBC} cdecl; external name 'clone'; {$endif}
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$ifndef FPC_USE_LIBC}
|
||||||
|
Uses Syscall;
|
||||||
|
|
||||||
|
Function Sysinfo(var Info:TSysinfo):Boolean;
|
||||||
|
{
|
||||||
|
Get system info
|
||||||
|
}
|
||||||
|
Begin
|
||||||
|
Sysinfo:=do_SysCall(SysCall_nr_Sysinfo,TSysParam(@info))=0;
|
||||||
|
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}
|
||||||
|
{$ASMMODE ATT}
|
||||||
|
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;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
end.
|
5908
rtl/linux/oldlinux.pp
Normal file
5908
rtl/linux/oldlinux.pp
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user