* freebsd update

* classes.rst
This commit is contained in:
peter 2000-10-26 22:30:21 +00:00
parent c10d4a9846
commit 392d0a5ebb
16 changed files with 2228 additions and 41 deletions

1540
fcl/freebsd/Makefile Normal file

File diff suppressed because it is too large Load Diff

48
fcl/freebsd/Makefile.fpc Normal file
View File

@ -0,0 +1,48 @@
#
# Makefile.fpc for Free Component Library for FreeBSD
#
[targets]
dirs=../db ../xml ../shedit
units=classes $(INCUNITS) process asyncio ssockets http
rst=classes ssockets cachecls
[defaults]
defaulttarget=freebsd
[require]
options=-S2
packages=zlib inet
[install]
unitsubdir=fcl
packagename=fcl
[libs]
libname=libfpfcl.so
libversion=1.0
[dirs]
fpcdir=../..
targetdir=.
incdir=$(INC) $(UNIXINC)
sourcesdir=$(INC) $(UNIXINC)
[presettings]
# Include files
UNIXINC=../unix
INC=../inc
# INCUNITS is defined in makefile.inc
# They are default units for all platforms.
include $(INC)/Makefile.inc
[rules]
classes$(PPUEXT): $(addprefix $(INC)/,$(INCNAMES)) $(UNIXINC)/classes$(PASEXT)
inifiles$(PPUEXT): classes$(PPUEXT) $(INC)/inifiles$(PASEXT)
ezcgi$(PPUEXT): $(INC)/ezcgi$(PASEXT)
process$(PPUEXT): process$(PASEXT) process.inc

95
fcl/freebsd/classes.pp Normal file
View File

@ -0,0 +1,95 @@
{
$Id$
This file is part of the Free Component Library (FCL)
Copyright (c) 1999-2000 by Michael Van Canneyt and Florian Klaempfl
Classes unit for linux
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.
**********************************************************************}
{$mode objfpc}
{ determine the type of the resource/form file }
{$define Win16Res}
unit Classes;
interface
uses
sysutils,
typinfo;
{$i classesh.inc}
implementation
uses
linux;
{ OS - independent class implementations are in /inc directory. }
{$i classes.inc}
initialization
CommonInit;
finalization
CommonCleanup;
if ThreadsInited then
DoneThreads;
end.
{
$Log$
Revision 1.2 2000-10-26 22:30:21 peter
* freebsd update
* classes.rst
Revision 1.1.2.1 2000/10/17 13:47:43 marco
* Copy of fcl/linux dir with adapted makefiles to ease FreeBSD 1.0.2
packaging
Revision 1.1 2000/07/13 06:31:32 michael
+ Initial import
Revision 1.19 2000/07/01 09:49:02 peter
* fixed go32v2,win32 build
Revision 1.18 2000/06/29 16:32:06 sg
* Changes in initialisation/finalisation for streaming support
Revision 1.17 2000/06/27 17:17:34 lazarus
Added code for registerclass, GetClass and RegisterClasses
Shane
Revision 1.16 2000/06/27 15:55:19 lazarus
Added TThreadlist code. Shane
Revision 1.15 2000/01/07 01:24:34 peter
* updated copyright to 2000
Revision 1.14 2000/01/07 00:01:33 peter
* uses typinfo moved to interface
Revision 1.13 2000/01/06 01:20:33 peter
* moved out of packages/ back to topdir
Revision 1.2 2000/01/04 18:07:58 michael
+ Added typinfo unit
Revision 1.1 2000/01/03 19:33:09 peter
* moved to packages dir
Revision 1.11 1999/05/30 10:46:41 peter
* start of tthread for linux,win32
}

7
fcl/freebsd/notice.txt Normal file
View File

@ -0,0 +1,7 @@
This directory is only temporarily, to ease working on FPC/FreeBSD 1.0.2
packaging. After that is done, the API and FCL will be restructured like the
RTL. (linux - unix - freebsd structure)
This dir is a plain copy from the api/linux dir with some small substitutions in
makefile.fpc (to select the right target)

126
fcl/freebsd/process.inc Normal file
View File

@ -0,0 +1,126 @@
{
$Id$
This file is part of the Free Pascal run time library.
Copyright (c) 1999-2000 by Michael Van Canneyt
Linux specific part of TProcess.
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.
**********************************************************************}
uses linux;
Function TProcess.GetRunning : Boolean;
begin
IF FRunning then
FRunning:=GetExitStatus=-1;
Result:=FRunning;
end;
Procedure TProcess.Execute;
begin
FreeStreams;
CreatePipeStreams (FChildInputSTream,FParentOutPutStream);
CreatePipeStreams (FParentInputStream,FChildOutPutStream);
If poUsePipes in FCreateOptions then
begin
if poStdErrToOutPut in FCreateOptions then
CreatePipeStreams (FParentErrorStream,FChildErrorStream)
else
begin
FChildErrorStream:=FChildOutPutStream;
FParentErrorStream:=FParentInputStream;
end;
end
else
CreatePipeStreams (FParentErrorStream,FChildErrorStream);
If FCurrentDirectory<>'' then
Chdir(FCurrentDirectory);
FHandle:=fork();
if FHandle=0 then
begin
// Child
fdClose(0);
fdClose(1);
fdclose(2);
dup2(FChildInputStream.Handle,0);
dup2(FCHildOutputStream.Handle,1);
dup2(FChildErrorStream.Handle,2);
execl(FCommandline);
halt(127);
end
else
begin
// Parent
FPID:=FHandle;
FThreadHandle:=FHandle;
fdclose(FChildOutputStream.Handle);
fdclose(FChildInputStream.Handle);
fdclose(FChildErrorStream.Handle);
FRunning:=True;
if (poWaitOnExit in FCreateOptions) and
not (poRunSuspended in FCreateOptions) then
WaitOnExit;
end;
end;
Function TProcess.WaitOnExit : Dword;
begin
waitpid(FPID, nil, 0);
{
Result:=WaitForSingleObject (FprocessInformation.hProcess,Infinite);
If Result<>Wait_Failed then
GetExitStatus;
} FRunning:=False;
Result := 0;
end;
Function TProcess.Suspend : Longint;
begin
Result:=Kill(Handle,SIGSTOP);
end;
Function TProcess.Resume : LongInt;
begin
Result:=Kill(FHandle,SIGCONT);
end;
Function TProcess.Terminate(AExitCode : Integer) : Boolean;
begin
Result:=False;
If ExitStatus=-1 then
Result:=Kill(FHandle,SIGTERM)=0;
end;
{
$Log$
Revision 1.2 2000-10-26 22:30:21 peter
* freebsd update
* classes.rst
Revision 1.1.2.1 2000/10/17 13:47:43 marco
* Copy of fcl/linux dir with adapted makefiles to ease FreeBSD 1.0.2
packaging
Revision 1.1 2000/07/13 06:33:44 michael
+ Initial import
Revision 1.5 2000/02/15 22:03:38 sg
* Inserted wrong copyright notice ;) Fixed.
Revision 1.4 2000/02/15 21:57:51 sg
* Added copyright notice and CVS log tags where necessary
}

321
fcl/freebsd/thread.inc Normal file
View File

@ -0,0 +1,321 @@
{
$Id$
This file is part of the Free Component Library (FCL)
Copyright (c) 1999-2000 by Peter Vreman
Linux TThread implementation
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
PThreadRec=^TThreadRec;
TThreadRec=record
thread : TThread;
next : PThreadRec;
end;
var
ThreadRoot : PThreadRec;
ThreadsInited : boolean;
// MainThreadID: longint;
Const
ThreadCount: longint = 0;
function ThreadSelf:TThread;
var
hp : PThreadRec;
sp : longint;
begin
sp:=SPtr;
hp:=ThreadRoot;
while assigned(hp) do
begin
if (sp<=hp^.Thread.FStackPointer) and
(sp>(hp^.Thread.FStackPointer-hp^.Thread.FStackSize)) then
begin
Result:=hp^.Thread;
exit;
end;
hp:=hp^.next;
end;
Result:=nil;
end;
//function SIGCHLDHandler(Sig: longint): longint; cdecl;//this is std linux C declaration as function
procedure SIGCHLDHandler(Sig: longint); cdecl;
begin
waitpid(-1, nil, WNOHANG);
end;
procedure InitThreads;
var
Act, OldAct: PSigActionRec;
begin
ThreadRoot:=nil;
ThreadsInited:=true;
// This will install SIGCHLD signal handler
// signal() installs "one-shot" handler,
// so it is better to install and set up handler with sigaction()
GetMem(Act, SizeOf(SigActionRec));
GetMem(OldAct, SizeOf(SigActionRec));
Act^.handler.sh := @SIGCHLDHandler;
Act^.sa_flags := SA_NOCLDSTOP {or SA_NOMASK or SA_RESTART};
Act^.sa_mask := 0; //Do not block all signals ??. Don't need if SA_NOMASK in flags
SigAction(SIGCHLD, Act, OldAct);
FreeMem(Act, SizeOf(SigActionRec));
FreeMem(OldAct, SizeOf(SigActionRec));
end;
procedure DoneThreads;
var
hp : PThreadRec;
begin
while assigned(ThreadRoot) do
begin
ThreadRoot^.Thread.Destroy;
hp:=ThreadRoot;
ThreadRoot:=ThreadRoot^.Next;
dispose(hp);
end;
ThreadsInited:=false;
end;
procedure AddThread(t:TThread);
var
hp : PThreadRec;
begin
{ Need to initialize threads ? }
if not ThreadsInited then
InitThreads;
{ Put thread in the linked list }
new(hp);
hp^.Thread:=t;
hp^.next:=ThreadRoot;
ThreadRoot:=hp;
inc(ThreadCount, 1);
end;
procedure RemoveThread(t:TThread);
var
lasthp,hp : PThreadRec;
begin
hp:=ThreadRoot;
lasthp:=nil;
while assigned(hp) do
begin
if hp^.Thread=t then
begin
if assigned(lasthp) then
lasthp^.next:=hp^.next
else
ThreadRoot:=hp^.next;
dispose(hp);
exit;
end;
lasthp:=hp;
hp:=hp^.next;
end;
Dec(ThreadCount, 1);
if ThreadCount = 0 then DoneThreads;
end;
{ TThread }
function ThreadProc(args:pointer): Integer;cdecl;
var
FreeThread: Boolean;
Thread : TThread absolute args;
begin
Thread.Execute;
FreeThread := Thread.FFreeOnTerminate;
Result := Thread.FReturnValue;
Thread.FFinished := True;
Thread.DoTerminate;
if FreeThread then
Thread.Free;
ExitProcess(Result);
end;
constructor TThread.Create(CreateSuspended: Boolean);
var
Flags: Integer;
begin
inherited Create;
AddThread(self);
FSuspended := CreateSuspended;
Flags := CLONE_VM + CLONE_FS + CLONE_FILES + CLONE_SIGHAND + SIGCHLD;
{ Setup 16k of stack }
FStackSize:=16384;
Getmem(pointer(FStackPointer),FStackSize);
inc(FStackPointer,FStackSize);
FCallExitProcess:=false;
{ Clone }
FHandle:= Clone(@ThreadProc,pointer(FStackPointer),Flags,self);
if FSuspended then Suspend;
FThreadID := FHandle;
end;
destructor TThread.Destroy;
begin
if not FFinished and not Suspended then
begin
Terminate;
WaitFor;
end;
if FHandle <> -1 then
Kill(FHandle, SIGKILL);
dec(FStackPointer,FStackSize);
Freemem(pointer(FStackPointer),FStackSize);
inherited Destroy;
RemoveThread(self);
end;
procedure TThread.CallOnTerminate;
begin
FOnTerminate(Self);
end;
procedure TThread.DoTerminate;
begin
if Assigned(FOnTerminate) then
Synchronize(@CallOnTerminate);
end;
const
{ I Don't know idle or timecritical, value is also 20, so the largest other
possibility is 19 (PFV) }
Priorities: array [TThreadPriority] of Integer =
(-20,-19,-10,9,10,19,20);
function TThread.GetPriority: TThreadPriority;
var
P: Integer;
I: TThreadPriority;
begin
P := Linux.GetPriority(Prio_Process,FHandle);
Result := tpNormal;
for I := Low(TThreadPriority) to High(TThreadPriority) do
if Priorities[I] = P then
Result := I;
end;
procedure TThread.SetPriority(Value: TThreadPriority);
begin
Linux.SetPriority(Prio_Process,FHandle, Priorities[Value]);
end;
procedure TThread.Synchronize(Method: TThreadMethod);
begin
FSynchronizeException := nil;
FMethod := Method;
{ SendMessage(ThreadWindow, CM_EXECPROC, 0, Longint(Self)); }
if Assigned(FSynchronizeException) then
raise FSynchronizeException;
end;
procedure TThread.SetSuspended(Value: Boolean);
begin
if Value <> FSuspended then
if Value then
Suspend
else
Resume;
end;
procedure TThread.Suspend;
begin
Kill(FHandle, SIGSTOP);
FSuspended := true;
end;
procedure TThread.Resume;
begin
Kill(FHandle, SIGCONT);
FSuspended := False;
end;
procedure TThread.Terminate;
begin
FTerminated := True;
end;
function TThread.WaitFor: Integer;
var
status : longint;
begin
if FThreadID = MainThreadID then
WaitPid(0,@status,0)
else
WaitPid(FHandle,@status,0);
Result:=status;
end;
{
$Log$
Revision 1.2 2000-10-26 22:30:21 peter
* freebsd update
* classes.rst
Revision 1.1.2.1 2000/10/17 13:47:43 marco
* Copy of fcl/linux dir with adapted makefiles to ease FreeBSD 1.0.2
packaging
Revision 1.1 2000/07/13 06:33:44 michael
+ Initial import
Revision 1.9 2000/05/17 18:31:18 peter
* fixed for new sigactionrec
Revision 1.8 2000/01/07 01:24:34 peter
* updated copyright to 2000
Revision 1.7 2000/01/06 01:20:33 peter
* moved out of packages/ back to topdir
Revision 1.1 2000/01/03 19:33:09 peter
* moved to packages dir
Revision 1.5 1999/10/27 10:40:30 peter
* fixed threadproc decl
Revision 1.4 1999/08/28 09:32:26 peter
* readded header/log
Revision 1.2 1999/05/31 12:47:59 peter
* classes unit to unitobjects
Revision 1.1 1999/05/30 10:46:42 peter
* start of tthread for linux,win32
}

View File

@ -1,5 +1,5 @@
#
# Makefile generated by fpcmake v1.00 [2000/10/01]
# Makefile generated by fpcmake v1.00 [2000/10/27]
#
defaultrule: all
@ -194,7 +194,7 @@ endif
override DIROBJECTS+=$(wildcard ../xml ../shedit)
override UNITOBJECTS+=classes $(INCUNITS)
override RSTOBJECTS+=ssockets cachecls
override RSTOBJECTS+=classes ssockets cachecls
# Clean
@ -279,7 +279,7 @@ endif
# To install files
ifndef INSTALL
ifdef inUnix
INSTALL:=install -m 644
INSTALL:=install -c -m 644
else
INSTALL:=$(COPY)
endif
@ -288,7 +288,7 @@ endif
# To install programs
ifndef INSTALLEXE
ifdef inUnix
INSTALLEXE:=install -m 755
INSTALLEXE:=install -c -m 755
else
INSTALLEXE:=$(COPY)
endif
@ -407,10 +407,10 @@ endif
export TARPROG
ifeq ($(USETAR),bz2)
TAROPT=vI
TAROPT=vIf
TAREXT=.tar.bz2
else
TAROPT=vz
TAROPT=vzf
TAREXT=.tar.gz
endif

View File

@ -5,7 +5,7 @@
[targets]
dirs=../xml ../shedit
units=classes $(INCUNITS)
rst=ssockets cachecls
rst=classes ssockets cachecls
[defaults]
defaulttarget=go32v2

View File

@ -1,5 +1,5 @@
#
# Makefile generated by fpcmake v1.00 [2000/10/01]
# Makefile generated by fpcmake v1.00 [2000/10/27]
#
defaultrule: all
@ -116,10 +116,13 @@ export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION
#####################################################################
# Include files
INC=../inc
UNIXINC=../unix
# INCUNITS is defined in makefile.inc
# They are default units for all platforms.
include $(INC)/Makefile.inc
#####################################################################
# FPCDIR Setting
@ -194,7 +197,7 @@ endif
override DIROBJECTS+=$(wildcard ../db ../xml ../shedit)
override UNITOBJECTS+=classes $(INCUNITS) process asyncio ssockets http
override RSTOBJECTS+=ssockets cachecls
override RSTOBJECTS+=classes ssockets cachecls
# Clean
@ -211,8 +214,8 @@ override NEEDOPT=-S2
# Directories
vpath %$(PASEXT) $(INC)
override NEEDINCDIR=$(INC)
vpath %$(PASEXT) $(INC) $(UNIXINC)
override NEEDINCDIR=$(INC) $(UNIXINC)
ifndef TARGETDIR
TARGETDIR=.
endif
@ -280,7 +283,7 @@ endif
# To install files
ifndef INSTALL
ifdef inUnix
INSTALL:=install -m 644
INSTALL:=install -c -m 644
else
INSTALL:=$(COPY)
endif
@ -289,7 +292,7 @@ endif
# To install programs
ifndef INSTALLEXE
ifdef inUnix
INSTALLEXE:=install -m 755
INSTALLEXE:=install -c -m 755
else
INSTALLEXE:=$(COPY)
endif
@ -408,10 +411,10 @@ endif
export TARPROG
ifeq ($(USETAR),bz2)
TAROPT=vI
TAROPT=vIf
TAREXT=.tar.bz2
else
TAROPT=vz
TAROPT=vzf
TAREXT=.tar.gz
endif

View File

@ -5,7 +5,7 @@
[targets]
dirs=../db ../xml ../shedit
units=classes $(INCUNITS) process asyncio ssockets http
rst=ssockets cachecls
rst=classes ssockets cachecls
[defaults]
defaulttarget=linux
@ -25,18 +25,19 @@ libversion=1.0
[dirs]
fpcdir=../..
targetdir=.
incdir=$(INC)
sourcesdir=$(INC)
incdir=$(INC) $(UNIXINC)
sourcesdir=$(INC) $(UNIXINC)
[presettings]
# Include files
INC=../inc
UNIXINC=../unix
# INCUNITS is defined in makefile.inc
# They are default units for all platforms.
include $(INC)/Makefile.inc
include $(INC)/Makefile.inc
[rules]
classes$(PPUEXT): $(addprefix $(INC)/,$(INCNAMES)) classes$(PASEXT)

View File

@ -159,7 +159,20 @@ end;
{
$Log$
Revision 1.2 2000-07-13 11:33:01 michael
+ removed logs
}
Revision 1.2 2000-10-26 22:30:21 peter
* freebsd update
* classes.rst
Revision 1.1.2.1 2000/10/25 12:36:24 marco
* Split up Freebsd/Unix/Linux for Fixes FCL
Revision 1.1 2000/07/13 06:31:32 michael
+ Initial import
Revision 1.2 2000/07/09 11:48:24 sg
* Implemented methods for reading event handlers
Revision 1.1 2000/02/18 23:14:10 michael
+ Initial implementation
}

