mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-11 18:49:14 +02:00
*** empty log message ***
This commit is contained in:
parent
4795d620dc
commit
dcbb5bac16
@ -16,6 +16,8 @@
|
||||
**********************************************************************}
|
||||
|
||||
{$ifdef MT}
|
||||
type
|
||||
TThreadFunc = function(parameter : pointer) : longint;
|
||||
{*****************************************************************************
|
||||
Multithread Handling
|
||||
*****************************************************************************}
|
||||
@ -45,7 +47,10 @@ procedure LeaveCriticalsection(var cs : tcriticalsection);
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.3 2001-01-24 21:47:18 florian
|
||||
Revision 1.4 2001-01-26 16:37:54 florian
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.3 2001/01/24 21:47:18 florian
|
||||
+ more MT stuff added
|
||||
|
||||
Revision 1.2 2001/01/05 17:35:50 florian
|
||||
|
@ -28,6 +28,20 @@ interface
|
||||
{ include system-independent routine headers }
|
||||
{$I systemh.inc}
|
||||
|
||||
type
|
||||
{ the fields of this record are os dependent }
|
||||
{ and they shouldn't be used in a program }
|
||||
{ only the type TCriticalSection is important }
|
||||
TCriticalSection = packed record
|
||||
DebugInfo : pointer;
|
||||
LockCount : longint;
|
||||
RecursionCount : longint;
|
||||
OwningThread : DWord;
|
||||
LockSemaphore : DWord;
|
||||
Reserved : DWord;
|
||||
end;
|
||||
|
||||
|
||||
{ include threading stuff }
|
||||
{$i threadh.inc}
|
||||
|
||||
@ -283,9 +297,6 @@ begin
|
||||
sbrk:=l;
|
||||
end;
|
||||
|
||||
{ include threading stuff, this is os independend part }
|
||||
{$I thread.inc}
|
||||
|
||||
{ include standard heap management }
|
||||
{$I heap.inc}
|
||||
|
||||
@ -649,6 +660,23 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{*****************************************************************************
|
||||
Thread Handling
|
||||
*****************************************************************************}
|
||||
|
||||
const
|
||||
fpucw : word = $1332;
|
||||
|
||||
procedure InitFPU;assembler;
|
||||
|
||||
asm
|
||||
fninit
|
||||
fldcw fpucw
|
||||
end;
|
||||
|
||||
{ include threading stuff, this is os independend part }
|
||||
{$I thread.inc}
|
||||
|
||||
{*****************************************************************************
|
||||
SystemUnit Initialization
|
||||
*****************************************************************************}
|
||||
@ -794,9 +822,6 @@ var
|
||||
to check if the call stack can be written on exceptions }
|
||||
_SS : longint;
|
||||
|
||||
const
|
||||
fpucw : word = $1332;
|
||||
|
||||
procedure Exe_entry;[public, alias : '_FPC_EXE_Entry'];
|
||||
begin
|
||||
IsLibrary:=false;
|
||||
@ -812,8 +837,7 @@ procedure Exe_entry;[public, alias : '_FPC_EXE_Entry'];
|
||||
movl %eax,Win32StackTop
|
||||
movw %ss,%bp
|
||||
movl %ebp,_SS
|
||||
fninit
|
||||
fldcw fpucw
|
||||
call InitFPU
|
||||
xorl %ebp,%ebp
|
||||
call PASCALMAIN
|
||||
popl %ebp
|
||||
@ -860,6 +884,9 @@ var
|
||||
DLL_THREAD_ATTACH :
|
||||
begin
|
||||
inc(Thread_count);
|
||||
{$ifdef MT}
|
||||
AllocateThreadVars;
|
||||
{$endif MT}
|
||||
if assigned(Dll_Thread_Attach_Hook) then
|
||||
Dll_Thread_Attach_Hook(DllParam);
|
||||
Dll_entry:=true; { return value is ignored }
|
||||
@ -869,6 +896,9 @@ var
|
||||
dec(Thread_count);
|
||||
if assigned(Dll_Thread_Detach_Hook) then
|
||||
Dll_Thread_Detach_Hook(DllParam);
|
||||
{$ifdef MT}
|
||||
ReleaseThreadVars;
|
||||
{$endif MT}
|
||||
Dll_entry:=true; { return value is ignored }
|
||||
end;
|
||||
DLL_PROCESS_DETACH :
|
||||
@ -1393,7 +1423,10 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.4 2001-01-24 21:47:38 florian
|
||||
Revision 1.5 2001-01-26 16:38:03 florian
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.4 2001/01/24 21:47:38 florian
|
||||
+ more MT stuff added
|
||||
|
||||
Revision 1.3 2001/01/05 15:44:35 florian
|
||||
|
@ -41,6 +41,14 @@ function CreateThread(lpThreadAttributes : pointer;
|
||||
external 'kernel32' name 'CreateThread';
|
||||
procedure ExitThread(dwExitCode : DWord);
|
||||
external 'kernel32' name 'ExitThread';
|
||||
function GlobalAlloc(uFlags:UINT; dwBytes:DWORD):Pointer;
|
||||
external 'kernel32' name 'GlobalAlloc';
|
||||
function GlobalFree(hMem : Pointer):Pointer; external 'kernel32' name 'GlobalFree';
|
||||
|
||||
const
|
||||
{ GlobalAlloc, GlobalFlags }
|
||||
GMEM_FIXED = 0;
|
||||
GMEM_ZEROINIT = 64;
|
||||
|
||||
procedure init_threadvar(var offset : dword;size : dword);[public,alias: 'FPC_INIT_THREADVAR'];
|
||||
|
||||
@ -72,6 +80,17 @@ procedure AllocateThreadVars;
|
||||
TlsSetValue(dataindex,threadvars);
|
||||
end;
|
||||
|
||||
procedure ReleaseThreadVars;
|
||||
|
||||
var
|
||||
threadvars : pointer;
|
||||
|
||||
begin
|
||||
{ release thread vars }
|
||||
threadvars:=TlsGetValue(dataindex);
|
||||
GlobalFree(threadvars);
|
||||
end;
|
||||
|
||||
procedure InitThread;
|
||||
|
||||
begin
|
||||
@ -88,13 +107,9 @@ procedure InitThread;
|
||||
|
||||
procedure DoneThread;
|
||||
|
||||
var
|
||||
threadvars : pointer;
|
||||
|
||||
begin
|
||||
{ release thread vars }
|
||||
threadvars:=TlsGetValue(dataindex);
|
||||
GlobalFree(threadvars);
|
||||
ReleaseThreadVars;
|
||||
end;
|
||||
|
||||
function ThreadMain(param : pointer) : dword;stdcall;
|
||||
@ -220,7 +235,10 @@ procedure LeaveCriticalSection(var cs : tcriticalsection);
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.2 2001-01-24 21:47:38 florian
|
||||
Revision 1.3 2001-01-26 16:38:03 florian
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.2 2001/01/24 21:47:38 florian
|
||||
+ more MT stuff added
|
||||
|
||||
Revision 1.1 2001/01/01 19:06:36 florian
|
||||
|
Loading…
Reference in New Issue
Block a user