Fix threadvar handling. Basically a merge of r31913 of my packages branch.

rtl/inc/system.inc:
  * provide a public alias for SetupEntryInformation so that it can be used in SysInit as well without globally exporting it
rtl/win/systlsdir.inc:
  * Exec_tls_callback: call SetupEntryInformation before initalizing the heap and multithreading so that the threadvar tables can be referenced correctly

git-svn-id: trunk@33035 -
This commit is contained in:
svenbarth 2016-01-30 23:10:35 +00:00
parent 191a293e4a
commit 1951b8aaaa
2 changed files with 17 additions and 1 deletions

View File

@ -121,7 +121,7 @@ var
{$endif FPC_HAS_INDIRECT_MAIN_INFORMATION} {$endif FPC_HAS_INDIRECT_MAIN_INFORMATION}
{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION} {$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}
procedure SetupEntryInformation(const info: TEntryInformation); procedure SetupEntryInformation(const info: TEntryInformation);[public,alias:'_FPC_SetupEntryInformation'];
begin begin
EntryInformation := info; EntryInformation := info;
FPCResStrInitTables := info.ResStrInitTables; FPCResStrInitTables := info.ResStrInitTables;

View File

@ -21,6 +21,11 @@
{ This is only useful for executables { This is only useful for executables
for DLLs, DLL_Entry gets called. PM } for DLLs, DLL_Entry gets called. PM }
{$ifdef FPC_INSSIDE_SYSINIT} {$ifdef FPC_INSSIDE_SYSINIT}
{$ifdef win32}
{$define FPC_HAS_INDIRECT_MAIN_INFORMATION}
{$endif win32}
Const Const
DLL_PROCESS_ATTACH = 1; DLL_PROCESS_ATTACH = 1;
DLL_THREAD_ATTACH = 2; DLL_THREAD_ATTACH = 2;
@ -45,6 +50,11 @@ function TlsGetValue(dwTlsIndex : DWord) : pointer; stdcall;
procedure InitSystemThreads; external name '_FPC_InitSystemThreads'; procedure InitSystemThreads; external name '_FPC_InitSystemThreads';
procedure SysAllocateThreadVars; external name '_FPC_SysAllocateThreadVars'; procedure SysAllocateThreadVars; external name '_FPC_SysAllocateThreadVars';
procedure InitHeap; external name '_FPC_InitHeap'; procedure InitHeap; external name '_FPC_InitHeap';
{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}
procedure SetupEntryInformation(const info: TEntryInformation); external name '_FPC_SetupEntryInformation';
{$endif FPC_HAS_INDIRECT_MAIN_INFORMATION}
{$endif FPC_INSSIDE_SYSINIT} {$endif FPC_INSSIDE_SYSINIT}
procedure Exec_Tls_callback(Handle : pointer; reason : Dword; Reserved : pointer); procedure Exec_Tls_callback(Handle : pointer; reason : Dword; Reserved : pointer);
@ -67,6 +77,12 @@ procedure Exec_Tls_callback(Handle : pointer; reason : Dword; Reserved : pointer
and the EntryInformation is a constant which sholud prevent troubles } and the EntryInformation is a constant which sholud prevent troubles }
DLL_PROCESS_ATTACH: DLL_PROCESS_ATTACH:
begin begin
{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}
{ since this procedure is called before SetupEntryInformation and thus
before EXE_Entry we need to setup the entry information here so that
the threadvar handling can be correctly initialized }
SetupEntryInformation(SysInitEntryInformation);
{$endif FPC_HAS_INDIRECT_MAIN_INFORMATION}
InitHeap; InitHeap;
InitSystemThreads; InitSystemThreads;
end; end;