[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH 03/10] Use InterlockedBitTestAnd[Set|Reset] in SHARED_INFO
Rather then using InterlockedCompareAndExchange to set and clear bits in the SHARED_INFO event channel masks, use InterlockedBitTestAnd[Set|Reset] as these will resolve to instrinsics when available. Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx> --- src/xenbus/shared_info.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/xenbus/shared_info.c b/src/xenbus/shared_info.c index 9a6af3a..41c99cf 100644 --- a/src/xenbus/shared_info.c +++ b/src/xenbus/shared_info.c @@ -74,21 +74,12 @@ SharedInfoSetBit( IN ULONG Bit ) { - ULONG_PTR Old; - ULONG_PTR New; - ASSERT3U(Bit, <, sizeof (ULONG_PTR) * 8); KeMemoryBarrier(); - do { - Old = *Mask; - New = Old | ((ULONG_PTR)1 << Bit); - } while (InterlockedCompareExchangePointer((PVOID *)Mask, (PVOID)New, (PVOID)Old) != (PVOID)Old); - - KeMemoryBarrier(); - - return (Old & ((ULONG_PTR)1 << Bit)) ? FALSE : TRUE; // return TRUE if we set the bit + // return TRUE if we set the bit + return (InterlockedBitTestAndSet((LONG *)Mask, Bit) == 0) ? TRUE : FALSE; } static BOOLEAN @@ -97,21 +88,12 @@ SharedInfoClearBit( IN ULONG Bit ) { - ULONG_PTR Old; - ULONG_PTR New; - ASSERT3U(Bit, <, sizeof (ULONG_PTR) * 8); KeMemoryBarrier(); - do { - Old = *Mask; - New = Old & ~((ULONG_PTR)1 << Bit); - } while (InterlockedCompareExchangePointer((PVOID *)Mask, (PVOID)New, (PVOID)Old) != (PVOID)Old); - - KeMemoryBarrier(); - - return (Old & ((ULONG_PTR)1 << Bit)) ? TRUE : FALSE; // return TRUE if we cleared the bit + // return TRUE if we cleared the bit + return (InterlockedBitTestAndReset((LONG *)Mask, Bit) != 0) ? TRUE : FALSE; } static BOOLEAN -- 2.1.1 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |