/* PRIVATE FUNCTIONS *********************************************************/
+#ifdef _WIN64
+#define InterlockedAndPointer(ptr,val) InterlockedAnd64((PLONGLONG)ptr,(LONGLONG)val)
+#else
+#define InterlockedAndPointer(ptr,val) InterlockedAnd((PLONG)ptr,(LONG)val)
+#endif
+
/*++
* @name ExpInitializePushLocks
*
ASSERT(NewValue.Waiting);
/* Write the New Value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value == OldValue.Value) return;
}
/* Save the First Block */
- FirstWaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)((ULONG_PTR)OldValue.Ptr &
+ FirstWaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)(OldValue.Value &
~EX_PUSH_LOCK_PTR_BITS);
WaitBlock = FirstWaitBlock;
ASSERT(!NewValue.Waking);
/* Write the New Value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value == OldValue.Value) break;
ASSERT(PushLock->Waiting);
/* Remove waking bit from pushlock */
- InterlockedAnd((PLONG)PushLock, ~EX_PUSH_LOCK_WAKING);
+ InterlockedAndPointer(&PushLock->Value, ~EX_PUSH_LOCK_WAKING);
/* Leave the loop */
break;
}
/* Get the wait block */
- WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)((ULONG_PTR)OldValue.Ptr &
+ WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)(OldValue.Value &
~EX_PUSH_LOCK_PTR_BITS);
/* Loop the blocks */
ASSERT(!NewValue.Waking);
/* Update the value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
ASSERT(NewValue.Locked);
/* Set the new value */
- if (InterlockedCompareExchangePointer(PushLock,
+ if (InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr) != OldValue.Ptr)
{
WaitBlock->ShareCount = 0;
/* Set the current Wait Block pointer */
- WaitBlock->Next = (PEX_PUSH_LOCK_WAIT_BLOCK)((ULONG_PTR)
- OldValue.Ptr &~ EX_PUSH_LOCK_PTR_BITS);
+ WaitBlock->Next = (PEX_PUSH_LOCK_WAIT_BLOCK)(
+ OldValue.Value &~ EX_PUSH_LOCK_PTR_BITS);
/* Point to ours */
NewValue.Value = (OldValue.Value & EX_PUSH_LOCK_MULTIPLE_SHARED) |
/* Write the new value */
TempValue = NewValue;
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value != OldValue.Value)
ASSERT(NewValue.Locked);
/* Set the new value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value != OldValue.Value)
if (OldValue.Waiting)
{
/* Set the current Wait Block pointer */
- WaitBlock->Next = (PEX_PUSH_LOCK_WAIT_BLOCK)((ULONG_PTR)
- OldValue.Ptr &~ EX_PUSH_LOCK_PTR_BITS);
+ WaitBlock->Next = (PEX_PUSH_LOCK_WAIT_BLOCK)(
+ OldValue.Value &~ EX_PUSH_LOCK_PTR_BITS);
/* Nobody is the last waiter yet */
WaitBlock->Last = NULL;
#endif
/* Write the new value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Ptr != OldValue.Ptr)
}
/* Write the New Value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value == OldValue.Value) return;
if (OldValue.MultipleShared)
{
/* Get the wait block */
- WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)((ULONG_PTR)OldValue.Ptr &
+ WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)(OldValue.Value &
~EX_PUSH_LOCK_PTR_BITS);
/* Loop until we find the last wait block */
ASSERT(NewValue.Waking && !NewValue.Locked && !NewValue.MultipleShared);
/* Write the new value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value == OldValue.Value) return;
/* Write the new value */
WakeValue = NewValue;
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value != OldValue.Value) continue;
}
/* Write the New Value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value == OldValue.Value) return;
if (OldValue.MultipleShared)
{
/* Get the wait block */
- WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)((ULONG_PTR)OldValue.Ptr &
+ WaitBlock = (PEX_PUSH_LOCK_WAIT_BLOCK)(OldValue.Value &
~EX_PUSH_LOCK_PTR_BITS);
/* Loop until we find the last wait block */
ASSERT(NewValue.Waking && !NewValue.Locked && !NewValue.MultipleShared);
/* Write the new value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value == OldValue.Value) return;
/* Write the new value */
WakeValue = NewValue;
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
if (NewValue.Value != OldValue.Value) continue;
/* Write the New Value. Save our original value for waking */
WakeValue = NewValue;
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
ASSERT(NewValue.Waking && !NewValue.Waiting);
/* Write the New Value */
- NewValue.Ptr = InterlockedCompareExchangePointer(PushLock,
+ NewValue.Ptr = InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr);
NewValue.Waking = TRUE;
/* Write the New Value */
- if (InterlockedCompareExchangePointer(PushLock,
+ if (InterlockedCompareExchangePointer(&PushLock->Ptr,
NewValue.Ptr,
OldValue.Ptr) == OldValue.Ptr)
{