For all DLLs with defined DllMain and which do not require

DLL_THREAD_ATTACH/DLL_THREAD_DETACH notifications, call
DisableThreadLibraryCalls() in order to slightly improve performance
on thread creation/exiting.
This commit is contained in:
Dmitry Timoshkov 2003-06-30 20:53:48 +00:00 committed by Alexandre Julliard
parent bf7a4d7d72
commit 4e1ef0c114
38 changed files with 56 additions and 48 deletions

View File

@ -204,15 +204,11 @@ BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
if (AVIFILE_hModule == NULL)
AVIFILE_hModule = (HMODULE)hInstDll;
DisableThreadLibraryCalls(hInstDll);
AVIFILE_hModule = (HMODULE)hInstDll;
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
};
return TRUE;

View File

@ -145,6 +145,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
COMCTL32_hModule = (HMODULE)hinstDLL;
/* create private heap */

View File

@ -88,6 +88,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
if (fdwReason == DLL_PROCESS_ATTACH)
{
DWORD version = GetVersion();
DisableThreadLibraryCalls(hinstDLL);
CRTDLL__basemajor_dll = (version >> 24) & 0xFF;
CRTDLL__baseminor_dll = (version >> 16) & 0xFF;
CRTDLL__baseversion_dll = (version >> 16);

View File

@ -63,7 +63,11 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
TRACE("fdwReason=%ld\n", fdwReason);
if (fdwReason == DLL_PROCESS_ATTACH)
{
HMODULE mod = GetModuleHandleA( "x11drv.dll" );
HMODULE mod;
DisableThreadLibraryCalls(hInstDLL);
mod = GetModuleHandleA( "x11drv.dll" );
if (mod)
{
wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" );

View File

@ -579,7 +579,11 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
if (fdwReason == DLL_PROCESS_ATTACH)
{
HMODULE mod = GetModuleHandleA( "x11drv.dll" );
HMODULE mod;
DisableThreadLibraryCalls(hInstDLL);
mod = GetModuleHandleA( "x11drv.dll" );
if (mod)
{
wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" );

View File

@ -60,6 +60,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserv)
switch(reason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(inst);
DINPUT_instance = inst;
break;
case DLL_PROCESS_DETACH:

View File

@ -107,6 +107,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hinstDLL);
/* FIXME: Initialisation */
}
else if (fdwReason == DLL_PROCESS_DETACH)

View File

@ -38,6 +38,7 @@ BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
switch ( fdwReason )
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
/* First instance perform construction of global processor data */
return DPLAYX_ConstructData();
@ -45,9 +46,6 @@ BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
/* Last instance performs destruction of global processor data */
return DPLAYX_DestructData();
case DLL_THREAD_ATTACH: /* Do nothing */
case DLL_THREAD_DETACH: /* Do nothing */
break;
default:
break;

View File

@ -35,6 +35,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
if (fdwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hinstDLL);
/* FIXME: Initialisation */
}
else if (fdwReason == DLL_PROCESS_DETACH)

View File

@ -32,6 +32,7 @@
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID lpvReserved)
{
if (reason != DLL_PROCESS_ATTACH) return TRUE;
DisableThreadLibraryCalls(hinstDLL);
return GDI_Init();
}

View File

@ -40,16 +40,13 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
IMAGEHLP_hHeap = HeapCreate(0, 0x10000, 0);
break;
case DLL_PROCESS_DETACH:
HeapDestroy(IMAGEHLP_hHeap);
IMAGEHLP_hHeap = NULL;
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
default:
break;
}

View File

@ -86,6 +86,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved)
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstDLL);
hImeInst = hInstDLL;
break;
case DLL_PROCESS_DETACH:

View File

@ -44,6 +44,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstDLL);
MSACM_hHeap = HeapCreate(0, 0x10000, 0);
MSACM_hInstance32 = hInstDLL;
MSACM_RegisterAllDrivers();
@ -54,10 +55,6 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
MSACM_hHeap = NULL;
MSACM_hInstance32 = NULL;
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
default:
break;
}

View File

@ -3,6 +3,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = msisys.ocx
IMPORTS = kernel32
EXTRALIBS = $(LIBUUID)
LDDLLFLAGS = @LDDLLFLAGS@

View File

@ -62,16 +62,13 @@ BOOL WINAPI DllMain(
switch ( fdwReason )
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstDLL);
if ( !MSISYS_InitProcess() )
return FALSE;
break;
case DLL_PROCESS_DETACH:
MSISYS_UninitProcess();
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE;

View File

