* some updates

This commit is contained in:
marco 2003-01-17 22:13:47 +00:00
parent a14491988b
commit 636cb5bb85
6 changed files with 2328 additions and 22 deletions

1267
rtl/netbsd/Makefile Normal file

File diff suppressed because it is too large Load Diff

222
rtl/netbsd/Makefile.fpc Normal file
View File

@ -0,0 +1,222 @@
#
# Makefile.fpc for Free Pascal NetBSD RTL
#
[package]
main=rtl
[install]
fpcpackage=y
[target]
loaders=prt0 cprt0
units=$(SYSTEMUNIT) objpas strings baseunix \
$(LINUXUNIT) unix initc \
dos crt objects printer \
sysutils typinfo math varutils \
cpu mmx charset ucomplex getopts heaptrc lineinfo \
errors sockets gpm ipc terminfo \
video mouse keyboard console serial variants types systhrds sysctl
rsts=math varutils typinfo
[require]
nortl=y
[install]
fpcpackage=y
[default]
fpcdir=../..
target=netbsd
[compiler]
includedir=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC) $(BSDPROCINC)
sourcedir=$(INC) $(PROCINC) $(UNIXINC) $(BSDINC)
targetdir=.
[lib]
libname=libfprtl.so
libversion=1.0
libunits=$(SYSTEMUNIT) objpas strings \
unix \
dos crt objects printer \
sysutils typinfo math \
cpu mmx getopts heaptrc \
errors sockets ipc
[prerules]
RTL=..
INC=$(RTL)/inc
PROCINC=$(RTL)/$(CPU_TARGET)
BSDINC=$(RTL)/bsd
BSDPROCINC=$(BSDINC)/$(CPU_TARGET)
UNIXINC=$(RTL)/unix
UNITPREFIX=rtl
ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
SYSTEMUNIT=system
LINUXUNIT=
PRT0=prt0
else
SYSTEMUNIT=sysbsd
LINUXUNIT=linux
override FPCOPT+=-dUNIX
PRT0=prt0_10
endif
# Use new feature from 1.0.5 version
# that generates release PPU files
# which will not be recompiled
ifdef RELEASE
override FPCOPT+=-Ur
endif
# Paths
OBJPASDIR=$(RTL)/objpas
GRAPHDIR=$(INC)/graph
# Use new graph unit ?
# NEWGRAPH=YES
# Use LibGGI ?
# Use
#
ifndef USELIBGGI
USELIBGGI=NO
endif
[rules]
# Get the system independent include file names.
# This will set the following variables :
# SYSINCNAMES
include $(INC)/makefile.inc
SYSINCDEPS=$(addprefix $(INC)/,$(SYSINCNAMES))
# Get the processor dependent include file names.
# This will set the following variables :
# CPUINCNAMES
include $(PROCINC)/makefile.cpu
SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))
# Put system unit dependencies together.
SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
#
# Loaders
#
prt0$(OEXT) : $(CPU_TARGET)/$(PRT0).as
$(AS) -o prt0$(OEXT) $(CPU_TARGET)/$(PRT0).as
cprt0$(OEXT) : $(CPU_TARGET)/cprt0.as
$(AS) -o cprt0$(OEXT) $(CPU_TARGET)/cprt0.as
#
# System Units (System, Objpas, Strings)
#
$(SYSTEMUNIT)$(PPUEXT) : $(BSDINC)/$(SYSTEMUNIT).pp sysconst.inc systypes.inc syscalls.inc $(SYSDEPS)
$(COMPILER) -Us -Sg $(BSDINC)/$(SYSTEMUNIT).pp
objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/objpas.pp
strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
$(PROCINC)/strings.inc $(PROCINC)/stringss.inc\
$(SYSTEMUNIT)$(PPUEXT)
#
# System Dependent Units
#
baseunix$(PPUEXT) : $(UNIXINC)/errno.inc $(BSDINC)/bunxtype.inc ptypes.inc $(BSDINC)/ctypes.inc \
signal.inc $(UNIXINC)/bunxh.inc $(BSDINC)/bunxmain.inc $(BSDINC)/ostypes.inc \
$(BSDINC)/bunxfunc.inc $(BSDPROCINC)/syscallh.inc sysnr.inc \
$(BSDINC)/ostypes.inc $(BSDINC)/ossysch.inc $(BSDINC)/bunxmacr.inc $(UNIXINC)/gensigset.inc \
$(UNIXINC)/genfuncs.inc $(SYSTEMUNIT)$(PPUEXT)
unix$(PPUEXT) : $(UNIXINC)/unix.pp strings$(PPUEXT) $(INC)/textrec.inc $(INC)/filerec.inc \
syscalls.inc systypes.inc sysconst.inc $(UNIXINC)/timezone.inc \
unixsysc.inc baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
linux$(PPUEXT) : baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
#
# TP7 Compatible RTL Units
#
dos$(PPUEXT) : $(UNIXINC)/dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) \
unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
crt$(PPUEXT) : $(UNIXINC)/crt.pp $(INC)/textrec.inc unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
objects$(PPUEXT) : $(INC)/objects.pp $(SYSTEMUNIT)$(PPUEXT)
printer$(PPUEXT) : $(UNIXINC)/printer.pp $(INC)/textrec.inc unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
#
# Graph
#
#
# Delphi Compatible Units
#
sysutils$(PPUEXT) : $(UNIXINC)/sysutils.pp $(wildcard $(OBJPASDIR)/*.inc) \
objpas$(PPUEXT) unix$(PPUEXT) errors$(PPUEXT)
$(COMPILER) -I$(OBJPASDIR) $(UNIXINC)/sysutils.pp
typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT)
$(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp
math$(PPUEXT): $(OBJPASDIR)/math.pp objpas$(PPUEXT) sysutils$(PPUEXT)
$(COMPILER) $(OBJPASDIR)/math.pp
gettext$(PPUEXT): $(OBJPASDIR)/gettext.pp objpas$(PPUEXT) sysutils$(PPUEXT)
$(COMPILER) $(OBJPASDIR)/gettext.pp
varutils$(PPUEXT) : $(OBJPASDIR)/cvarutil.inc $(OBJPASDIR)/varutils.inc \
$(OBJPASDIR)/varutilh.inc varutils.pp
$(COMPILER) -I$(OBJPASDIR) $(UNIXINC)/varutils.pp
types$(PPUEXT) : $(OBJPASDIR/types.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) $(OBJPASDIR)/types.pp
#
# Other system-independent RTL Units
#
cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMUNIT)$(PPUEXT)
mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMUNIT)$(PPUEXT)
heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMUNIT)$(PPUEXT)
$(COMPILER) -Sg $(INC)/heaptrc.pp
lineinfo$(PPUEXT) : $(INC)/lineinfo.pp $(SYSTEMUNIT)$(PPUEXT)
charset$(PPUEXT) : $(INC)/charset.pp $(SYSTEMUNIT)$(PPUEXT)
ucomplex$(PPUEXT) : $(INC)/ucomplex.pp math$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
#
# Other system-dependent RTL Units
#
sockets$(PPUEXT) : $(UNIXINC)/sockets.pp $(INC)/textrec.inc $(INC)/filerec.inc \
unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
errors$(PPUEXT) : $(UNIXINC)/errors.pp strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
ipc$(PPUEXT) : $(UNIXINC)/ipc.pp unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
terminfo$(PPUEXT) : terminfo.pp unix$(PPUEXT)
callspec$(PPUEXT) : $(INC)/callspec.pp $(SYSTEMUNIT)$(PPUEXT)
sysctl$(PPUEXT) : $(BSDINC)/sysctl.pp $(SYSTEMUNIT)$(PPUEXT)

View File

@ -20,44 +20,77 @@
{ POSIX TYPE DEFINITIONS }
{***********************************************************************}
{$I ctypes.inc}
type
{ the following type definitions are compiler dependant }
{ and system dependant }
cint8 = shortint;
cuint8 = byte;
cuint16= word;
cint16 = smallint;
cint32 = longint;
cuint32= cardinal;
cint64 = int64;
{$ifndef VER_1_0}
cuint64= qword;
{$endif}
cint = longint; { minimum range is : 32-bit }
cuint = Cardinal; { minimum range is : 32-bit }
clong = longint;
culong = Cardinal;
dev_t = cuint32; { used for device numbers }
TDev = dev_t;
pDev = ^dev_t;
gid_t = cuint32; { used for group IDs }
TGid = gid_t;
pGid = ^gid_t;
ino_t = clong; { used for file serial numbers }
TIno = ino_t;
pIno = ^ino_t;
mode_t = cuint32; { used for file attributes }
TMode = mode_t;
pMode = ^mode_t;
nlink_t = cuint32; { used for link counts }
TnLink = nlink_t;
pnLink = ^nlink_t;
off_t = cint64; { used for file sizes }
TOff = off_t;
pOff = ^off_t;
pid_t = cint32; { used as process identifier }
TPid = pid_t;
pPid = ^pid_t;
size_t = cuint32; { as definied in the C standard}
TSize = size_t;
pSize = ^size_t;
ssize_t = cint32; { used by function for returning number of bytes }
TsSize = ssize_t;
psSize = ^ssize_t;
uid_t = cuint32; { used for user ID type }
TUid = Uid_t;
pUid = ^Uid_t;
clock_t = culong;
TClock = clock_t;
pClock = ^clock_t;
time_t = clong; { used for returning the time }
TTime = time_t;
pTime = ^time_t;
socklen_t= cuint32;
TSocklen = socklen_t;
pSocklen = ^socklen_t;
CONST
{ System limits, POSIX value in parentheses, used for buffer and stack allocation }
ARG_MAX = (256*1024); {4096} { Maximum number of argument size }
NAME_MAX = 255; {14} { Maximum number of bytes in filename }
PATH_MAX = 1024; {255} { Maximum number of bytes in pathname }
ARG_MAX = 256*1024; {4096} { Maximum number of argument size }
NAME_MAX = 255; {14} { Maximum number of bytes in filename }
PATH_MAX = 1024; {255} { Maximum number of bytes in pathname }
SYS_NMLN = 32; {BSD utsname struct limit}
SYS_NMLN = 32; {BSD utsname struct limit}
{
$Log$
Revision 1.3 2003-01-17 22:13:47 marco
* some updates
Revision 1.5 2003/01/03 13:11:32 marco
* split into ptypes and ctypes
}

432
rtl/netbsd/syscalls.inc Normal file
View File

@ -0,0 +1,432 @@
{
$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.
**********************************************************************}
{BSD version of the syscalls required to implement SysLinux.}
{No debugging for syslinux include !}
{$IFDEF SYS_LINUX}
{$UNDEF SYSCALL_DEBUG}
{$ENDIF SYS_LINUX}
{*****************************************************************************
--- 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.
For now I do them in assembler, which makes it easier to test them (copy and
paste to and AS source). Ultimately I hope to design something like this}
{$i cpusys.inc }
Function Sys_Time:longint;
VAR tv : timeval;
tz : timezone;
retval : longint;
begin
Retval:=do_syscall(116,longint(@tv),longint(@tz));
If retval=-1 then
sys_time:=-1
else
sys_time:=tv.sec;
end;
{*****************************************************************************
--- File:File handling related calls ---
*****************************************************************************}
Function Sys_Open(f:pchar;flags:longint;mode:integer):longint;
Begin
sys_open:=do_syscall(syscall_nr_open,longint(f),flags,mode);
End;
Function Sys_Close(f:longint):longint;
begin
sys_close:=do_syscall(syscall_nr_close,f);
end;
{$ifndef m68k}
Function Sys_Lseek(F:longint;Off:longint;Whence:longint):longint;
var returnvalue64 : int64;
begin
{Lseek's offset is 64-bit, the highword is the 0}
// do_syscall(syscall_nr_lseek,longint(@returnvalue64),F,Off,0,Whence);
do_syscall(syscall_nr___syscall,syscall_nr_lseek,0,f,0,off,0,whence);
asm
lea returnvalue64,%ebx
movl %eax,(%ebx)
movl %edx,4(%ebx)
end;
sys_lseek:=longint(returnvalue64);
end;
{$endif m68k}
Function Sys_Read(f:longint;buffer:pchar;count:longint):longint;
begin
sys_read:=do_syscall(syscall_nr_read,F,longint(buffer),count);
end;
Function Sys_Write(f:longint;buffer:pchar;count:longint):longint;
begin
sys_write:=do_syscall(syscall_nr_write,F,longint(buffer),count);
end;
Function Sys_Unlink(Filename:pchar):longint;
begin
sys_unlink:=do_syscall(syscall_nr_unlink,longint(Filename));
end;
Function Sys_Rename(Oldname,Newname:pchar):longint;
begin
sys_rename:=do_syscall(syscall_nr_rename,longint(oldname),longint(newname));
end;
Function Sys_Stat(Filename:pchar;var Buffer: stat):longint;
{
We need this for getcwd
}
begin
sys_stat:=do_syscall(syscall_nr_stat,longint(filename),longint(@buffer));
end;
Function Sys_Symlink(oldname,newname:pchar):longint;
{
We need this for erase
}
begin
sys_symlink:=do_syscall(syscall_nr_symlink,longint(oldname),longint(newname));
end;
Function Sys_ReadLink(name,linkname:pchar;maxlen:longint):longint;
begin
sys_readlink:=do_syscall(syscall_nr_readlink, longint(name),longint(linkname),maxlen);
end;
{*****************************************************************************
--- Directory:Directory related calls ---
*****************************************************************************}
Function Sys_Chdir(Filename:pchar):longint;
begin
sys_chdir:=do_syscall(syscall_nr_chdir,longint(filename));
end;
Function Sys_Mkdir(Filename:pchar;mode:longint):longint;
begin {Mode is 16-bit on F-BSD}
sys_mkdir:=do_syscall(syscall_nr_mkdir,longint(filename),mode );
end;
Function Sys_Rmdir(Filename:pchar):longint;
begin
sys_rmdir:=do_syscall(syscall_nr_rmdir,longint(filename));
end;
{$ifndef NewReaddir}
const DIRBLKSIZ=1024;
{ we need this for getcwd, NOT touched for BSD version }
Function OpenDir(f:pchar):pdir;
var
fd:longint;
st:stat;
ptr:pdir;
begin
opendir:=nil;
if sys_stat(f,st)<0 then
exit;
{ Is it a dir ? }
if not((st.mode and $f000)=$4000)then
begin
errno:=sys_enotdir;
exit
end;
{ Open it}
fd:=sys_open(f,OPEN_RDONLY,438);
if fd<0 then
exit;
new(ptr);
if ptr=nil then
exit;
Getmem(ptr^.buf,2*DIRBLKSIZ);
if ptr^.buf=nil then
exit;
ptr^.fd:=fd;
ptr^.loc:=-1;
ptr^.rewind:=longint(ptr^.buf);
ptr^.size:=0;
// ptr^.dd_max:=sizeof(ptr^.buf^);
opendir:=ptr;
end;
function CloseDir(p:pdir):integer;
begin
closedir:=sys_close(p^.fd);
Freemem(p^.buf);
dispose(p);
end;
Function Sys_ReadDir(p:pdir):pdirent;
{Different from Linux, Readdir on BSD is based on Getdents, due to the
missing of the readdir syscall.
Getdents requires the buffer to be larger than the blocksize.
This usually the sectorsize =512 bytes, but maybe tapedrives and harddisks
with blockmode have this higher?}
function readbuffer:longint;
var retval :longint;
begin
retval:=do_syscall(syscall_nr_getdents,longint(p^.fd),longint(@p^.buf^),DIRBLKSIZ {sizeof(getdentsbuffer)});
p^.rewind:=longint(p^.buf);
if retval=0 then
begin
p^.rewind:=0;
p^.loc:=0;
end
else
P^.loc:=retval;
readbuffer:=retval;
end;
var
l : pdirent;
novalid : boolean;
begin
if (p^.buf=nil) or (p^.loc=0) THEN
exit(nil);
if p^.loc=cardinal(-1) then {First readdir on this pdir. Initial fill of buffer}
begin
if readbuffer()=0 Then {nothing to be read}
exit(nil)
end;
l:=nil;
repeat
novalid:=false;
if (pdirent(p^.rewind)^.reclen<>0) then
begin {valid direntry?}
if pdirent(P^.rewind)^.ino<>0 then
l:=pdirent(p^.rewind);
inc(p^.rewind,pdirent(p^.rewind)^.reclen);
if p^.rewind>=(cardinal(p^.buf)+dirblksiz) then
novalid:=true;
end
else
novalid:=true;
if novalid then
begin {block entirely searched or reclen=0}
if p^.loc<>0 THEN {blocks left?}
if readbuffer()<>0 then {succesful read?}
novalid:=false;
end;
until (l<>nil) or novalid;
If novalid then
l:=nil;
Sys_ReadDir:=l;
end;
{$endif}
{*****************************************************************************
--- Process:Process & program handling - related calls ---
*****************************************************************************}
Function sys_GetPid:LongInt;
{
Get Process ID.
}
begin
sys_GetPID:=do_syscall(syscall_nr_getpid);
end;
Procedure Sys_Exit(ExitCode:longint);
begin
do_syscall(syscall_nr_exit,exitcode);
end;
{
Change action of process upon receipt of a signal.
Signum specifies the signal (all except SigKill and SigStop).
If Act is non-nil, it is used to specify the new action.
If OldAct is non-nil the previous action is saved there.
}
Procedure SigAction(Signum:longint;Act,OldAct:PSigActionRec );
{
Change action of process upon receipt of a signal.
Signum specifies the signal (all except SigKill and SigStop).
If Act is non-nil, it is used to specify the new action.
If OldAct is non-nil the previous action is saved there.
}
begin
do_syscall(syscall_nr_sigaction,longint(signum),longint(act),longint(oldact));
{$ifdef linuxunit}
LinuxError:=Errno;
{$endif}
end;
(*=================== MOVED from syslinux.inc ========================*)
Function Sys_FTruncate(Handle,Pos:longint):longint; //moved from sysunix.inc Do_Truncate
begin
Sys_FTruncate:=do_syscall(syscall_nr___syscall, syscall_nr_ftruncate,0,handle,0,pos,0);
end;
Function Sys_fstat(fd : longint;var Info:stat):Longint; // This was missing here, instead an fstat call was included in Do_FileSize
begin
Sys_FStat:=do_SysCall(syscall_nr_fstat,fd,longint(@info));
end;
{$ifdef NewReaddir}
{$I readdir.inc}
{$endif}
{
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 hardcoded in Do_IsDevice
begin
Sys_IOCtl:=do_SysCall(syscall_nr_ioctl,handle,Ndx,longint(data));
end;
Function Sys_mmap(adr,len,prot,flags,fdes,off:longint):longint; // moved from sysunix.inc, used in sbrk
begin
Sys_mmap:=do_syscall(syscall_nr_mmap,Adr,Len,Prot,Flags,fdes,off,0);
end;
{
$Log$
Revision 1.2 2003-01-17 22:13:47 marco
* some updates
Revision 1.1.2.4 2002/09/20 07:04:44 pierre
* avoid compiler warning
Revision 1.1.2.3 2002/01/23 09:10:05 marco
* Similar truncate test. truncate tests from testsuite now seem to pass
Revision 1.1.2.2 2001/08/29 09:43:07 marco
* first lseek fix. Still not 100%, but don't know exact problem yet.
Revision 1.1.2.1 2001/08/14 20:22:53 pierre
New file
Revision 1.1.2.7 2001/04/04 10:38:36 marco
* Small fix to readdir. Is this *the* bug?
Revision 1.1.2.6 2001/03/14 17:19:10 marco
* Readdir compiles (some conflicts in Linux). Untested. Use NewReaddir to enable
Revision 1.1.2.5 2001/03/12 20:37:50 marco
* [Solaris] Now cycles for FreeBSD (wrong version Linux unit commited)
Revision 1.1.2.4 2001/03/12 14:57:38 marco
* [solaris] added some sys functions to decrease amount of ifdefs needed
Revision 1.1.2.3 2000/09/19 09:58:49 marco
* Mkdir fix
Revision 1.1.2.2 2000/09/18 12:14:41 marco
* An addw in the do_syscall(integer) caused warnings. Fixed
Revision 1.1.2.1 2000/09/16 11:19:08 marco
* Moved files from BSD to FreeBSD directory, with some small changes
Revision 1.1.2.1 2000/09/10 16:12:14 marco
Initial signals, sockets and clone
Revision 1.1 2000/07/13 06:30:32 michael
+ Initial import
Revision 1.15 2000/04/16 16:08:53 marco
* Fixes (mainly opendir/Readdir/closedir)
Revision 1.14 2000/04/14 17:04:13 marco
* Working!
Revision 1.13 2000/04/10 15:46:52 marco
* worked all day. probably a lot changed
Revision 1.11 2000/04/05 13:58:40 marco
* syscall variablenames reintroduced.
Revision 1.10 2000/03/16 16:18:12 marco
* Last changes before next test. ppc386 -h works with these srcs.
Revision 1.9 2000/03/02 15:34:07 marco
* added a syscall for 5 longints
Revision 1.8 2000/03/01 20:03:57 marco
* small fixes for syslinux
Revision 1.7 2000/03/01 17:28:40 marco
* some changes due to updating linux.pp to new syscall
Revision 1.6 2000/02/27 23:45:39 marco
* Redone the syscalls
Revision 1.5 2000/02/04 16:53:26 marco
* Finished Linux (and rest syscalls) roughly. Some things still need to be
tested, and checked (off_t calls specially)
Revision 1.4 2000/02/03 17:04:47 marco
* additions fixes due to port linux
Revision 1.3 2000/02/02 18:07:27 marco
* Ported except for readdir which is 200 lines C code in FBSD linux
emulator
Revision 1.2 2000/02/02 16:35:10 marco
* Ported more functions. Half done now.
Revision 1.1 2000/02/02 15:41:56 marco
* Initial BSD version. Still needs a lot of work.
}

138
rtl/netbsd/sysconst.inc Normal file
View File

@ -0,0 +1,138 @@
{
$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.
**********************************************************************}
{BSD version, only the blocks with BSD in the comment are updated}
Const
{ Things for LSEEK call, same in linux and BSD }
Seek_set = 0;
Seek_Cur = 1;
Seek_End = 2;
{ Things for OPEN call - after include/sys/fcntl.h, BSD updated.
BSD specifies these constants in hex }
Open_Accmode = 3;
Open_RdOnly = 0;
Open_WrOnly = 1;
Open_RdWr = 2;
Open_NonBlock = 4;
Open_Append = 8;
Open_ShLock = $10;
Open_ExLock = $20;
Open_ASync = $40;
Open_FSync = $80;
Open_NoFollow = $100;
Open_Create = $200; {BSD convention}
Open_Creat = $200; {Linux convention}
Open_Trunc = $400;
Open_Excl = $800;
Open_NOCTTY = $8000;
{ The waitpid uses the following options:}
Wait_NoHang = 1;
Wait_UnTraced = 2;
Wait_Any = -1;
Wait_MyPGRP = 0;
{ Constants to check stat.mode - checked all STAT constants with BSD}
STAT_IFMT = $f000; {00170000 }
STAT_IFSOCK = $c000; {0140000 }
STAT_IFLNK = $a000; {0120000 }
STAT_IFREG = $8000; {0100000 }
STAT_IFBLK = $6000; {0060000 }
STAT_IFDIR = $4000; {0040000 }
STAT_IFCHR = $2000; {0020000 }
STAT_IFIFO = $1000; {0010000 }
STAT_ISUID = $0800; {0004000 }
STAT_ISGID = $0400; {0002000 }
STAT_ISVTX = $0200; {0001000}
{ Constants to check permissions all }
STAT_IRWXO = $7;
STAT_IROTH = $4;
STAT_IWOTH = $2;
STAT_IXOTH = $1;
STAT_IRWXG = STAT_IRWXO shl 3;
STAT_IRGRP = STAT_IROTH shl 3;
STAT_IWGRP = STAT_IWOTH shl 3;
STAT_IXGRP = STAT_IXOTH shl 3;
STAT_IRWXU = STAT_IRWXO shl 6;
STAT_IRUSR = STAT_IROTH shl 6;
STAT_IWUSR = STAT_IWOTH shl 6;
STAT_IXUSR = STAT_IXOTH shl 6;
{ Constants to test the type of filesystem }
fs_old_ext2 = $ef51;
fs_ext2 = $ef53;
fs_ext = $137d;
fs_iso = $9660;
fs_minix = $137f;
fs_minix_30 = $138f;
fs_minux_V2 = $2468;
fs_msdos = $4d44;
fs_nfs = $6969;
fs_proc = $9fa0;
fs_xia = $012FD16D;
{ Constansts for MMAP }
MAP_PRIVATE =2;
MAP_ANONYMOUS =$1000;
{Constansts Termios/Ioctl (used in Do_IsDevice) }
IOCtl_TCGETS=$5401; // TCGETS is also in termios.inc, but the sysunix needs only this
{
$Log$
Revision 1.2 2003-01-17 22:13:47 marco
* some updates
Revision 1.1.2.1 2001/08/10 11:07:17 pierre
New NetBSD files taken and adapted from FreeBSD
Revision 1.1.2.3 2001/03/12 14:58:37 marco
* [Solaris] some constants moved from sysunix.inc
Revision 1.1.2.2 2000/11/03 14:58:52 marco
* Open_NoCTTY added. Needed for serial.pp
Revision 1.1.2.1 2000/09/16 11:19:08 marco
* Moved files from BSD to FreeBSD directory, with some small changes
Revision 1.1 2000/07/13 06:30:33 michael
+ Initial import
Revision 1.5 2000/04/10 15:46:52 marco
* worked all day. probably a lot changed
Revision 1.3 2000/02/03 17:05:13 marco
* fixes and updates due to linux unit porting
Revision 1.2 2000/02/02 16:35:29 marco
* Checked stat constants
Revision 1.1 2000/02/02 15:41:28 marco
* initial BSD version.
Revision 1.4 2000/01/07 16:41:41 daniel
* copyright 2000
Revision 1.3 2000/01/07 16:32:28 daniel
* copyright 2000 added
Revision 1.2 1998/05/06 12:38:22 michael
+ Removed log from before restored version.
Revision 1.1.1.1 1998/03/25 11:18:43 root
* Restored version
}

214
rtl/netbsd/systypes.inc Normal file
View File

@ -0,0 +1,214 @@
{
$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.
**********************************************************************}
type
{
Linux system calls take arguments as follows :
i386/m68k:
%eax/%d0 : System call number
%ebx/%d1 : first argument
%ecx/%d2 : second argument
%edx/%d3 : third argumens
%esi/%d3 : fourth argument
%edi/%d4 : fifth argument
That is why we define a special type, with only these arguments
To make it processor independent, we don't give any system dependent
names, but the rather abstract reg1,reg2 etc;
SysCallRegs=record
reg1,reg2,reg3,reg4,reg5,reg6 : longint;
end;
PSysCallRegs=^SysCallRegs;
TSysCallRegs=SysCallRegs;
}
{ The following are records for system calls BSD updated }
dirent = packed record
ino : cardinal; { This is not inode number, but "a number
unique for each file on a filesystem"}
reclen : word;
d_type,
namlen : byte;
name : array [0..255] of char;
end;
pdirent =^dirent;
TDirEnt = dirent;
TDir= packed record {BSD libc record.}
fd : longint; { file descriptor associated with directory }
loc, { offset in current buffer }
size : cardinal; { amount of data returned by getdirentries}
buf : pdirent; { data buffer, actually a pchar}
len : longint; { size of data buffer }
seek, { magic cookie returned by getdirentries}
rewind: cardinal; { magic cookie for rewinding}
flags : longint; { flags for readdir }
end;
(* Linux kernel record
TDir = packed record
fd : longint;
loc : longint;
size : integer;
buf : pdirent;
{The following are used in libc, but NOT in the linux kernel sources ??}
nextoff: longint;
dd_max : integer; {size of buf. Irrelevant, as buf is of type dirent}
lock : pointer;
dummy : array[0..1023] of char;
end; *)
PDir =^TDir;
{$packrecords C}
type
dev_t = cardinal; // taken from sysunix.getdir to avoid ifdef's.
Stat =record {BSD version}
dev, { inode's device }
ino : cardinal; { inode's number }
mode, { inode protection mode }
nlink : longint; { number of hard links }
uid, { user ID of the file's owner }
gid, { group ID of the file's group }
dev_t : cardinal; { device type }
atime, { time of last access }
atime_nsec, { nsec of last access }
mtime, { time of last data modification }
mtime_nsec, { nsec of last data modification }
ctime, { time of last file status change }
ctime_nsec : longint; { nsec of last file status change }
size, { file size, in bytes }
blocks : Int64; { blocks allocated for file }
blksze, { optimal blocksize for I/O }
flags, { user defined flags for file }
filegen : cardinal; { file generation number }
// lspare : longint;
qspare : array[0..1] of int64;
end;
PStat=^Stat;
TStat=Stat;
Statfs = packed record
spare2, { place holder}
bsize, { fundamental block size}
iosize, { optimal block size }
blocks, { total blocks}
bfree, { blocks free}
bavail, { block available for mortal users}
files, { Total file nodes}
ffree : longint; { file nodes free}
fsid : array[0..1] of longint;
fowner : longint; {mounter uid}
ftype : longint;
fflags : longint; {copy of mount flags}
spare : array [0..1] of longint; { For later use }
fstypename : array[0..15] of char;
mountpoint : array[0..89] of char;
mnfromname : array[0..89] of char;
end;
PStatFS=^StatFS;
TStatFS=StatFS;
fdSet=array[0..7] of longint;{=256 bits}
pfdset=^fdset;
TFDSet=fdset;
timeval = packed record
sec,usec:longint;
end;
ptimeval=^timeval;
TTimeVal=timeval;
timespec = packed record
tv_sec,tv_nsec:longint;
end;
timezone = packed record
minuteswest,dsttime:longint;
end;
ptimezone =^timezone;
TTimeZone = timezone;
utsname = packed record
sysname,
nodename,
release,
version,
machine,
domainname : Array[0..64] of char;
end;
PUTSName=^UTSName;
TUTSName=UTSName;
{
$Log$
Revision 1.2 2003-01-17 22:13:47 marco
* some updates
Revision 1.1.2.2 2001/08/30 23:00:18 marco
* Fix for stat record.
Revision 1.1.2.1 2001/08/10 11:07:17 pierre
New NetBSD files taken and adapted from FreeBSD
Revision 1.1.2.5 2001/03/12 15:01:39 marco
* [Solaris] introduced dev_t
Revision 1.1.2.4 2001/01/20 16:54:51 marco
* Fixed timeval. Must have thought that long=int64 when I did initial port?
Revision 1.1.2.3 2000/10/30 14:36:07 marco
* timespec from int64 to longint.
Revision 1.1.2.2 2000/10/24 12:14:37 pierre
+ timespec type for syscall_nr_nanosleep
Revision 1.1.2.1 2000/09/16 11:19:08 marco
* Moved files from BSD to FreeBSD directory, with some small changes
Revision 1.1.2.1 2000/09/10 16:12:14 marco
Initial signals, sockets and clone
Revision 1.1 2000/07/13 06:30:33 michael
+ Initial import
Revision 1.8 2000/04/16 16:08:30 marco
* Updated PDir to BSD libc layout. (which is totally different from Linux)
Revision 1.7 2000/04/10 15:46:52 marco
* worked all day. probably a lot changed
Revision 1.5 2000/03/17 12:58:57 marco
* some changes to ftruncate based procs. Added a "0" as extra parameter
Revision 1.4 2000/02/04 16:55:47 marco
* Fixed tdir, some params need to be 32-bit
Revision 1.3 2000/02/03 17:05:55 marco
* Some types fixed/ported.
Revision 1.2 2000/02/02 16:45:38 marco
* Typo in STAT record
Revision 1.1 2000/02/02 16:36:09 marco
* Initial version. Copy of linux version, with BSD stat.
}