mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 08:46:09 +02:00
* 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:
parent
b0cef1693a
commit
02a5efc619
@ -162,32 +162,6 @@ var
|
|||||||
dataindex : pointer;
|
dataindex : pointer;
|
||||||
errorsave : dword;
|
errorsave : dword;
|
||||||
begin
|
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;
|
errorsave:=GetLastError;
|
||||||
dataindex:=TlsGetValue(tlskey);
|
dataindex:=TlsGetValue(tlskey);
|
||||||
if dataindex=nil then
|
if dataindex=nil then
|
||||||
@ -197,7 +171,6 @@ var
|
|||||||
InitThread($1000000);
|
InitThread($1000000);
|
||||||
end;
|
end;
|
||||||
SetLastError(errorsave);
|
SetLastError(errorsave);
|
||||||
{$endif win32}
|
|
||||||
SysRelocateThreadvar:=DataIndex+Offset;
|
SysRelocateThreadvar:=DataIndex+Offset;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -548,12 +521,9 @@ begin
|
|||||||
SysInitMultithreading;
|
SysInitMultithreading;
|
||||||
{$IFDEF SUPPORT_WIN95}
|
{$IFDEF SUPPORT_WIN95}
|
||||||
{ Try to find TryEnterCriticalSection function }
|
{ Try to find TryEnterCriticalSection function }
|
||||||
KernelHandle:=LoadLibrary(KernelDLL);
|
KernelHandle:=GetModuleHandle(KernelDLL);
|
||||||
if KernelHandle<>0 then
|
if KernelHandle<>0 then
|
||||||
begin
|
WinTryEnterCriticalSection:=TTryEnterCriticalSection(GetProcAddress(KernelHandle,'TryEnterCriticalSection'));
|
||||||
WinTryEnterCriticalSection:=TTryEnterCriticalSection(GetProcAddress(KernelHandle,'TryEnterCriticalSection'));
|
|
||||||
FreeLibrary(KernelHandle);
|
|
||||||
end;
|
|
||||||
if not assigned(WinTryEnterCriticalSection) then
|
if not assigned(WinTryEnterCriticalSection) then
|
||||||
WinTryEnterCriticalSection:=@Win95TryEnterCriticalSection;
|
WinTryEnterCriticalSection:=@Win95TryEnterCriticalSection;
|
||||||
{$ENDIF SUPPORT_WIN95}
|
{$ENDIF SUPPORT_WIN95}
|
||||||
|
Loading…
Reference in New Issue
Block a user