* linux now compiles with FPC_USE_LIBC

This commit is contained in:
marco 2003-12-30 15:43:20 +00:00
parent 371f66818a
commit 42d5e0e005
7 changed files with 163 additions and 97 deletions

View File

@ -16,10 +16,13 @@
**********************************************************************} **********************************************************************}
{$i ostypes.inc}
{$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 ostypes.inc}
{$i ossysch.inc} // external interface to syscalls in system unit. {$i ossysch.inc} // external interface to syscalls in system unit.
{$endif}
//{$i genfuncs.inc} //{$i genfuncs.inc}
{$i bunxmacr.inc} // macro's. {$i bunxmacr.inc} // macro's.
@ -27,6 +30,7 @@
{$I gensigset.inc} // general sigset funcs implementation. {$I gensigset.inc} // general sigset funcs implementation.
{$I genfdset.inc} {$I genfdset.inc}
{$ifndef FPC_USE_LIBC}
Function fpKill(Pid:pid_t;Sig:cint):cint; Function fpKill(Pid:pid_t;Sig:cint):cint;
{ {
Send signal 'sig' to a process, or a group of processes. Send signal 'sig' to a process, or a group of processes.
@ -431,9 +435,14 @@ begin
fpSelect:=do_syscall(syscall_nr_select,longint(@selectarray)); fpSelect:=do_syscall(syscall_nr_select,longint(@selectarray));
end; end;
{$endif}
{ {
$Log$ $Log$
Revision 1.6 2003-11-19 14:04:34 marco Revision 1.7 2003-12-30 15:43:20 marco
* linux now compiles with FPC_USE_LIBC
Revision 1.6 2003/11/19 14:04:34 marco
* fix for sleep from johill * fix for sleep from johill
Revision 1.5 2003/09/27 13:45:58 peter Revision 1.5 2003/09/27 13:45:58 peter

View File

@ -21,8 +21,9 @@
{ $I ostypes.inc} { $I ostypes.inc}
{$ifdef uselibc} {$ifdef FPC_USE_LIBC}
{$I oscdeclh.inc} // {$I oscdeclh.inc}
{$linklib c}
{$else} {$else}
{$I sysdeclh.inc} {$I sysdeclh.inc}
{$endif} {$endif}
@ -32,7 +33,10 @@
{ {
$Log$ $Log$
Revision 1.3 2003-06-01 16:28:56 marco Revision 1.4 2003-12-30 15:43:20 marco
* linux now compiles with FPC_USE_LIBC
Revision 1.3 2003/06/01 16:28:56 marco
* small rearrangements * small rearrangements
Revision 1.2 2003/01/02 22:39:19 marco Revision 1.2 2003/01/02 22:39:19 marco

View File

@ -16,14 +16,23 @@
**************************************************************************** ****************************************************************************
} }
{$ifdef uselibc} {$I ostypes.inc}
{$ifdef FPC_USE_LIBC}
{$Linklib c}
// Out of date atm.
{$ifdef FPC_IS_SYSTEM}
{$i oscdeclh.inc}
{$endif}
{$I bunxmacr.inc}
{$else} {$else}
{***************************************************************************** {*****************************************************************************
--- Main:The System Call Self --- --- Main:The System Call Self ---
*****************************************************************************} *****************************************************************************}
{$I ostypes.inc}
{$I syscallh.inc} {$I syscallh.inc}
{$I syscall.inc} {$I syscall.inc}
{$I sysnr.inc} {$I sysnr.inc}
@ -324,14 +333,6 @@ begin
Fpdup2:=do_syscall(syscall_nr_dup2,TSysParam(fildes),TSysParam(fildes2)); Fpdup2:=do_syscall(syscall_nr_dup2,TSysParam(fildes),TSysParam(fildes2));
end; end;
CONST
{ Constansts for MMAP }
MAP_PRIVATE =2;
MAP_ANONYMOUS =$20;
{Constansts Termios/Ioctl (used in Do_IsDevice) }
IOCtl_TCGETS=$5401; // TCGETS is also in termios.inc, but the sysunix needs only this
type type
tmmapargs=packed record tmmapargs=packed record
@ -380,15 +381,6 @@ begin
Fpmunmap:=do_syscall(syscall_nr_munmap,TSysParam(Adr),TSysParam(Len)); Fpmunmap:=do_syscall(syscall_nr_munmap,TSysParam(Adr),TSysParam(Len));
end; end;
Function sbrk(size : longint) : pointer;
begin
sbrk:=Fpmmap(nil,Size,3,MAP_PRIVATE+MAP_ANONYMOUS,-1,0);
if sbrk=pointer(-1) then
sbrk:=nil
else
errno:=0;
end;
{ {
Interface to Unix ioctl call. Interface to Unix ioctl call.
Performs various operations on the filedescriptor Handle. Performs various operations on the filedescriptor Handle.
@ -406,20 +398,6 @@ begin
FpIOCtl:=do_SysCall(syscall_nr_ioctl,tsysparam(fd),tsysparam(Request),TSysParam(data)); FpIOCtl:=do_SysCall(syscall_nr_ioctl,tsysparam(fd),tsysparam(Request),TSysParam(data));
end; end;
Function Do_IsDevice(Handle:cint):boolean;
{
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.
}
var
Data : array[0..255] of byte; {Large enough for termios info}
begin
Do_IsDevice:=(Fpioctl(handle,IOCTL_TCGETS,@data)<>-1);
end;
Function FpGetPid:pid_t; [public, alias : 'FPC_SYSC_GETPID']; Function FpGetPid:pid_t; [public, alias : 'FPC_SYSC_GETPID'];
{ {
@ -452,9 +430,47 @@ end;
{$ENDIF} {$ENDIF}
CONST
{ Constansts for MMAP }
MAP_PRIVATE =2;
MAP_ANONYMOUS =$20;
{Constansts Termios/Ioctl (used in Do_IsDevice) }
IOCtl_TCGETS=$5401; // TCGETS is also in termios.inc, but the sysunix needs only this
Function sbrk(size : longint) : pointer;
begin
sbrk:=Fpmmap(nil,Size,3,MAP_PRIVATE+MAP_ANONYMOUS,-1,0);
if sbrk=pointer(-1) then
sbrk:=nil
else
errno:=0;
end;
Function Do_IsDevice(Handle:cint):boolean;
{
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.
}
var
Data : array[0..255] of byte; {Large enough for termios info}
begin
Do_IsDevice:=(Fpioctl(handle,IOCTL_TCGETS,@data)<>-1);
end;
{ {
$Log$ $Log$
Revision 1.10 2003-12-16 09:43:04 daniel Revision 1.11 2003-12-30 15:43:20 marco
* linux now compiles with FPC_USE_LIBC
Revision 1.10 2003/12/16 09:43:04 daniel
* Use of 0 instead of nil fixed * Use of 0 instead of nil fixed
Revision 1.9 2003/10/17 20:56:24 olle Revision 1.9 2003/10/17 20:56:24 olle

View File

@ -70,17 +70,25 @@ end;
{$I heap.inc} {$I heap.inc}
{***************************************************************************** {*****************************************************************************
UnTyped File Handling UnTyped File Handling
*****************************************************************************} *****************************************************************************}
{$i file.inc} {$i file.inc}
{***************************************************************************** {*****************************************************************************
Typed File Handling Typed File Handling
*****************************************************************************} *****************************************************************************}
{$i typefile.inc} {$i typefile.inc}
{*****************************************************************************
Extra cdecl declarations for FPC_USE_LIBC for this os
*****************************************************************************}
{$ifdef FPC_USE_LIBC}
Function fpReadLink(name,linkname:pchar;maxlen:cint):cint; cdecl; external name 'readlink';
{$endif}
procedure SysInitStdIO; procedure SysInitStdIO;
begin begin
OpenStdIO(Input,fmInput,StdInputHandle); OpenStdIO(Input,fmInput,StdInputHandle);
@ -133,7 +141,10 @@ End.
{ {
$Log$ $Log$
Revision 1.9 2003-12-30 12:36:56 marco Revision 1.10 2003-12-30 15:43:20 marco
* linux now compiles with FPC_USE_LIBC
Revision 1.9 2003/12/30 12:36:56 marco
* FPC_USE_LIBC * FPC_USE_LIBC
Revision 1.8 2003/09/14 20:15:01 marco Revision 1.8 2003/09/14 20:15:01 marco

View File

@ -13,7 +13,7 @@
**********************************************************************} **********************************************************************}
{$ifndef FPC_USE_LIBC}
Function fsync (fd : cint) : cint; Function fsync (fd : cint) : cint;
begin begin
fsync := do_SysCall(syscall_nr_fsync, fd); fsync := do_SysCall(syscall_nr_fsync, fd);
@ -46,44 +46,6 @@ begin
fStatFS:=(do_SysCall(SysCall_nr_fstatfs,fd,longint(@info))); fStatFS:=(do_SysCall(SysCall_nr_fstatfs,fd,longint(@info)));
end; end;
Function AssignPipe(var pipe_in,pipe_out:cint):cint; [public, alias : 'FPC_SYSC_ASSIGNPIPE'];
{
Sets up a pair of file variables, which act as a pipe. The first one can
be read from, the second one can be written to.
If the operation was unsuccesful, linuxerror is set.
}
var
pip : tpipe;
begin
assignPipe:=do_SysCall(SysCall_nr_pipe,longint(@pip));
pipe_in:=pip[1];
pipe_out:=pip[2];
end;
Function PClose(Var F:text) :cint;
var
pl : ^cint;
res : cint;
begin
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);
pclose:=res shr 8;
end;
Function PClose(Var F:file) : cint;
var
pl : ^cint;
res : cint;
begin
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);
pclose:=res shr 8;
end;
{-------------------------------- {--------------------------------
Port IO functions Port IO functions
@ -108,10 +70,58 @@ begin
end; end;
{$endif cpui386} {$endif cpui386}
{$endif}
Function AssignPipe(var pipe_in,pipe_out:cint):cint; [public, alias : 'FPC_SYSC_ASSIGNPIPE'];
{
Sets up a pair of file variables, which act as a pipe. The first one can
be read from, the second one can be written to.
If the operation was unsuccesful, linuxerror is set.
}
var
pip : tpipe;
begin
{$ifdef FPC_USE_LIBC}
assignpipe:=pipe(pip);
{$else}
assignPipe:=do_SysCall(SysCall_nr_pipe,longint(@pip));
{$endif}
pipe_in:=pip[1];
pipe_out:=pip[2];
end;
Function PClose(Var F:text) :cint;
var
pl : ^cint;
res : cint;
begin
fpclose(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);
pclose:=res shr 8;
end;
Function PClose(Var F:file) : cint;
var
pl : ^cint;
res : cint;
begin
fpclose(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);
pclose:=res shr 8;
end;
{ {
$Log$ $Log$
Revision 1.22 2003-12-30 12:36:56 marco Revision 1.23 2003-12-30 15:43:20 marco
* linux now compiles with FPC_USE_LIBC
Revision 1.22 2003/12/30 12:36:56 marco
* FPC_USE_LIBC * FPC_USE_LIBC
Revision 1.21 2003/11/19 11:46:55 marco Revision 1.21 2003/11/19 11:46:55 marco

View File

@ -28,11 +28,11 @@ Type TGrpArr = Array [0..0] of TGid; { C style array workarounds}
function FpAccess (pathname : pchar; amode : cint): cint; cdecl; external name 'access'; function FpAccess (pathname : pchar; amode : cint): cint; cdecl; external name 'access';
function FpChdir (path : pchar): cint; cdecl; external name 'chdir'; function FpChdir (path : pchar): cint; cdecl; external name 'chdir';
function FpClose (fd : cint): cint; cdecl; external name 'close'; function FpClose (fd : cint): cint; cdecl; external name 'close';
{$ifndef FPC_IS_SYSTEM} //{$ifndef FPC_IS_SYSTEM}
Function FpClosedir (var dirp : Dir): cInt; cdecl; external name 'closedir'; Function FpClosedir (var dirp : Dir): cInt; cdecl; external name 'closedir';
{$else} //{$else}
function FpClosedir (dirp : pdir): cint; cdecl; external name 'closedir'; function FpClosedir (dirp : pdir): cint; cdecl; external name 'closedir';
{$endif} //{$endif}
function FpDup (oldd:cint):cint; cdecl; external name 'dup'; function FpDup (oldd:cint):cint; cdecl; external name 'dup';
function FpDup2 (oldd:cint;newd:cint):cint; cdecl; external name 'dup2'; function FpDup2 (oldd:cint;newd:cint):cint; cdecl; external name 'dup2';
function FpExecve (path : pchar; argv : ppchar; envp: ppchar): cint; cdecl; external name 'execve'; function FpExecve (path : pchar; argv : ppchar; envp: ppchar): cint; cdecl; external name 'execve';
@ -44,18 +44,18 @@ Type TGrpArr = Array [0..0] of TGid; { C style array workarounds}
function FpOpen (path: pchar; flags : cint; mode: TMode):cint; cdecl; external name 'open'; function FpOpen (path: pchar; flags : cint; mode: TMode):cint; cdecl; external name 'open';
function FpOpendir (dirname : pchar): pdir; cdecl; external name 'opendir'; function FpOpendir (dirname : pchar): pdir; cdecl; external name 'opendir';
function FpRead (fd: cint; buf: pchar; nbytes : TSize): TSSize; cdecl; external name 'read'; function FpRead (fd: cint; buf: pchar; nbytes : TSize): TSSize; cdecl; external name 'read';
{$ifdef FPC_IS_SYSTEM} //{$ifdef FPC_IS_SYSTEM}
function FpReaddir (dirp : pdir) : pdirent;cdecl; external name 'readdir'; function FpReaddir (dirp : pdir) : pdirent;cdecl; external name 'readdir';
{$ELSE} //{$ELSE}
Function FpReaddir (var dirp : Dir) : pDirent;cdecl; external name 'readdir'; Function FpReaddir (var dirp : Dir) : pDirent;cdecl; external name 'readdir';
{$endif} //{$endif}
function FpRename (old : pchar; newpath: pchar): cint; cdecl;external name 'rename'; function FpRename (old : pchar; newpath: pchar): cint; cdecl;external name 'rename';
function FpRmdir (path : pchar): cint; cdecl; external name 'rmdir'; function FpRmdir (path : pchar): cint; cdecl; external name 'rmdir';
{$ifdef FPC_IS_SYSTEM} // {$ifdef FPC_IS_SYSTEM}
function FpSigaction (sig: cint;var act : sigactionrec; var oact : sigactionrec): cint; cdecl; external name 'sigaction'; function FpSigaction (sig: cint;var act : sigactionrec; var oact : sigactionrec): cint; cdecl; external name 'sigaction';
{$else} // {$else}
Function FPSigaction (sig: cInt; act :pSigActionRec;oact:pSigActionRec):cint;cdecl; external name 'sigaction'; Function FPSigaction (sig: cInt; act :pSigActionRec;oact:pSigActionRec):cint;cdecl; external name 'sigaction';
{$endif} // {$endif}
{$ifdef BSD} {$ifdef BSD}
function FPSigProcMask(how:cint;nset : psigset;oset : psigset):cint; external name 'sigprocmask'; function FPSigProcMask(how:cint;nset : psigset;oset : psigset):cint; external name 'sigprocmask';
@ -91,7 +91,10 @@ Type TGrpArr = Array [0..0] of TGid; { C style array workarounds}
{ {
$Log$ $Log$
Revision 1.2 2003-12-30 12:24:01 marco Revision 1.3 2003-12-30 15:43:20 marco
* linux now compiles with FPC_USE_LIBC
Revision 1.2 2003/12/30 12:24:01 marco
* FPC_USE_LIBC * FPC_USE_LIBC
Revision 1.1 2003/06/01 15:23:46 marco Revision 1.1 2003/06/01 15:23:46 marco

View File

@ -43,7 +43,7 @@ Const
LOCK_NB = 4; LOCK_NB = 4;
Type Type
Tpipe = array[1..2] of cint; Tpipe = baseunix.tfildes; // compability.
pglob = ^tglob; pglob = ^tglob;
tglob = record tglob = record
@ -609,11 +609,21 @@ Begin
EpochToLocal(fptime,year,month,day,hour,minute,second); EpochToLocal(fptime,year,month,day,hour,minute,second);
End; End;
{$ifndef BSD} {$ifndef BSD} // this can be done nicer, but I still have
// to think about what to do with this func.
{$ifdef linux} {$ifdef linux}
Function stime (t : cint) : Boolean; {$ifdef FPC_USE_LIBC}
function intstime (t:ptime_t):cint; external name 'stime';
{$endif}
Function stime (t : cint) : boolean;
begin begin
stime:=do_SysCall(Syscall_nr_stime,cint(@t))=0; {$ifdef FPC_USE_LIBC}
stime:=intstime(@t)=0;
{$else}
stime:=do_SysCall(Syscall_nr_stime,cint(@t))=0;
{$endif}
end; end;
{$endif} {$endif}
{$endif} {$endif}
@ -1398,7 +1408,10 @@ End.
{ {
$Log$ $Log$
Revision 1.53 2003-12-30 12:24:01 marco Revision 1.54 2003-12-30 15:43:20 marco
* linux now compiles with FPC_USE_LIBC
Revision 1.53 2003/12/30 12:24:01 marco
* FPC_USE_LIBC * FPC_USE_LIBC
Revision 1.52 2003/12/08 17:16:30 peter Revision 1.52 2003/12/08 17:16:30 peter