Build Generic HAL with w32api
[reactos.git] / reactos / hal / halx86 / generic / fmutex.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/hal/x86/fmutex.c
6 * PURPOSE: Implements fast mutexes
7 * PROGRAMMER: David Welch (welch@cwcom.net)
8 * Eric Kohl (ekohl@rz-online.de)
9 * UPDATE HISTORY:
10 * Created 09/06/2000
11 */
12
13 /* INCLUDES *****************************************************************/
14
15 #define NDEBUG
16 #include <hal.h>
17
18 /* FUNCTIONS *****************************************************************/
19
20 #undef KeEnterCriticalRegion
21 #undef KeLeaveCriticalRegion
22 VOID FASTCALL
23 ExAcquireFastMutex (PFAST_MUTEX FastMutex)
24 {
25 KeEnterCriticalRegion();
26 ExAcquireFastMutexUnsafe(FastMutex);
27 }
28
29
30 VOID FASTCALL
31 ExReleaseFastMutex (PFAST_MUTEX FastMutex)
32 {
33 ExReleaseFastMutexUnsafe(FastMutex);
34 KeLeaveCriticalRegion();
35 }
36
37
38 BOOLEAN FASTCALL
39 ExTryToAcquireFastMutex (PFAST_MUTEX FastMutex)
40 {
41 KeEnterCriticalRegion();
42 if (InterlockedExchange(&FastMutex->Count, 0) == 1)
43 {
44 FastMutex->Owner = KeGetCurrentThread();
45 return(TRUE);
46 }
47 else
48 {
49 KeLeaveCriticalRegion();
50 return(FALSE);
51 }
52 }
53
54 /* EOF */