diff --git a/dlls/dinput/keyboard/main.c b/dlls/dinput/keyboard/main.c index fede58cdbcf..71a5630d0cd 100644 --- a/dlls/dinput/keyboard/main.c +++ b/dlls/dinput/keyboard/main.c @@ -72,7 +72,15 @@ but 'DI_LOSTFOCUS' and 'DI_UNACQUIRED' exist for a reason. static BYTE DInputKeyState[256]; /* array for 'GetDeviceState' */ -static CRITICAL_SECTION keyboard_crit = CRITICAL_SECTION_INIT("dinput_keyboard"); +static CRITICAL_SECTION keyboard_crit; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &keyboard_crit, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": keyboard_crit") } +}; +static CRITICAL_SECTION keyboard_crit = { &critsect_debug, -1, 0, 0, 0, 0 }; + static DWORD keyboard_users; static HHOOK keyboard_hook; diff --git a/dlls/gdi/driver.c b/dlls/gdi/driver.c index f5c9ef44ef8..6b20e21ffe2 100644 --- a/dlls/gdi/driver.c +++ b/dlls/gdi/driver.c @@ -42,7 +42,15 @@ struct graphics_driver static struct graphics_driver *first_driver; static struct graphics_driver *display_driver; -static CRITICAL_SECTION driver_section = CRITICAL_SECTION_INIT( "driver_section" ); + +static CRITICAL_SECTION driver_section; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &driver_section, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": driver_section") } +}; +static CRITICAL_SECTION driver_section = { &critsect_debug, -1, 0, 0, 0, 0 }; /********************************************************************** * create_driver diff --git a/dlls/kernel/console.c b/dlls/kernel/console.c index ac3c917957d..730083716f2 100644 --- a/dlls/kernel/console.c +++ b/dlls/kernel/console.c @@ -1274,7 +1274,15 @@ struct ConsoleHandler { static unsigned int CONSOLE_IgnoreCtrlC = 0; /* FIXME: this should be inherited somehow */ static struct ConsoleHandler CONSOLE_DefaultConsoleHandler = {CONSOLE_DefaultHandler, NULL}; static struct ConsoleHandler* CONSOLE_Handlers = &CONSOLE_DefaultConsoleHandler; -static CRITICAL_SECTION CONSOLE_CritSect = CRITICAL_SECTION_INIT("console_ctrl_section"); + +static CRITICAL_SECTION CONSOLE_CritSect; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &CONSOLE_CritSect, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": CONSOLE_CritSect") } +}; +static CRITICAL_SECTION CONSOLE_CritSect = { &critsect_debug, -1, 0, 0, 0, 0 }; /*****************************************************************************/ diff --git a/dlls/kernel/kernel_main.c b/dlls/kernel/kernel_main.c index ab5974bcb44..0163ece960e 100644 --- a/dlls/kernel/kernel_main.c +++ b/dlls/kernel/kernel_main.c @@ -53,7 +53,14 @@ extern void ENV_CopyStartupInformation(void); extern int main_create_flags; -static CRITICAL_SECTION ldt_section = CRITICAL_SECTION_INIT("ldt_section"); +static CRITICAL_SECTION ldt_section; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &ldt_section, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": ldt_section") } +}; +static CRITICAL_SECTION ldt_section = { &critsect_debug, -1, 0, 0, 0, 0 }; /*********************************************************************** * locking for LDT routines diff --git a/dlls/ntdll/critsection.c b/dlls/ntdll/critsection.c index d0988c7ca70..17bc6ceab3a 100644 --- a/dlls/ntdll/critsection.c +++ b/dlls/ntdll/critsection.c @@ -27,6 +27,7 @@ #include "winerror.h" #include "winternl.h" #include "wine/debug.h" +#include "ntdll_misc.h" WINE_DEFAULT_DEBUG_CHANNEL(ntdll); WINE_DECLARE_DEBUG_CHANNEL(relay); @@ -73,7 +74,19 @@ static inline HANDLE get_semaphore( RTL_CRITICAL_SECTION *crit ) */ NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit ) { - crit->DebugInfo = NULL; + crit->DebugInfo = RtlAllocateHeap(ntdll_get_process_heap(), 0, sizeof(CRITICAL_SECTION_DEBUG)); + if (crit->DebugInfo) + { + crit->DebugInfo->Type = 0; + crit->DebugInfo->CreatorBackTraceIndex = 0; + crit->DebugInfo->CriticalSection = crit; + crit->DebugInfo->ProcessLocksList.Blink = &(crit->DebugInfo->ProcessLocksList); + crit->DebugInfo->ProcessLocksList.Flink = &(crit->DebugInfo->ProcessLocksList); + crit->DebugInfo->EntryCount = 0; + crit->DebugInfo->ContentionCount = 0; + crit->DebugInfo->Spare[0] = 0; + crit->DebugInfo->Spare[1] = 0; + } crit->LockCount = -1; crit->RecursionCount = 0; crit->OwningThread = 0; @@ -125,6 +138,16 @@ NTSTATUS WINAPI RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit ) crit->OwningThread = 0; if (crit->LockSemaphore) NtClose( crit->LockSemaphore ); crit->LockSemaphore = 0; + if (crit->DebugInfo) + { + /* only free the ones we made in here */ + if (!crit->DebugInfo->Spare[1]) + { + + RtlFreeHeap( ntdll_get_process_heap(), 0, crit->DebugInfo ); + crit->DebugInfo = NULL; + } + } return STATUS_SUCCESS; } @@ -153,7 +176,8 @@ NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit ) status = NtWaitForSingleObject( sem, FALSE, &time ); if ( status == WAIT_TIMEOUT ) { - const char *name = (char *)crit->DebugInfo; + const char *name = NULL; + if (crit->DebugInfo) name = (char *)crit->DebugInfo->Spare[1]; if (!name) name = "?"; ERR( "section %p %s wait timed out in thread %04lx, blocked by %04lx, retrying (60 sec)\n", crit, debugstr_a(name), GetCurrentThreadId(), (DWORD)crit->OwningThread ); @@ -170,7 +194,7 @@ NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit ) if (status == STATUS_WAIT_0) return STATUS_SUCCESS; /* Throw exception only for Wine internal locks */ - if (!crit->DebugInfo) continue; + if ((!crit->DebugInfo) || (!crit->DebugInfo->Spare[1])) continue; rec.ExceptionCode = STATUS_POSSIBLE_DEADLOCK; rec.ExceptionFlags = 0; diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index e48f715a571..08f92e7e919 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -64,7 +64,15 @@ static UINT tls_module_count; /* number of modules with TLS directory */ static UINT tls_total_size; /* total size of TLS storage */ static const IMAGE_TLS_DIRECTORY **tls_dirs; /* array of TLS directories */ -static CRITICAL_SECTION loader_section = CRITICAL_SECTION_INIT( "loader_section" ); +static CRITICAL_SECTION loader_section; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &loader_section, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": loader_section") } +}; +static CRITICAL_SECTION loader_section = { &critsect_debug, -1, 0, 0, 0, 0 }; + static WINE_MODREF *cached_modref; static WINE_MODREF *current_modref; diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c index 76eb823147b..37b4d1a08a5 100644 --- a/dlls/ntdll/rtl.c +++ b/dlls/ntdll/rtl.c @@ -39,8 +39,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(ntdll); - -static RTL_CRITICAL_SECTION peb_lock = CRITICAL_SECTION_INIT("peb_lock"); +static CRITICAL_SECTION peb_lock; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &peb_lock, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": peb_lock") } +}; +static CRITICAL_SECTION peb_lock = { &critsect_debug, -1, 0, 0, 0, 0 }; /* CRC polynomial 0xedb88320 */ static const DWORD CRC_table[256] = diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index a656ae69cba..25c82d2fa11 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -95,7 +95,15 @@ static const BYTE VIRTUAL_Win32Flags[16] = static FILE_VIEW *VIRTUAL_FirstView; -static CRITICAL_SECTION csVirtual = CRITICAL_SECTION_INIT("csVirtual"); + +static CRITICAL_SECTION csVirtual; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &csVirtual, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": csVirtual") } +}; +static CRITICAL_SECTION csVirtual = { &critsect_debug, -1, 0, 0, 0, 0 }; #ifdef __i386__ /* These are always the same on an i386, and it will be faster this way */ diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 9f197aa6fe0..7614e5e4a02 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -62,10 +62,16 @@ static void COM_ExternalLockFreeList(); const CLSID CLSID_StdGlobalInterfaceTable = { 0x00000323, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46} }; - - APARTMENT MTA, *apts; -static CRITICAL_SECTION csApartment = CRITICAL_SECTION_INIT("csApartment"); + +static CRITICAL_SECTION csApartment; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &csApartment, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": csApartment") } +}; +static CRITICAL_SECTION csApartment = { &critsect_debug, -1, 0, 0, 0, 0 }; /* * This lock count counts the number of times CoInitialize is called. It is @@ -93,9 +99,17 @@ typedef struct tagRegisteredClass struct tagRegisteredClass* nextClass; } RegisteredClass; -static CRITICAL_SECTION csRegisteredClassList = CRITICAL_SECTION_INIT("csRegisteredClassList"); static RegisteredClass* firstRegisteredClass = NULL; +static CRITICAL_SECTION csRegisteredClassList; +static CRITICAL_SECTION_DEBUG class_cs_debug = +{ + 0, 0, &csRegisteredClassList, + { &class_cs_debug.ProcessLocksList, &class_cs_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": csRegisteredClassList") } +}; +static CRITICAL_SECTION csRegisteredClassList = { &class_cs_debug, -1, 0, 0, 0, 0 }; + /***************************************************************************** * This section contains OpenDllList definitions * @@ -112,9 +126,17 @@ typedef struct tagOpenDll { struct tagOpenDll *next; } OpenDll; -static CRITICAL_SECTION csOpenDllList = CRITICAL_SECTION_INIT("csOpenDllList"); static OpenDll *openDllList = NULL; /* linked list of open dlls */ +static CRITICAL_SECTION csOpenDllList; +static CRITICAL_SECTION_DEBUG dll_cs_debug = +{ + 0, 0, &csOpenDllList, + { &dll_cs_debug.ProcessLocksList, &dll_cs_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": csOpenDllList") } +}; +static CRITICAL_SECTION csOpenDllList = { &dll_cs_debug, -1, 0, 0, 0, 0 }; + static const char aptWinClass[] = "WINE_OLE32_APT_CLASS"; static LRESULT CALLBACK COM_AptWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); diff --git a/dlls/ole32/ifs.c b/dlls/ole32/ifs.c index 15dfe3a3fdd..42c18316578 100644 --- a/dlls/ole32/ifs.c +++ b/dlls/ole32/ifs.c @@ -59,7 +59,14 @@ typedef struct { _Malloc32 Malloc32 = {&VT_IMalloc32, 0, NULL, 0, 0, NULL, 0}; /* with a spy active all calls from pre to post methods are threadsave */ -static CRITICAL_SECTION IMalloc32_SpyCS = CRITICAL_SECTION_INIT("IMalloc32_SpyCS"); +static CRITICAL_SECTION IMalloc32_SpyCS; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &IMalloc32_SpyCS, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": IMalloc32_SpyCS") } +}; +static CRITICAL_SECTION IMalloc32_SpyCS = { &critsect_debug, -1, 0, 0, 0, 0 }; /* resize the old table */ static int SetSpyedBlockTableLength ( int NewLength ) diff --git a/dlls/rpcrt4/rpc_binding.c b/dlls/rpcrt4/rpc_binding.c index 868cd05ee2b..4e473eb5996 100644 --- a/dlls/rpcrt4/rpc_binding.c +++ b/dlls/rpcrt4/rpc_binding.c @@ -41,7 +41,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); static RpcConnection* conn_cache; -static CRITICAL_SECTION conn_cache_cs = CRITICAL_SECTION_INIT("conn_cache_cs"); + +static CRITICAL_SECTION conn_cache_cs; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &conn_cache_cs, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": conn_cache_cs") } +}; +static CRITICAL_SECTION conn_cache_cs = { &critsect_debug, -1, 0, 0, 0, 0 }; LPSTR RPCRT4_strndupA(LPSTR src, INT slen) { diff --git a/dlls/rpcrt4/rpc_server.c b/dlls/rpcrt4/rpc_server.c index 95955a03a07..c27053dfc5f 100644 --- a/dlls/rpcrt4/rpc_server.c +++ b/dlls/rpcrt4/rpc_server.c @@ -55,13 +55,37 @@ typedef struct _RpcPacket static RpcServerProtseq* protseqs; static RpcServerInterface* ifs; -static CRITICAL_SECTION server_cs = CRITICAL_SECTION_INIT("RpcServer"); -static CRITICAL_SECTION listen_cs = CRITICAL_SECTION_INIT("RpcListen"); +static CRITICAL_SECTION server_cs; +static CRITICAL_SECTION_DEBUG server_cs_debug = +{ + 0, 0, &server_cs, + { &server_cs_debug.ProcessLocksList, &server_cs_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": server_cs") } +}; +static CRITICAL_SECTION server_cs = { &server_cs_debug, -1, 0, 0, 0, 0 }; + +static CRITICAL_SECTION listen_cs; +static CRITICAL_SECTION_DEBUG listen_cs_debug = +{ + 0, 0, &listen_cs, + { &listen_cs_debug.ProcessLocksList, &listen_cs_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": listen_cs") } +}; +static CRITICAL_SECTION listen_cs = { &listen_cs_debug, -1, 0, 0, 0, 0 }; + static BOOL std_listen; static LONG listen_count = -1; static HANDLE mgr_event, server_thread; -static CRITICAL_SECTION spacket_cs = CRITICAL_SECTION_INIT("RpcServerPacket"); +static CRITICAL_SECTION spacket_cs; +static CRITICAL_SECTION_DEBUG spacket_cs_debug = +{ + 0, 0, &spacket_cs, + { &spacket_cs_debug.ProcessLocksList, &spacket_cs_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": spacket_cs") } +}; +static CRITICAL_SECTION spacket_cs = { &spacket_cs_debug, -1, 0, 0, 0, 0 }; + static RpcPacket* spacket_head; static RpcPacket* spacket_tail; static HANDLE server_sem; diff --git a/dlls/shell32/changenotify.c b/dlls/shell32/changenotify.c index 29292bbeb73..dbb7264b4cc 100644 --- a/dlls/shell32/changenotify.c +++ b/dlls/shell32/changenotify.c @@ -27,7 +27,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); -static CRITICAL_SECTION SHELL32_ChangenotifyCS = CRITICAL_SECTION_INIT("SHELL32_ChangenotifyCS"); +static CRITICAL_SECTION SHELL32_ChangenotifyCS; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &SHELL32_ChangenotifyCS, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": SHELL32_ChangenotifyCS") } +}; +static CRITICAL_SECTION SHELL32_ChangenotifyCS = { &critsect_debug, -1, 0, 0, 0, 0 }; /* internal list of notification clients (internal) */ typedef struct _NOTIFICATIONLIST diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c index 82206613555..e73b4f3add3 100644 --- a/dlls/shell32/iconcache.c +++ b/dlls/shell32/iconcache.c @@ -58,7 +58,15 @@ typedef struct } SIC_ENTRY, * LPSIC_ENTRY; static HDPA sic_hdpa = 0; -static CRITICAL_SECTION SHELL32_SicCS = CRITICAL_SECTION_INIT("SHELL32_SicCS"); + +static CRITICAL_SECTION SHELL32_SicCS; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &SHELL32_SicCS, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": SHELL32_SicCS") } +}; +static CRITICAL_SECTION SHELL32_SicCS = { &critsect_debug, -1, 0, 0, 0, 0 }; /***************************************************************************** * SIC_CompareEntries diff --git a/dlls/user/dde/misc.c b/dlls/user/dde/misc.c index 51e24bf513c..83689eca64a 100644 --- a/dlls/user/dde/misc.c +++ b/dlls/user/dde/misc.c @@ -49,7 +49,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddeml); static WDML_INSTANCE* WDML_InstanceList = NULL; static DWORD WDML_MaxInstanceID = 0; /* OK for present, have to worry about wrap-around later */ const char WDML_szEventClass[] = "DdeEventClass"; -CRITICAL_SECTION WDML_CritSect = CRITICAL_SECTION_INIT("WDML_CritSect"); + +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &WDML_CritSect, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": WDML_CritSect") } +}; +CRITICAL_SECTION WDML_CritSect = { &critsect_debug, -1, 0, 0, 0, 0 }; /* ================================================================ * diff --git a/dlls/user/message.c b/dlls/user/message.c index ff32ec29f17..be0e90a2405 100644 --- a/dlls/user/message.c +++ b/dlls/user/message.c @@ -1127,7 +1127,15 @@ struct DDE_pair { static struct DDE_pair* dde_pairs; static int dde_num_alloc; static int dde_num_used; -static CRITICAL_SECTION dde_crst = CRITICAL_SECTION_INIT("Raw_DDE_CritSect"); + +static CRITICAL_SECTION dde_crst; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &dde_crst, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": dde_crst") } +}; +static CRITICAL_SECTION dde_crst = { &critsect_debug, -1, 0, 0, 0, 0 }; static BOOL dde_add_pair(HGLOBAL chm, HGLOBAL shm) { diff --git a/dlls/winaspi/winaspi32.c b/dlls/winaspi/winaspi32.c index bc9095e2107..c6c9d80f11d 100644 --- a/dlls/winaspi/winaspi32.c +++ b/dlls/winaspi/winaspi32.c @@ -51,7 +51,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(aspi); #ifdef linux static ASPI_DEVICE_INFO *ASPI_open_devices = NULL; -static CRITICAL_SECTION ASPI_CritSection = CRITICAL_SECTION_INIT("ASPI_CritSection"); + +static CRITICAL_SECTION ASPI_CritSection; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &ASPI_CritSection, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": ASPI_CritSection") } +}; +static CRITICAL_SECTION ASPI_CritSection = { &critsect_debug, -1, 0, 0, 0, 0 }; #endif /* defined(linux) */ diff --git a/dlls/winedos/dosvm.c b/dlls/winedos/dosvm.c index 064c4f704a0..0ca05650b5f 100644 --- a/dlls/winedos/dosvm.c +++ b/dlls/winedos/dosvm.c @@ -76,10 +76,18 @@ typedef struct _DOSEVENT { struct _DOSEVENT *next; } DOSEVENT, *LPDOSEVENT; -static CRITICAL_SECTION qcrit = CRITICAL_SECTION_INIT("DOSVM"); static struct _DOSEVENT *pending_event, *current_event; static HANDLE event_notifier; +static CRITICAL_SECTION qcrit; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &qcrit, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": qcrit") } +}; +static CRITICAL_SECTION qcrit = { &critsect_debug, -1, 0, 0, 0, 0 }; + /*********************************************************************** * DOSVM_HasPendingEvents diff --git a/dlls/winedos/vga.c b/dlls/winedos/vga.c index e29a506544c..5cc7dbf5870 100644 --- a/dlls/winedos/vga.c +++ b/dlls/winedos/vga.c @@ -131,7 +131,14 @@ static BOOL vga_address_3c0 = TRUE; * tries to modify VGA state. This is not how real VGA adapters work, * but it makes timing and correctness issues much easier to deal with. */ -static CRITICAL_SECTION vga_lock = CRITICAL_SECTION_INIT("VGA"); +static CRITICAL_SECTION vga_lock; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &vga_lock, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": vga_lock") } +}; +static CRITICAL_SECTION vga_lock = { &critsect_debug, -1, 0, 0, 0, 0 }; typedef HRESULT (WINAPI *DirectDrawCreateProc)(LPGUID,LPDIRECTDRAW *,LPUNKNOWN); static DirectDrawCreateProc pDirectDrawCreate; diff --git a/dlls/winsock/async.c b/dlls/winsock/async.c index bc370c1a7a5..2271e234c19 100644 --- a/dlls/winsock/async.c +++ b/dlls/winsock/async.c @@ -112,7 +112,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(winsock); /* critical section to protect some non-rentrant net function */ -CRITICAL_SECTION csWSgetXXXbyYYY = CRITICAL_SECTION_INIT("csWSgetXXXbyYYY"); +CRITICAL_SECTION csWSgetXXXbyYYY; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &csWSgetXXXbyYYY, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": csWSgetXXXbyYYY") } +}; +CRITICAL_SECTION csWSgetXXXbyYYY = { &critsect_debug, -1, 0, 0, 0, 0 }; /* protoptypes of some functions in socket.c */ diff --git a/dlls/x11drv/x11drv_main.c b/dlls/x11drv/x11drv_main.c index f727713f6c0..117e983d18e 100644 --- a/dlls/x11drv/x11drv_main.c +++ b/dlls/x11drv/x11drv_main.c @@ -52,7 +52,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(x11drv); -static CRITICAL_SECTION X11DRV_CritSection = CRITICAL_SECTION_INIT("X11DRV_CritSection"); +static CRITICAL_SECTION X11DRV_CritSection; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &X11DRV_CritSection, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": X11DRV_CritSection") } +}; +static CRITICAL_SECTION X11DRV_CritSection = { &critsect_debug, -1, 0, 0, 0, 0 }; Screen *screen; Visual *visual; diff --git a/dlls/x11drv/xrender.c b/dlls/x11drv/xrender.c index 94a4006cc94..781edc7c1d3 100644 --- a/dlls/x11drv/xrender.c +++ b/dlls/x11drv/xrender.c @@ -120,7 +120,14 @@ MAKE_FUNCPTR(XRenderSetPictureClipRectangles) MAKE_FUNCPTR(XRenderQueryExtension) #undef MAKE_FUNCPTR -static CRITICAL_SECTION xrender_cs = CRITICAL_SECTION_INIT("xrender_cs"); +static CRITICAL_SECTION xrender_cs; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &xrender_cs, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": xrender_cs") } +}; +static CRITICAL_SECTION xrender_cs = { &critsect_debug, -1, 0, 0, 0, 0 }; /*********************************************************************** diff --git a/files/profile.c b/files/profile.c index 77eca2c0085..8d7f6e1d120 100644 --- a/files/profile.c +++ b/files/profile.c @@ -90,7 +90,14 @@ static PROFILE *MRUProfile[N_CACHED_PROFILES]={NULL}; static const WCHAR emptystringW[] = {0}; static const WCHAR wininiW[] = { 'w','i','n','.','i','n','i',0 }; -static CRITICAL_SECTION PROFILE_CritSect = CRITICAL_SECTION_INIT("PROFILE_CritSect"); +static CRITICAL_SECTION PROFILE_CritSect; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &PROFILE_CritSect, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": PROFILE_CritSect") } +}; +static CRITICAL_SECTION PROFILE_CritSect = { &critsect_debug, -1, 0, 0, 0, 0 }; static const char hex[16] = "0123456789ABCDEF"; diff --git a/graphics/x11drv/xfont.c b/graphics/x11drv/xfont.c index 5392216daaa..ecade9f24ff 100644 --- a/graphics/x11drv/xfont.c +++ b/graphics/x11drv/xfont.c @@ -322,7 +322,14 @@ static const struct CharsetBindingInfo charsetbindings[] = static int DefResolution = 0; -static CRITICAL_SECTION crtsc_fonts_X11 = CRITICAL_SECTION_INIT("crtsc_fonts_X11"); +static CRITICAL_SECTION crtsc_fonts_X11; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &crtsc_fonts_X11, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": crtsc_fonts_X11") } +}; +static CRITICAL_SECTION crtsc_fonts_X11 = { &critsect_debug, -1, 0, 0, 0, 0 }; static fontResource* fontList = NULL; static fontObject* fontCache = NULL; /* array */ diff --git a/include/winbase.h b/include/winbase.h index 7298ff6fc15..f0dacd3032d 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -839,10 +839,6 @@ typedef DWORD (CALLBACK *LPPROGRESS_ROUTINE)(LARGE_INTEGER, LARGE_INTEGER, LARGE #define FORMAT_MESSAGE_ARGUMENT_ARRAY 0x00002000 #define FORMAT_MESSAGE_MAX_WIDTH_MASK 0x000000FF -#ifdef __WINESRC__ -#define CRITICAL_SECTION_INIT(name) { (void *)(__FILE__ ": " name), -1, 0, 0, 0, 0 } -#endif - typedef struct { DWORD dwOSVersionInfoSize; DWORD dwMajorVersion; diff --git a/objects/gdiobj.c b/objects/gdiobj.c index 28ecdfd7746..f7bbe8079df 100644 --- a/objects/gdiobj.c +++ b/objects/gdiobj.c @@ -66,7 +66,15 @@ static const LOGPEN NullPen = { PS_NULL, { 0, 0 }, 0 }; static HGDIOBJ stock_objects[NB_STOCK_OBJECTS]; -static SYSLEVEL GDI_level = { CRITICAL_SECTION_INIT("GDI_level"), 3 }; +static SYSLEVEL GDI_level; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &GDI_level.crst, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": GDI_level") } +}; +static SYSLEVEL GDI_level = { { &critsect_debug, -1, 0, 0, 0, 0 }, 3 }; + static WORD GDI_HeapSel; inline static BOOL get_bool(char *buffer) diff --git a/scheduler/pthread.c b/scheduler/pthread.c index c89a48f1dc6..5a08e26746f 100644 --- a/scheduler/pthread.c +++ b/scheduler/pthread.c @@ -325,7 +325,15 @@ strong_alias(__pthread_kill_other_threads_np, pthread_kill_other_threads_np); #define MAX_ATFORK 8 /* libc doesn't need that many anyway */ -static CRITICAL_SECTION atfork_section = CRITICAL_SECTION_INIT("atfork_section"); +static CRITICAL_SECTION atfork_section; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &atfork_section, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": atfork_section") } +}; +static CRITICAL_SECTION atfork_section = { &critsect_debug, -1, 0, 0, 0, 0 }; + typedef void (*atfork_handler)(); static atfork_handler atfork_prepare[MAX_ATFORK]; static atfork_handler atfork_parent[MAX_ATFORK]; diff --git a/scheduler/syslevel.c b/scheduler/syslevel.c index 76e9d6349b6..ca23f71326c 100644 --- a/scheduler/syslevel.c +++ b/scheduler/syslevel.c @@ -32,7 +32,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(win32); -static SYSLEVEL Win16Mutex = { CRITICAL_SECTION_INIT("Win16Mutex"), 1 }; +static SYSLEVEL Win16Mutex; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &Win16Mutex.crst, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": Win16Mutex") } +}; +static SYSLEVEL Win16Mutex = { { &critsect_debug, -1, 0, 0, 0, 0 }, 1 }; /* Global variable to save current TEB while in 16-bit code */ WORD SYSLEVEL_Win16CurrentTeb = 0; diff --git a/windows/cursoricon.c b/windows/cursoricon.c index a43de9f891c..261a247b583 100644 --- a/windows/cursoricon.c +++ b/windows/cursoricon.c @@ -93,7 +93,16 @@ typedef struct tagICONCACHE } ICONCACHE; static ICONCACHE *IconAnchor = NULL; -static CRITICAL_SECTION IconCrst = CRITICAL_SECTION_INIT("IconCrst"); + +static CRITICAL_SECTION IconCrst; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &IconCrst, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": IconCrst") } +}; +static CRITICAL_SECTION IconCrst = { &critsect_debug, -1, 0, 0, 0, 0 }; + static WORD ICON_HOTSPOT = 0x4242; diff --git a/windows/timer.c b/windows/timer.c index 234ed292a2e..ede31342bca 100644 --- a/windows/timer.c +++ b/windows/timer.c @@ -50,7 +50,14 @@ typedef struct tagTIMER static TIMER TimersArray[NB_TIMERS]; -static CRITICAL_SECTION csTimer = CRITICAL_SECTION_INIT("csTimer"); +static CRITICAL_SECTION csTimer; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &csTimer, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": csTimer") } +}; +static CRITICAL_SECTION csTimer = { &critsect_debug, -1, 0, 0, 0, 0 }; /*********************************************************************** diff --git a/windows/user.c b/windows/user.c index 194233e58ae..d108aa4152b 100644 --- a/windows/user.c +++ b/windows/user.c @@ -42,8 +42,14 @@ WINE_DECLARE_DEBUG_CHANNEL(system); WINE_DECLARE_DEBUG_CHANNEL(win); WINE_DECLARE_DEBUG_CHANNEL(win32); -SYSLEVEL USER_SysLevel = { CRITICAL_SECTION_INIT("USER_SysLevel"), 2 }; - +static SYSLEVEL USER_SysLevel; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &USER_SysLevel.crst, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": USER_SysLevel") } +}; +static SYSLEVEL USER_SysLevel = { { &critsect_debug, -1, 0, 0, 0, 0 }, 2 }; /* USER signal proc flags and codes */ /* See UserSignalProc for comments */ @@ -151,6 +157,36 @@ void USER_CheckNotLock(void) } +/*********************************************************************** + * WIN_SuspendWndsLock + * + * Suspend the lock on WND structures. + * Returns the number of locks suspended + * FIXME: should be removed + */ +int WIN_SuspendWndsLock( void ) +{ + int isuspendedLocks = _ConfirmSysLevel( &USER_SysLevel ); + int count = isuspendedLocks; + + while ( count-- > 0 ) + _LeaveSysLevel( &USER_SysLevel ); + + return isuspendedLocks; +} + +/*********************************************************************** + * WIN_RestoreWndsLock + * + * Restore the suspended locks on WND structures + * FIXME: should be removed + */ +void WIN_RestoreWndsLock( int ipreviousLocks ) +{ + while ( ipreviousLocks-- > 0 ) + _EnterSysLevel( &USER_SysLevel ); +} + /*********************************************************************** * FinalUserInit (USER.400) */ diff --git a/windows/win.c b/windows/win.c index 704d8e2423d..6abf4a9923d 100644 --- a/windows/win.c +++ b/windows/win.c @@ -56,37 +56,6 @@ static WORD wDragHeight= 3; static void *user_handles[NB_USER_HANDLES]; -/* thread safeness */ -extern SYSLEVEL USER_SysLevel; /* FIXME */ - -/*********************************************************************** - * WIN_SuspendWndsLock - * - * Suspend the lock on WND structures. - * Returns the number of locks suspended - */ -int WIN_SuspendWndsLock( void ) -{ - int isuspendedLocks = _ConfirmSysLevel( &USER_SysLevel ); - int count = isuspendedLocks; - - while ( count-- > 0 ) - _LeaveSysLevel( &USER_SysLevel ); - - return isuspendedLocks; -} - -/*********************************************************************** - * WIN_RestoreWndsLock - * - * Restore the suspended locks on WND structures - */ -void WIN_RestoreWndsLock( int ipreviousLocks ) -{ - while ( ipreviousLocks-- > 0 ) - _EnterSysLevel( &USER_SysLevel ); -} - /*********************************************************************** * create_window_handle * diff --git a/windows/winproc.c b/windows/winproc.c index 87bb690a369..b446b559b50 100644 --- a/windows/winproc.c +++ b/windows/winproc.c @@ -114,7 +114,15 @@ static LRESULT WINAPI WINPROC_CallProc32WTo16( WNDPROC16 func, HWND hwnd, static WINDOWPROC winproc_array[MAX_WINPROCS]; static WINDOWPROC *winproc_first_free; static UINT winproc_used; -static CRITICAL_SECTION winproc_cs = CRITICAL_SECTION_INIT("winproc_cs"); + +static CRITICAL_SECTION winproc_cs; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &winproc_cs, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { 0, (DWORD)(__FILE__ ": winproc_cs") } +}; +static CRITICAL_SECTION winproc_cs = { &critsect_debug, -1, 0, 0, 0, 0 }; /* allocate a window procedure from the global array */ static WINDOWPROC *alloc_winproc(void)