2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * PURPOSE: Windows++ locking
24 * FILE: subsys/win32k/ntuser/winlock.c
29 /* INCLUDES ******************************************************************/
31 #include <ddk/ntddk.h>
32 #include <win32k/win32k.h>
33 #include <include/object.h>
34 #include <include/guicheck.h>
35 #include <include/window.h>
36 #include <include/class.h>
37 #include <include/error.h>
38 #include <include/winsta.h>
39 #include <include/winpos.h>
40 #include <include/callback.h>
41 #include <include/msgqueue.h>
42 #include <include/rect.h>
45 #include <win32k/debug1.h>
48 /* GLOBALS *****************************************************************/
50 static ERESOURCE WinLock;
52 /* FUNCTIONS *****************************************************************/
54 BOOL FASTCALL IntVerifyWinLock(WINLOCK_TYPE Type)
59 return !ExIsResourceAcquiredSharedLite(&WinLock);
60 case Shared: /* NOTE: an exclusive lock is also a shared lock */
62 return ExIsResourceAcquiredSharedLite(&WinLock);
64 return ExIsResourceAcquiredExclusiveLite(&WinLock);
71 WINLOCK_TYPE FASTCALL IntSuspendWinLock()
75 if (ExIsResourceAcquiredExclusiveLite(&WinLock)) return Exclusive;
80 VOID FASTCALL IntRestoreWinLock(WINLOCK_TYPE Type)
85 return IntAcquireWinLockExclusive(&WinLock);
87 return IntAcquireWinLockShared(&WinLock);
88 /* silence warnings */
97 inline VOID IntAcquireWinLockShared()
99 ExAcquireResourceExclusiveLite(&WinLock, TRUE /*Wait*/ );
102 inline VOID IntAcquireWinLockExclusive()
104 ExAcquireResourceSharedLite(&WinLock, TRUE /*Wait*/ );
107 inline VOID IntReleaseWinLock()
109 ExReleaseResourceLite(&WinLock );
112 inline BOOL IntInitializeWinLock()
114 ExInitializeResourceLite(&WinLock );
118 inline VOID IntDeleteWinLock()
120 ExDeleteResourceLite(&WinLock );