@ -1902,13 +1902,10 @@ BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved)
switch (dwReason) {
case DLL_PROCESS_ATTACH:
if (MSRLE32_hModule == 0)
MSRLE32_hModule = hModule;
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
DisableThreadLibraryCalls(hModule);
MSRLE32_hModule = hModule;
break;
case DLL_PROCESS_DETACH:
break;
};

View File

@ -110,6 +110,7 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
NETAPI32_hModule = hinstDLL;
break;
case DLL_PROCESS_DETACH:

View File

@ -3,6 +3,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = odbc32.dll
IMPORTS = kernel32
LDDLLFLAGS = @LDDLLFLAGS@
SYMBOLFILE = $(MODULE).tmp.o

View File

@ -176,6 +176,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
if (fdwReason == DLL_PROCESS_ATTACH)
{
TRACE("Loading ODBC...\n");
DisableThreadLibraryCalls(hinstDLL);
if (ODBC_LoadDriverManager())
ODBC_LoadDMFunctions();
}

View File

@ -97,6 +97,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
switch(fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
OLE32_hInstance = hinstDLL;
COMPOBJ_InitProcess();
if (TRACE_ON(ole)) CoRegisterMallocSpy((LPVOID)-1);

View File

@ -683,6 +683,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
switch(reason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinst);
return process_attach();
case DLL_PROCESS_DETACH:
process_detach();

View File

@ -34,6 +34,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{
switch(fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstDLL);
break;
case DLL_PROCESS_DETACH:
break;

View File

@ -71,6 +71,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
/* create private heap */
RICHED32_hHeap = HeapCreate (0, 0x10000, 0);
/* register the Rich Edit class */

View File

@ -167,6 +167,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
master_mutex = CreateMutexA( NULL, FALSE, RPCSS_MASTER_MUTEX_NAME);
if (!master_mutex)
ERR("Failed to create master mutex\n");

View File

@ -65,6 +65,7 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
SERIALUI_hModule = hinstDLL;
break;
case DLL_PROCESS_DETACH:

View File

@ -65,6 +65,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
shlwapi_hInstance = hinstDLL;
SHLWAPI_ThreadRef_index = TlsAlloc();
break;

View File

@ -3,6 +3,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = snmpapi.dll
IMPORTS = kernel32
LDDLLFLAGS = @LDDLLFLAGS@
SYMBOLFILE = $(MODULE).tmp.o

View File

@ -20,8 +20,7 @@
#include "config.h"
#include "windef.h"
#include "winbase.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(snmpapi);
@ -38,13 +37,10 @@ BOOL WINAPI DllMain(
switch(fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstDLL);
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE;

View File

@ -76,6 +76,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
switch(reason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinst);
process_attach();
break;

View File

@ -33,15 +33,10 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
DSM_currentState = 2;
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
DSM_currentState = 1;
break;

View File

@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wtypes.h"
@ -39,6 +39,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
switch(fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
URLMON_hInstance = hinstDLL;
break;

View File

@ -62,14 +62,12 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstDLL);
SCSI_Init();
break;
case DLL_PROCESS_DETACH:
DeleteCriticalSection( &ASPI_CritSection );
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
}
#endif /* defined(linux) */
return TRUE;

View File

@ -688,6 +688,7 @@ BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
if (fdwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hinstDLL);
DOSVM_InitSegments();
event_notifier = CreateEventA(NULL, FALSE, FALSE, NULL);

View File

@ -121,6 +121,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
switch(reason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinst);
PSDRV_Heap = HeapCreate(0, 0x10000, 0);
if (PSDRV_Heap == NULL)

View File

@ -122,6 +122,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
{
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstDLL);
MCIAVI_hInstance = hInstDLL;
break;
}

View File

@ -125,6 +125,8 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstDLL);
if (!WINMM_CreateIData(hInstDLL))
return FALSE;
if (!MCI_Init() || !MMDRV_Init()) {
@ -141,9 +143,6 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
WINMM_DeleteIData();
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}

View File

@ -444,6 +444,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
TRACE("%p 0x%lx %p\n", hInstDLL, fdwReason, fImpLoad);
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstDLL);
opentype_tls_index = TlsAlloc();
break;
case DLL_PROCESS_DETACH:

View File

@ -41,6 +41,8 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD reason, LPVOID lpReserved)
{
case DLL_PROCESS_ATTACH: {
extern void WINSPOOL_LoadSystemPrinters();
DisableThreadLibraryCalls(hInstance);
WINSPOOL_LoadSystemPrinters();
break;
}