From 6837b9c119f46415a31cebed0c32228310272690 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 16 Aug 2001 18:14:22 +0000 Subject: [PATCH] Moved user lock to user.c. Added USER_CheckNotLock function. --- include/user.h | 5 +++++ include/win.h | 2 -- windows/dce.c | 24 ++++++++++++------------ windows/user.c | 33 +++++++++++++++++++++++++++++++++ windows/win.c | 36 ++++++++---------------------------- 5 files changed, 58 insertions(+), 42 deletions(-) diff --git a/include/user.h b/include/user.h index ae6fca3148d..71a26ac6a7d 100644 --- a/include/user.h +++ b/include/user.h @@ -93,6 +93,11 @@ extern USER_DRIVER USER_Driver; WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID, DWORD dwFlags, HMODULE16 hModule ); +/* user lock */ +extern void USER_Lock(void); +extern void USER_Unlock(void); +extern void USER_CheckNotLock(void); + VOID WINAPI MOUSE_Enable(LPMOUSE_EVENT_PROC lpMouseEventProc); VOID WINAPI MOUSE_Disable(VOID); diff --git a/include/win.h b/include/win.h index c5a2616c445..bc11e39114c 100644 --- a/include/win.h +++ b/include/win.h @@ -84,8 +84,6 @@ typedef struct #define BWA_SKIPICONIC 0x0008 /* Window functions */ -extern void WIN_LockWnds( void ); -extern void WIN_UnlockWnds( void ); extern int WIN_SuspendWndsLock( void ); extern void WIN_RestoreWndsLock(int ipreviousLock); extern WND* WIN_FindWndPtr( HWND hwnd ); diff --git a/windows/dce.c b/windows/dce.c index fc11d3c4cf0..b7bb0243c94 100644 --- a/windows/dce.c +++ b/windows/dce.c @@ -45,7 +45,7 @@ static void DCE_DumpCache(void) { DCE *dce; - WIN_LockWnds(); + USER_Lock(); dce = firstDCE; DPRINTF("DCE:\n"); @@ -58,7 +58,7 @@ static void DCE_DumpCache(void) dce = dce->next; } - WIN_UnlockWnds(); + USER_Unlock(); } /*********************************************************************** @@ -119,7 +119,7 @@ DCE* DCE_FreeDCE( DCE *dce ) if (!dce) return NULL; - WIN_LockWnds(); + USER_Lock(); ppDCE = &firstDCE; @@ -133,7 +133,7 @@ DCE* DCE_FreeDCE( DCE *dce ) DeleteObject(dce->hClipRgn); HeapFree( GetProcessHeap(), 0, dce ); - WIN_UnlockWnds(); + USER_Unlock(); return *ppDCE; } @@ -147,7 +147,7 @@ void DCE_FreeWindowDCE( WND* pWnd ) { DCE *pDCE; - WIN_LockWnds(); + USER_Lock(); pDCE = firstDCE; while( pDCE ) @@ -192,7 +192,7 @@ void DCE_FreeWindowDCE( WND* pWnd ) pDCE = pDCE->next; } - WIN_UnlockWnds(); + USER_Unlock(); } @@ -603,7 +603,7 @@ INT WINAPI ReleaseDC( DCE * dce; INT nRet = 0; - WIN_LockWnds(); + USER_Lock(); dce = firstDCE; TRACE("%04x %04x\n", hwnd, hdc ); @@ -614,7 +614,7 @@ INT WINAPI ReleaseDC( if ( dce->DCXflags & DCX_DCEBUSY ) nRet = DCE_ReleaseDC( dce ); - WIN_UnlockWnds(); + USER_Unlock(); return nRet; } @@ -635,7 +635,7 @@ BOOL16 WINAPI DCHook16( HDC16 hDC, WORD code, DWORD data, LPARAM lParam ) assert(dce->hDC == hDC); /* Grab the windows lock before doing anything else */ - WIN_LockWnds(); + USER_Lock(); switch( code ) { @@ -672,7 +672,7 @@ BOOL16 WINAPI DCHook16( HDC16 hDC, WORD code, DWORD data, LPARAM lParam ) FIXME("unknown code\n"); } - WIN_UnlockWnds(); /* Release the wnd lock */ + USER_Unlock(); /* Release the wnd lock */ return retv; } @@ -694,13 +694,13 @@ HWND WINAPI WindowFromDC( HDC hDC ) DCE *dce; HWND hwnd; - WIN_LockWnds(); + USER_Lock(); dce = firstDCE; while (dce && (dce->hDC != hDC)) dce = dce->next; hwnd = dce ? dce->hwndCurrent : 0; - WIN_UnlockWnds(); + USER_Unlock(); return hwnd; } diff --git a/windows/user.c b/windows/user.c index a4adc4829a1..d114a12b8d8 100644 --- a/windows/user.c +++ b/windows/user.c @@ -31,6 +31,9 @@ DECLARE_DEBUG_CHANNEL(system); DECLARE_DEBUG_CHANNEL(win); DECLARE_DEBUG_CHANNEL(win32); +SYSLEVEL USER_SysLevel = { CRITICAL_SECTION_INIT("USER_SysLevel"), 2 }; + + /*********************************************************************** * GetFreeSystemResources (USER.284) */ @@ -88,6 +91,36 @@ INT16 WINAPI InitApp16( HINSTANCE16 hInstance ) return 1; } + +/*********************************************************************** + * USER_Lock + */ +void USER_Lock(void) +{ + _EnterSysLevel( &USER_SysLevel ); +} + + +/*********************************************************************** + * USER_Unlock + */ +void USER_Unlock(void) +{ + _LeaveSysLevel( &USER_SysLevel ); +} + + +/*********************************************************************** + * USER_CheckNotLock + * + * Make sure that we don't hold the user lock. + */ +void USER_CheckNotLock(void) +{ + _CheckNotSysLevel( &USER_SysLevel ); +} + + /********************************************************************** * USER_ModuleUnload */ diff --git a/windows/win.c b/windows/win.c index 419397d27e9..377b486b01d 100644 --- a/windows/win.c +++ b/windows/win.c @@ -38,27 +38,7 @@ static WORD wDragWidth = 4; static WORD wDragHeight= 3; /* thread safeness */ -static SYSLEVEL WIN_SysLevel = { CRITICAL_SECTION_INIT, 2 }; - -/*********************************************************************** - * WIN_LockWnds - * - * Locks access to all WND structures for thread safeness - */ -void WIN_LockWnds( void ) -{ - _EnterSysLevel( &WIN_SysLevel ); -} - -/*********************************************************************** - * WIN_UnlockWnds - * - * Unlocks access to all WND structures - */ -void WIN_UnlockWnds( void ) -{ - _LeaveSysLevel( &WIN_SysLevel ); -} +extern SYSLEVEL USER_SysLevel; /* FIXME */ /*********************************************************************** * WIN_SuspendWndsLock @@ -68,11 +48,11 @@ void WIN_UnlockWnds( void ) */ int WIN_SuspendWndsLock( void ) { - int isuspendedLocks = _ConfirmSysLevel( &WIN_SysLevel ); + int isuspendedLocks = _ConfirmSysLevel( &USER_SysLevel ); int count = isuspendedLocks; while ( count-- > 0 ) - _LeaveSysLevel( &WIN_SysLevel ); + _LeaveSysLevel( &USER_SysLevel ); return isuspendedLocks; } @@ -85,7 +65,7 @@ int WIN_SuspendWndsLock( void ) void WIN_RestoreWndsLock( int ipreviousLocks ) { while ( ipreviousLocks-- > 0 ) - _EnterSysLevel( &WIN_SysLevel ); + _EnterSysLevel( &USER_SysLevel ); } /*********************************************************************** @@ -100,7 +80,7 @@ WND * WIN_FindWndPtr( HWND hwnd ) if (!hwnd || HIWORD(hwnd)) goto error2; ptr = (WND *) USER_HEAP_LIN_ADDR( hwnd ); /* Lock all WND structures for thread safeness*/ - WIN_LockWnds(); + USER_Lock(); /*and increment destruction monitoring*/ ptr->irefCount++; @@ -114,7 +94,7 @@ WND * WIN_FindWndPtr( HWND hwnd ) return ptr; error: /* Unlock all WND structures for thread safeness*/ - WIN_UnlockWnds(); + USER_Unlock(); /* and decrement destruction monitoring value */ ptr->irefCount--; @@ -136,7 +116,7 @@ WND *WIN_LockWndPtr(WND *initWndPtr) if(!initWndPtr) return 0; /* Lock all WND structures for thread safeness*/ - WIN_LockWnds(); + USER_Lock(); /*and increment destruction monitoring*/ initWndPtr->irefCount++; @@ -168,7 +148,7 @@ void WIN_ReleaseWndPtr(WND *wndPtr) ERR("forgot a Lock on %p somewhere\n",wndPtr); } /*unlock all WND structures for thread safeness*/ - WIN_UnlockWnds(); + USER_Unlock(); } /***********************************************************************