* win/systhrd.inc, clean up:

- removed assembler from SysRelocateThreadVars: never actually worked, and this file is shared between different CPUs - not a proper place for assembler anyway.
- Obtain handle of kernel32.dll using GetModuleHandle, allows to get rid of UnloadLibrary call.

git-svn-id: trunk@17975 -
This commit is contained in:
sergei 2011-07-11 17:18:48 +00:00
parent b0cef1693a
commit 02a5efc619

View File

@ -162,32 +162,6 @@ var
dataindex : pointer;
errorsave : dword;
begin
{$ifdef dummy}
{ it least in the on windows 7 x64, this still doesn't not work, fs:(0x2c) is
self referencing on this system (FK)
MVC: It also does not work on Windows Vista 32-bit, Home Premium, SP 1. Results in a crash}
asm
movl TLSKey,%edx
movl %fs:(0x2c),%eax
orl %eax,%eax
jnz .LAddressInEAX
{ this works on Windows 7, but I don't know if it works on other OSes (FK) }
movl %fs:(0x18),%eax
movl 0xe10(%eax,%edx,4),%eax
jmp .LToDataIndex
.LAddressInEAX:
movl (%eax,%edx,4),%eax
.LToDataIndex:
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
@ -197,7 +171,6 @@ var
InitThread($1000000);
end;
SetLastError(errorsave);
{$endif win32}
SysRelocateThreadvar:=DataIndex+Offset;
end;
@ -548,12 +521,9 @@ begin
SysInitMultithreading;
{$IFDEF SUPPORT_WIN95}
{ Try to find TryEnterCriticalSection function }
KernelHandle:=LoadLibrary(KernelDLL);
KernelHandle:=GetModuleHandle(KernelDLL);
if KernelHandle<>0 then
begin
WinTryEnterCriticalSection:=TTryEnterCriticalSection(GetProcAddress(KernelHandle,'TryEnterCriticalSection'));
FreeLibrary(KernelHandle);
end;
WinTryEnterCriticalSection:=TTryEnterCriticalSection(GetProcAddress(KernelHandle,'TryEnterCriticalSection'));
if not assigned(WinTryEnterCriticalSection) then
WinTryEnterCriticalSection:=@Win95TryEnterCriticalSection;
{$ENDIF SUPPORT_WIN95}