* Modifications from Saturday.

This commit is contained in:
marco 2002-10-27 11:58:29 +00:00
parent 9b47bcfe9b
commit 10f2ceeab8
9 changed files with 240 additions and 73 deletions

View File

@ -1,9 +1,11 @@
{
$Id$
This file is part of the Free Pascal run time library.
Copyright (c) 2001 by Free Pascal development team
Copyright (c) 2002 by Marco van de Voort
Calls needed for the POSIX unit.
Calls needed for the POSIX unit, but not for system.
Some calls that can be used for both Linux and *BSD will be
moved to a /unix/ includedfile later.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
@ -156,16 +158,16 @@ Var it,oitv : Itimerval;
Begin
// register struct itimerval *itp = ⁢
it.it_interval.sec:=0;
it.it_interval.usec:=0;
it.it_value.sec:=seconds;
it.it_value.usec:=0;
it.it_interval.tv_sec:=0;
it.it_interval.tv_usec:=0;
it.it_value.tv_sec:=seconds;
it.it_value.tv_usec:=0;
If SetITimer(ITIMER_REAL,it,oitv)<0 Then
Exit(-1);
if oitv.it_value.usec<>0 Then
Inc(oitv.it_value.sec);
sys_Alarm:=oitv.it_value.sec;
if oitv.it_value.tv_usec<>0 Then
Inc(oitv.it_value.tv_sec);
sys_Alarm:=oitv.it_value.tv_sec;
End;
function sigblock(mask:cuint):cint;
@ -374,10 +376,98 @@ begin
sys_setsid:=do_syscall(syscall_nr_setsid);
end;
Function sys_umask(cmask:mode_t):mode_t;
{
Sets file creation mask to (Mask and 0777 (octal) ), and returns the
previous value.
}
begin
sys_umask:=Do_syscall(syscall_nr_umask,cmask);
end;
Function sys_link(existing:pchar;_new:pchar):cint;
{
Proceduces a hard link from new to old.
In effect, new will be the same file as old.
}
begin
sys_Link:=Do_Syscall(syscall_nr_link,longint(existing),longint(_new));
end;
Function sys_mkfifo(path:pchar;mode:mode_t):cint;
begin
sys_mkfifo:=do_syscall(syscall_nr_mkfifo,longint(path),longint(mode));
end;
Function sys_chmod(path:pchar;mode:mode_t):cint;
begin
sys_chmod:=do_syscall(syscall_nr_chmod,longint(path),longint(mode));
end;
Function sys_chown(path:pchar;owner:uid_t;group:gid_t):cint;
begin
sys_ChOwn:=do_syscall(syscall_nr_chown,longint(path),longint(owner),longint(group));
end;
Function sys_Utime(path:pchar;times:putimbuf):cint;
var tv : array[0..1] of timeval;
tvp : ^timeval;
begin
if times=nil Then
tvp:=nil
else
begin
tv[0].tv_sec :=times^.actime;
tv[1].tv_sec :=times^.modtime;
tv[0].tv_usec:=0;
tv[1].tv_usec:=0;
tvp:=@tv;
end;
sys_utime:=do_syscall(syscall_nr_utimes,longint(path),longint(tvp));
end;
Function sys_pipe(var fildes : tfildes):cint;
begin
sys_pipe:=do_syscall(syscall_nr_pipe,longint(@fildes));
end;
function sys_fcntl(fildes:cint;Cmd:cint;Arg:cint):cint;
begin
sys_fcntl:=do_syscall(syscall_nr_fcntl,fildes,cmd,arg);
end;
function sys_fcntl(fildes:cint;Cmd:cint;var Arg:flock):cint;
begin
sys_fcntl:=do_syscall(syscall_nr_fcntl,fildes,cmd,longint(@arg));
end;
function sys_fcntl(fildes:cint;Cmd:cint):cint;
begin
sys_fcntl:=do_syscall(syscall_nr_fcntl,fildes,cmd);
end;
function sys_execve(path:pchar;argv:ppchar;envp:ppchar):cint
Begin
sys_execve:=do_syscall(syscall_nr_Execve,longint(path),longint(argv),longint(envp));
End;
{
$Log$
Revision 1.6 2002-10-26 18:27:51 marco
Revision 1.7 2002-10-27 11:58:29 marco
* Modifications from Saturday.
Revision 1.6 2002/10/26 18:27:51 marco
* First series POSIX calls commits. Including getcwd.
Revision 1.5 2002/10/25 15:46:48 marco
@ -398,6 +488,3 @@ end;
Revision 1.1 2002/08/08 11:39:30 marco
* Initial versions, to allow support for uname in posix.pp
}

View File

@ -1,30 +1,24 @@
{
$Id$
Copyright (c) 2001 by Carl Eric Codere
Copyright (c) 2002 by Marco van de Voort
The base *BSD syscalls required to implement the system unit. These
are aliased for use in other units (to avoid poluting the system units
interface)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
****************************************************************************
}
{$ifdef uselibc}
{$Linklib c}
// Out of date atm.
{ var
Errno : cint; external name 'errno';}
@ -90,8 +84,8 @@ begin
else
Begin
// If Assigned(tloc) Then
TLoc:=tv.sec;
sys_time:=tv.sec;
TLoc:=tv.tv_sec;
sys_time:=tv.tv_sec;
End;
End;
@ -438,22 +432,16 @@ begin
end;
}
function sys_Dup(oldd:cint):cint; [public, alias : 'FPC_SYSC_DUP'];
{
Copies the filedescriptor oldfile to newfile
}
Function sys_Dup(fildes:cint):cint; [public, alias : 'FPC_SYSC_DUP'];
begin
sys_dup:=Do_syscall(syscall_nr_dup,oldd);
sys_dup:=Do_syscall(syscall_nr_dup,longint(fildes));
end;
function sys_Dup2(oldd:cint;newd:cint):cint; [public, alias : 'FPC_SYSC_DUP2'];
{
Copies the filedescriptor oldfile to newfile
}
Function sys_Dup2(fildes,fildes2:cint):cint; [public, alias : 'FPC_SYSC_DUP2'];
begin
sys_dup2:=do_syscall(syscall_nr_dup2,oldd,newd);
sys_dup2:=do_syscall(syscall_nr_dup2,longint(fildes),longint(fildes2));
end;
CONST
@ -585,7 +573,10 @@ end;
{
$Log$
Revision 1.6 2002-10-26 18:27:51 marco
Revision 1.7 2002-10-27 11:58:29 marco
* Modifications from Saturday.
Revision 1.6 2002/10/26 18:27:51 marco
* First series POSIX calls commits. Including getcwd.
Revision 1.5 2002/10/18 12:19:58 marco

View File

@ -1,3 +1,19 @@
{
$Id$
Copyright (c) 2002 by Marco van de Voort
Header for functions/syscalls included in system, but not in POSIX. To
implement unit UNIX, and/or other lowlevel unix routines.
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.
****************************************************************************
}
Function Sys_mmap(adr,len,prot,flags,fdes,off:longint):longint; external name 'FPC_SYSC_MMAP';
Function Sys_munmap(adr:longint;len:size_t):longint; external name 'FPC_SYSC_MUNMAP';
@ -9,4 +25,13 @@ Function Sys_ReadLink(name,linkname:pchar;maxlen:longint):longint; external nam
Function sys_NanoSleep (const req : timespec;var rem : timespec) : longint; external name 'FPC_SYSC_NANOSLEEP';
{ can be used for getdir?}
Function sys_getcwd (pt:pchar; _size:size_t):pchar; external name 'FPC_SYSC_GETCWD';
Function sys_getcwd (pt:pchar; _size:size_t):pchar; external name 'FPC_SYSC_GETCWD';
{
$Log$
Revision 1.4 2002-10-27 11:58:29 marco
* Modifications from Saturday.
}

View File

@ -23,7 +23,7 @@
Type
timeval = packed record
sec,usec:clong;
tv_sec,tv_usec:clong;
end;
ptimeval = ^timeval;
TTimeVal = timeval;
@ -42,7 +42,10 @@ Type
{
$Log$
Revision 1.2 2002-09-07 16:01:17 peter
Revision 1.3 2002-10-27 11:58:30 marco
* Modifications from Saturday.
Revision 1.2 2002/09/07 16:01:17 peter
* old logs removed and tabs fixed
Revision 1.1 2002/08/19 12:29:11 marco

View File

@ -2,26 +2,19 @@
$Id$
Copyright (c) 2002 by Marco van de Voort.
Declarations to import basic syscalls declarations into other base
units.
Implementation of the POSIX unit for *BSD. In practice only includes
other files, or specifies libc bindings.
The conditional uselibc can be used to switch from libc to syscall
usage for basic primitives, but it is best to use unit POSIX if
possible. Note that the system unit must also be compiled using uselibc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
****************************************************************************
}
@ -61,18 +54,13 @@ Uses Sysctl;
function sys_execve(const path : pchar; const argv : ppchar; const envp: ppchar): cint; cdecl; external name 'execve';
function sys_waitpid(pid : pid_t; var stat_loc : cint; options: cint): pid_t; cdecl; external name 'waitpid';
function sys_access(const pathname : pchar; amode : cint): cint; cdecl; external name 'access';
// function sys_uname(var name: utsname): cint; cdecl; external name 'uname';
function sys_Dup(oldd:cint):cint; cdecl; external name 'dup';
function sys_Dup2(oldd:cint;newd:cint):cint; cdecl; external name 'dup2';
function sys_uname(var name: utsname): cint; cdecl; external name 'uname';
function sys_Dup(fildes:cint):cint; cdecl; external name 'dup';
function sys_Dup2(fildes:cint;fildes2:cint):cint; cdecl; external name 'dup2';
{$else}
{*****************************************************************************
--- Main:The System Call Self ---
*****************************************************************************}
{ The system designed for Linux can't be used for FreeBSD so easily, since
FreeBSD pushes arguments, instead of loading them to registers.}
// uses syscalls.
function sys_time(var tloc:time_t): time_t; external name 'FPC_SYSC_TIME';
function sys_open(const path: pchar; flags : cint; mode: mode_t):cint; external name 'FPC_SYSC_OPEN';
@ -97,8 +85,8 @@ function sys_fork : pid_t; external name 'FPC_SYSC_FORK';
function sys_execve(const path : pchar; const argv : ppchar; const envp: ppchar): cint; external name 'FPC_SYSC_EXECVE';
function sys_waitpid(pid : pid_t; var stat_loc : cint; options: cint): pid_t; external name 'FPC_SYSC_WAITPID';
function sys_access(const pathname : pchar; amode : cint): cint;external name 'FPC_SYSC_ACCESS';
function sys_Dup(oldd:cint):cint; external name 'FPC_SYSC_DUP';
function sys_Dup2(oldd:cint;newd:cint):cint; external name 'FPC_SYSC_DUP2';
function sys_Dup(fildes:cint):cint; external name 'FPC_SYSC_DUP';
function sys_Dup2(fildes:cint;fildes2:cint):cint; external name 'FPC_SYSC_DUP2';
function geterrno:cint; external name 'FPC_SYS_GETERRNO';
procedure seterrno (i:cint); external name 'FPC_SYS_SETERRNO';
@ -106,11 +94,12 @@ procedure seterrno (i:cint); external name 'FPC_SYS_SETERRNO';
{$I bsdfuncs.inc}
{
$Log$
Revision 1.6 2002-10-26 18:27:51 marco
Revision 1.7 2002-10-27 11:58:30 marco
* Modifications from Saturday.
Revision 1.6 2002/10/26 18:27:51 marco
* First series POSIX calls commits. Including getcwd.
Revision 1.5 2002/09/07 16:01:17 peter

View File

@ -86,7 +86,20 @@ TYPE
dd_rewind : clong; // magic cookie for rewinding
dd_flags : cint; // flags for readdir
end;
putimbuf = ^utimbuf;
utimbuf = record
actime : time_t;
modtime : time_t;
end;
flock = record
l_start : off_t; { starting offset }
l_len : off_t; { len = 0 means until end of file }
l_pid : pid_t; { lock owner }
l_type : cshort; { lock type: read/write, etc. }
l_whence: cshort; { type of l_start }
end;
{***********************************************************************}
{ POSIX CONSTANT ROUTINE DEFINITIONS }
@ -142,7 +155,10 @@ CONST
{
$Log$
Revision 1.4 2002-09-07 16:01:17 peter
Revision 1.5 2002-10-27 11:58:30 marco
* Modifications from Saturday.
Revision 1.4 2002/09/07 16:01:17 peter
* old logs removed and tabs fixed
Revision 1.3 2002/08/21 07:03:16 marco

View File

@ -1,18 +1,51 @@
{
$Id$
This file is part of the Free Pascal run time librar~y.
Copyright (c) 2000 by Marco van de Voort
member of the Free Pascal development team.
Filellist and some notes about the *BSD RTL architecture.
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.
**********************************************************************}
*BSD commonly means FreeBSD, OpenBSD and NetBSD, but since Apple's Darwin
has a FreeBSD userland, I also add Darwin to it. At least Darwin's
userland seems to be compatible enough to be included, despite its
internal Mach architecture.
Common *BSD files:
bsdmacro.inc The POSIX IS_DIR etc macro's.
bsdmacro.inc The POSIX mode_t (IS_DIR etc) and exit macro's.
bsdsysc.inc The base syscalls for *BSD system unit.
including a few that are _not_ posix, but still
req'ed in the system unit.
required in the system unit. All routines have
a public alias.
bsdsysch.inc EXTERNAL declarations for the non-posix calls in
bsdsysc.inc (to import them into e.g. Unix)
bsdtypes.inc some non POSIX BSD types required for the
syscalls
bsduname.inc The Uname implementation. Requires unit sysctl
syscalls and base functions.
bsdfuncs.inc POSIX syscalls and functions that are not needed
for system.
osposix.inc The implementation of unit posix, redirects to libc
or bsdtypes.inc (via aliases)
osposixh.inc The headers of unit posix.
sysctl.pp Some basic sysctl headers.
sysctl.pp Some basic sysctl headers, needed for implementation
of POSIX functions.
sysposix.inc BSD specific part of the implementation
i386/syscall.inc The primitives for performing syscalls
i386/syscallh.inc Headers to syscall.inc
powerpc/syscall.inc likewise for PPC.
{
$Log$
Revision 1.2 2002-10-27 11:58:30 marco
* Modifications from Saturday.
}

View File

@ -1 +1,19 @@
{
$Id$
This file is part of the Free Pascal run time librar~y.
Copyright (c) 2000 by Marco van de Voort
member of the Free Pascal development team.
For bootstrapping with 1.0.x compilers (which still want sysbsd
as system unit name)
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.
**********************************************************************}
{$i system.pp}

View File

@ -4,6 +4,8 @@
Copyright (c) 2000 by Marco van de Voort
member of the Free Pascal development team.
System unit for the *BSD's.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
@ -97,7 +99,10 @@ End.
{
$Log$
Revision 1.5 2002-10-26 18:27:51 marco
Revision 1.6 2002-10-27 11:58:30 marco
* Modifications from Saturday.
Revision 1.5 2002/10/26 18:27:51 marco
* First series POSIX calls commits. Including getcwd.
Revision 1.4 2002/10/18 12:19:58 marco