View File

@ -25,7 +25,17 @@ Type
{
$Log$
Revision 1.2 2000-07-13 11:33:01 michael
+ removed logs
}
Revision 1.2 2000-10-26 22:30:21 peter
* freebsd update
* classes.rst
Revision 1.1.2.1 2000/10/25 12:36:24 marco
* Split up Freebsd/Unix/Linux for Fixes FCL
Revision 1.1 2000/07/13 06:31:32 michael
+ Initial import
Revision 1.1 2000/02/18 23:14:10 michael
+ Initial implementation
}

View File

@ -32,7 +32,20 @@ end;
{
$Log$
Revision 1.2 2000-07-13 11:33:01 michael
+ removed logs
Revision 1.2 2000-10-26 22:30:21 peter
* freebsd update
* classes.rst
Revision 1.1.2.1 2000/10/25 12:36:24 marco
* Split up Freebsd/Unix/Linux for Fixes FCL
Revision 1.1 2000/07/13 06:31:32 michael
+ Initial import
Revision 1.7 2000/02/15 22:03:38 sg
* Inserted wrong copyright notice ;) Fixed.
Revision 1.6 2000/02/15 21:57:51 sg
* Added copyright notice and CVS log tags where necessary
}

View File

@ -24,7 +24,17 @@ end;
{
$Log$
Revision 1.2 2000-07-13 11:33:01 michael
+ removed logs
Revision 1.2 2000-10-26 22:30:21 peter
* freebsd update
* classes.rst
Revision 1.1.2.1 2000/10/25 12:36:24 marco
* Split up Freebsd/Unix/Linux for Fixes FCL
Revision 1.1 2000/07/13 06:31:32 michael
+ Initial import
Revision 1.5 2000/02/15 21:57:51 sg
* Added copyright notice and CVS log tags where necessary
}

