/* We failed, this is bad... */
DPRINT1("Failed to Create Event!\n");
- _InterlockedDecrement(&CriticalSection->LockCount);
+ InterlockedDecrement(&CriticalSection->LockCount);
RtlRaiseStatus(Status);
return;
}
DPRINT("Created Event: %p \n", hNewEvent);
- if ((hEvent = (HANDLE)_InterlockedCompareExchangePointer((PVOID*)&CriticalSection->LockSemaphore,
- (PVOID)hNewEvent,
- 0))) {
+ if (InterlockedCompareExchangePointer((PVOID*)&CriticalSection->LockSemaphore,
+ (PVOID)hNewEvent,
+ 0)) {
/* Some just created an event */
DPRINT("Closing already created event: %p\n", hNewEvent);
DPRINT("Waiting on Critical Section Event: %p %p\n",
CriticalSection,
CriticalSection->LockSemaphore);
- CriticalSection->DebugInfo->EntryCount++;
+
+ if (CriticalSection->DebugInfo)
+ CriticalSection->DebugInfo->EntryCount++;
for (;;) {
/* Increase the number of times we've had contention */
- CriticalSection->DebugInfo->ContentionCount++;
+ if (CriticalSection->DebugInfo)
+ CriticalSection->DebugInfo->ContentionCount++;
/* Wait on the Event */
Status = NtWaitForSingleObject(CriticalSection->LockSemaphore,
HANDLE Thread = (HANDLE)NtCurrentTeb()->ClientId.UniqueThread;
/* Try to Lock it */
- if (_InterlockedIncrement(&CriticalSection->LockCount) != 0) {
+ if (InterlockedIncrement(&CriticalSection->LockCount) != 0) {
/*
* We've failed to lock it! Does this thread
RtlLeaveCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
{
#ifndef NDEBUG
- HANDLE Thread = (HANDLE)NtCurrentTeb()->Cid.UniqueThread;
+ HANDLE Thread = (HANDLE)NtCurrentTeb()->ClientId.UniqueThread;
/* In win this case isn't checked. However it's a valid check so it should only
be performed in debug builds! */
if (--CriticalSection->RecursionCount) {
/* Someone still owns us, but we are free. This needs to be done atomically. */
- _InterlockedDecrement(&CriticalSection->LockCount);
+ InterlockedDecrement(&CriticalSection->LockCount);
} else {
CriticalSection->OwningThread = 0;
/* Was someone wanting us? This needs to be done atomically. */
- if (-1 != _InterlockedDecrement(&CriticalSection->LockCount)) {
+ if (-1 != InterlockedDecrement(&CriticalSection->LockCount)) {
/* Let him have us */
RtlpUnWaitCriticalSection(CriticalSection);
RtlTryEnterCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
{
/* Try to take control */
- if (_InterlockedCompareExchange(&CriticalSection->LockCount,
+ if (InterlockedCompareExchange(&CriticalSection->LockCount,
0,
-1) == -1) {
} else if (CriticalSection->OwningThread == NtCurrentTeb()->ClientId.UniqueThread) {
/* It's already ours */
- _InterlockedIncrement(&CriticalSection->LockCount);
+ InterlockedIncrement(&CriticalSection->LockCount);
CriticalSection->RecursionCount++;
return TRUE;
}