mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-12 23:09:40 +02:00
* don't destroy LastError when resolving a threadvar on windows, resolves #10205 (?)
git-svn-id: trunk@10621 -
This commit is contained in:
parent
fce221f9b4
commit
6c5471f324
@ -826,7 +826,6 @@ destructor TThreadList.Destroy;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TThreadList.Add(Item: Pointer);
|
||||
begin
|
||||
LockList;
|
||||
@ -876,5 +875,3 @@ procedure TThreadList.UnlockList;
|
||||
begin
|
||||
System.LeaveCriticalSection(FLock);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -173,6 +173,9 @@ threadvar
|
||||
function GetLastError : DWORD;
|
||||
{$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'GetLastError';
|
||||
|
||||
procedure SetLastError(dwErrCode : DWORD);
|
||||
{$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'SetLastError';
|
||||
|
||||
{ time and date functions }
|
||||
function GetTickCount : longint;
|
||||
{$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'GetTickCount';
|
||||
|
@ -99,20 +99,41 @@ CONST
|
||||
TlsSetValue(tlskey,dataindex);
|
||||
end;
|
||||
|
||||
|
||||
function SysRelocateThreadvar(offset : dword) : pointer;
|
||||
var
|
||||
var
|
||||
dataindex : pointer;
|
||||
errorsave : dword;
|
||||
begin
|
||||
dataindex := TlsGetValue(tlskey);
|
||||
if dataindex = nil then begin
|
||||
SysAllocateThreadVars;
|
||||
dataindex := TlsGetValue(tlskey);
|
||||
{$ifdef dummy}
|
||||
{ I've no clue why this doesn't read dataindex, imo it should (FK) }
|
||||
asm
|
||||
movl TLSKey,%edx
|
||||
movl $0x2c,%eax
|
||||
movl %fs:(%eax),%eax
|
||||
movl (%eax,%edx,4),%eax
|
||||
movl %eax,dataindex
|
||||
end;
|
||||
if DataIndex=nil then
|
||||
begin
|
||||
errorsave:=GetLastError;
|
||||
SysAllocateThreadVars;
|
||||
DataIndex:=TlsGetValue(tlskey);
|
||||
SetLastError(errorsave);
|
||||
end;
|
||||
{$else win32}
|
||||
errorsave:=GetLastError;
|
||||
dataindex:=TlsGetValue(tlskey);
|
||||
if dataindex=nil then
|
||||
begin
|
||||
SysAllocateThreadVars;
|
||||
dataindex:=TlsGetValue(tlskey);
|
||||
end;
|
||||
SetLastError(errorsave);
|
||||
{$endif win32}
|
||||
SysRelocateThreadvar:=DataIndex+Offset;
|
||||
{
|
||||
begin
|
||||
SysRelocateThreadvar:=TlsGetValue(tlskey)+Offset;
|
||||
} end;
|
||||
end;
|
||||
|
||||
|
||||
procedure SysReleaseThreadVars;
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user