View File

@ -1,5 +1,5 @@
#
# Makefile generated by fpcmake v1.00 [2000/10/01]
# Makefile generated by fpcmake v1.00 [2000/10/27]
#
defaultrule: all
@ -194,7 +194,7 @@ endif
override DIROBJECTS+=$(wildcard ../xml ../shedit)
override UNITOBJECTS+=classes $(INCUNITS) process fileinfo
override RSTOBJECTS+=ssockets cachecls
override RSTOBJECTS+=classes ssockets cachecls
# Clean
@ -279,7 +279,7 @@ endif
# To install files
ifndef INSTALL
ifdef inUnix
INSTALL:=install -m 644
INSTALL:=install -c -m 644
else
INSTALL:=$(COPY)
endif
@ -288,7 +288,7 @@ endif
# To install programs
ifndef INSTALLEXE
ifdef inUnix
INSTALLEXE:=install -m 755
INSTALLEXE:=install -c -m 755
else
INSTALLEXE:=$(COPY)
endif
@ -407,10 +407,10 @@ endif
export TARPROG
ifeq ($(USETAR),bz2)
TAROPT=vI
TAROPT=vIf
TAREXT=.tar.bz2
else
TAROPT=vz
TAROPT=vzf
TAREXT=.tar.gz
endif

View File

@ -5,7 +5,7 @@
[targets]
dirs=../xml ../shedit
units=classes $(INCUNITS) process fileinfo
rst=ssockets cachecls
rst=classes ssockets cachecls
[defaults]
defaulttarget=win32