From 02a5efc619944a4951aac0db5f1929355e141b93 Mon Sep 17 00:00:00 2001 From: sergei Date: Mon, 11 Jul 2011 17:18:48 +0000 Subject: [PATCH] * 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 - --- rtl/win/systhrd.inc | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/rtl/win/systhrd.inc b/rtl/win/systhrd.inc index 51bbd3d1f4..58d6f14dfb 100644 --- a/rtl/win/systhrd.inc +++ b/rtl/win/systhrd.inc @@ -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}