Author: tkreuzer Date: Tue Apr 3 13:27:45 2012 New Revision: 56324
URL: http://svn.reactos.org/svn/reactos?rev=56324&view=rev Log: [NTOSKRNL] Don't truncate pointers to 32 bits in pushlock code
Modified: trunk/reactos/ntoskrnl/ex/pushlock.c
Modified: trunk/reactos/ntoskrnl/ex/pushlock.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/pushlock.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/ex/pushlock.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ex/pushlock.c [iso-8859-1] Tue Apr 3 13:27:45 2012 @@ -245,11 +245,11 @@ ExfWakePushLock(PushLock, OldValue); break; } - + /* Get the wait block */ WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)(OldValue.Value & ~EX_PUSH_LOCK_PTR_BITS); - + /* Loop the blocks */ FirstWaitBlock = WaitBlock; while (TRUE) @@ -262,32 +262,32 @@ FirstWaitBlock->Last = LastWaitBlock; break; } - + /* Save the block */ PreviousWaitBlock = WaitBlock; - + /* Get the next block */ WaitBlock = WaitBlock->Next; - + /* Save the previous */ WaitBlock->Previous = PreviousWaitBlock; } - + /* Remove the wake bit */ NewValue.Value = OldValue.Value &~ EX_PUSH_LOCK_WAKING; - + /* Sanity checks */ ASSERT(NewValue.Locked); ASSERT(!NewValue.Waking); - + /* Update the value */ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr, NewValue.Ptr, OldValue.Ptr); - + /* If we updated correctly, leave */ if (NewValue.Value == OldValue.Value) break; - + /* Update value */ OldValue = NewValue; } @@ -523,7 +523,7 @@ EX_PUSH_LOCK_LOCK | EX_PUSH_LOCK_WAKING | EX_PUSH_LOCK_WAITING | - PtrToUlong(WaitBlock); + (ULONG_PTR)WaitBlock;
/* Check if the pushlock was already waking */ if (!OldValue.Waking) NeedWake = TRUE; @@ -543,7 +543,7 @@ NewValue.Value = EX_PUSH_LOCK_MULTIPLE_SHARED | EX_PUSH_LOCK_LOCK | EX_PUSH_LOCK_WAITING | - PtrToUlong(WaitBlock); + (ULONG_PTR)WaitBlock; } else { @@ -553,7 +553,7 @@ /* Point to our wait block */ NewValue.Value = EX_PUSH_LOCK_LOCK | EX_PUSH_LOCK_WAITING | - PtrToUlong(WaitBlock); + (ULONG_PTR)WaitBlock; } }
@@ -706,7 +706,7 @@ EX_PUSH_LOCK_LOCK)) | EX_PUSH_LOCK_WAKING | EX_PUSH_LOCK_WAITING | - PtrToUlong(WaitBlock); + (ULONG_PTR)WaitBlock;
/* Check if the pushlock was already waking */ if (!OldValue.Waking) NeedWake = TRUE; @@ -719,7 +719,7 @@ /* Point to our wait block */ NewValue.Value = (OldValue.Value & EX_PUSH_LOCK_PTR_BITS) | EX_PUSH_LOCK_WAITING | - PtrToUlong(WaitBlock); + (ULONG_PTR)WaitBlock; }
/* Sanity check */ @@ -812,7 +812,7 @@
/* Sanity check */ ASSERT(OldValue.Locked); - + /* Start main loop */ while (TRUE) { @@ -849,13 +849,13 @@ /* Get the wait block */ WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)(OldValue.Value & ~EX_PUSH_LOCK_PTR_BITS); - + /* Loop until we find the last wait block */ while (TRUE) { /* Get the last wait block */ LastWaitBlock = WaitBlock->Last; - + /* Did it exist? */ if (LastWaitBlock) { @@ -863,22 +863,22 @@ WaitBlock = LastWaitBlock; break; } - + /* Keep searching */ WaitBlock = WaitBlock->Next; } - + /* Make sure the Share Count is above 0 */ if (WaitBlock->ShareCount > 0) { /* This shouldn't be an exclusive wait block */ ASSERT(WaitBlock->Flags & EX_PUSH_LOCK_FLAGS_EXCLUSIVE); - + /* Do the decrease and check if the lock isn't shared anymore */ if (InterlockedDecrement(&WaitBlock->ShareCount) > 0) return; } } - + /* * If nobody was waiting on the block, then we possibly reduced the number * of times the pushlock was shared, and we unlocked it. @@ -895,10 +895,10 @@ NewValue.Value = OldValue.Value; NewValue.MultipleShared = FALSE; NewValue.Locked = FALSE; - + /* Sanity check */ ASSERT(NewValue.Waking && !NewValue.Locked && !NewValue.MultipleShared); - + /* Write the new value */ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr, NewValue.Ptr, @@ -911,20 +911,20 @@ NewValue.Value = OldValue.Value; NewValue.MultipleShared = FALSE; NewValue.Locked = FALSE; - + /* It's not already waking, so add the wake bit */ NewValue.Waking = TRUE; - + /* Sanity check */ ASSERT(NewValue.Waking && !NewValue.Locked && !NewValue.MultipleShared); - + /* Write the new value */ WakeValue = NewValue; NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr, NewValue.Ptr, OldValue.Ptr); if (NewValue.Value != OldValue.Value) continue; - + /* The write was successful. The pushlock is Unlocked and Waking */ ExfWakePushLock(PushLock, WakeValue); return; @@ -988,13 +988,13 @@ /* Get the wait block */ WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)(OldValue.Value & ~EX_PUSH_LOCK_PTR_BITS); - + /* Loop until we find the last wait block */ while (TRUE) { /* Get the last wait block */ LastWaitBlock = WaitBlock->Last; - + /* Did it exist? */ if (LastWaitBlock) { @@ -1002,7 +1002,7 @@ WaitBlock = LastWaitBlock; break; } - + /* Keep searching */ WaitBlock = WaitBlock->Next; } @@ -1169,11 +1169,11 @@ * and locked, don't do anything */ if ((OldValue.Waking) || (OldValue.Locked) || !(OldValue.Waiting)) return; - + /* Make it Waking */ NewValue = OldValue; NewValue.Waking = TRUE; - + /* Write the New Value */ if (InterlockedCompareExchangePointer(&PushLock->Ptr, NewValue.Ptr,