|
@@ -27,7 +27,6 @@
|
|
Threadvar support
|
|
Threadvar support
|
|
*****************************************************************************}
|
|
*****************************************************************************}
|
|
|
|
|
|
-{$ifdef HASTHREADVAR}
|
|
|
|
const
|
|
const
|
|
threadvarblocksize : dword = 0;
|
|
threadvarblocksize : dword = 0;
|
|
thredvarsmainthread: pointer = nil; // to free the threadvars in the signal handler
|
|
thredvarsmainthread: pointer = nil; // to free the threadvars in the signal handler
|
|
@@ -82,7 +81,6 @@
|
|
pthread_setspecific(tlskey,newPtr);
|
|
pthread_setspecific(tlskey,newPtr);
|
|
end;
|
|
end;
|
|
|
|
|
|
-{$endif HASTHREADVAR}
|
|
|
|
|
|
|
|
|
|
|
|
{*****************************************************************************
|
|
{*****************************************************************************
|
|
@@ -100,10 +98,8 @@
|
|
procedure DoneThread;
|
|
procedure DoneThread;
|
|
begin
|
|
begin
|
|
{ Release Threadvars }
|
|
{ Release Threadvars }
|
|
-{$ifdef HASTHREADVAR}
|
|
|
|
WRITE_DEBUG('DoneThread, releasing threadvars'#13#10);
|
|
WRITE_DEBUG('DoneThread, releasing threadvars'#13#10);
|
|
SysReleaseThreadVars;
|
|
SysReleaseThreadVars;
|
|
-{$endif HASTHREADVAR}
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -112,11 +108,9 @@
|
|
ti : tthreadinfo;
|
|
ti : tthreadinfo;
|
|
begin
|
|
begin
|
|
WRITE_DEBUG('New thread started, initing threadvars'#13#10);
|
|
WRITE_DEBUG('New thread started, initing threadvars'#13#10);
|
|
-{$ifdef HASTHREADVAR}
|
|
|
|
{ Allocate local thread vars, this must be the first thing,
|
|
{ Allocate local thread vars, this must be the first thing,
|
|
because the exception management and io depends on threadvars }
|
|
because the exception management and io depends on threadvars }
|
|
SysAllocateThreadVars;
|
|
SysAllocateThreadVars;
|
|
-{$endif HASTHREADVAR}
|
|
|
|
{ Copy parameter to local data }
|
|
{ Copy parameter to local data }
|
|
WRITE_DEBUG('New thread started, initialising ...'#13#10);
|
|
WRITE_DEBUG('New thread started, initialising ...'#13#10);
|
|
ti:=pthreadinfo(param)^;
|
|
ti:=pthreadinfo(param)^;
|
|
@@ -143,11 +137,9 @@
|
|
{ Initialize multithreading if not done }
|
|
{ Initialize multithreading if not done }
|
|
if not IsMultiThread then
|
|
if not IsMultiThread then
|
|
begin
|
|
begin
|
|
-{$ifdef HASTHREADVAR}
|
|
|
|
{ We're still running in single thread mode, setup the TLS }
|
|
{ We're still running in single thread mode, setup the TLS }
|
|
pthread_key_create(@TLSKey,nil);
|
|
pthread_key_create(@TLSKey,nil);
|
|
InitThreadVars(@SysRelocateThreadvar);
|
|
InitThreadVars(@SysRelocateThreadvar);
|
|
-{$endif HASTHREADVAR}
|
|
|
|
IsMultiThread:=true;
|
|
IsMultiThread:=true;
|
|
end;
|
|
end;
|
|
{ the only way to pass data to the newly created thread
|
|
{ the only way to pass data to the newly created thread
|
|
@@ -423,12 +415,10 @@ begin
|
|
DoneCriticalSection :=@SysDoneCriticalSection;
|
|
DoneCriticalSection :=@SysDoneCriticalSection;
|
|
EnterCriticalSection :=@SysEnterCriticalSection;
|
|
EnterCriticalSection :=@SysEnterCriticalSection;
|
|
LeaveCriticalSection :=@SysLeaveCriticalSection;
|
|
LeaveCriticalSection :=@SysLeaveCriticalSection;
|
|
-{$ifdef hasthreadvar}
|
|
|
|
InitThreadVar :=@SysInitThreadVar;
|
|
InitThreadVar :=@SysInitThreadVar;
|
|
RelocateThreadVar :=@SysRelocateThreadVar;
|
|
RelocateThreadVar :=@SysRelocateThreadVar;
|
|
AllocateThreadVars :=@SysAllocateThreadVars;
|
|
AllocateThreadVars :=@SysAllocateThreadVars;
|
|
ReleaseThreadVars :=@SysReleaseThreadVars;
|
|
ReleaseThreadVars :=@SysReleaseThreadVars;
|
|
-{$endif}
|
|
|
|
BasicEventCreate :=@intBasicEventCreate;
|
|
BasicEventCreate :=@intBasicEventCreate;
|
|
BasicEventDestroy :=@intBasicEventDestroy;
|
|
BasicEventDestroy :=@intBasicEventDestroy;
|
|
BasicEventResetEvent :=@intBasicEventResetEvent;
|
|
BasicEventResetEvent :=@intBasicEventResetEvent;
|
|
@@ -437,9 +427,7 @@ begin
|
|
end;
|
|
end;
|
|
SetThreadManager(NWThreadManager);
|
|
SetThreadManager(NWThreadManager);
|
|
InitHeapMutexes;
|
|
InitHeapMutexes;
|
|
- {$ifdef HASTHREADVAR}
|
|
|
|
ThVarAllocResourceTag := AllocateResourceTag(getnlmhandle,'Threadvar Memory',AllocSignature);
|
|
ThVarAllocResourceTag := AllocateResourceTag(getnlmhandle,'Threadvar Memory',AllocSignature);
|
|
- {$endif}
|
|
|
|
NWSysSetThreadFunctions (@SysAllocateThreadVars,
|
|
NWSysSetThreadFunctions (@SysAllocateThreadVars,
|
|
@SysReleaseThreadVars,
|
|
@SysReleaseThreadVars,
|
|
@SysSetThreadDataAreaPtr);
|
|
@SysSetThreadDataAreaPtr);
|