Provide atomic bit test and clear functionality
This commit is contained in:
@@ -36,6 +36,10 @@ namespace RTL
|
|||||||
IN LONG Mask);
|
IN LONG Mask);
|
||||||
STATIC XTFASTCALL LONG_PTR And64(IN PLONG_PTR Address,
|
STATIC XTFASTCALL LONG_PTR And64(IN PLONG_PTR Address,
|
||||||
IN LONG_PTR Mask);
|
IN LONG_PTR Mask);
|
||||||
|
STATIC XTFASTCALL UCHAR BitTestAndReset(IN PLONG Base,
|
||||||
|
IN LONG Offset);
|
||||||
|
STATIC XTFASTCALL UCHAR BitTestAndReset64(IN PLONGLONG Base,
|
||||||
|
IN LONGLONG Offset);
|
||||||
STATIC XTFASTCALL UCHAR BitTestAndSet(IN PLONG Base,
|
STATIC XTFASTCALL UCHAR BitTestAndSet(IN PLONG Base,
|
||||||
IN LONG Offset);
|
IN LONG Offset);
|
||||||
STATIC XTFASTCALL UCHAR BitTestAndSet64(IN PLONGLONG Base,
|
STATIC XTFASTCALL UCHAR BitTestAndSet64(IN PLONGLONG Base,
|
||||||
|
|||||||
@@ -199,6 +199,48 @@ RTL::Atomic::And64(IN PLONG_PTR Address,
|
|||||||
return __sync_fetch_and_and(Address, Mask);
|
return __sync_fetch_and_and(Address, Mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs an atomic test of the specified bit of the specified long value and resets it to 0.
|
||||||
|
*
|
||||||
|
* @param Base
|
||||||
|
* Supplies a pointer to the variable.
|
||||||
|
*
|
||||||
|
* @param Offset
|
||||||
|
* Specifies the bit position to be tested.
|
||||||
|
*
|
||||||
|
* @return This routine returns the original value of the specified bit.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTFASTCALL
|
||||||
|
UCHAR
|
||||||
|
RTL::Atomic::BitTestAndReset(IN PLONG Base,
|
||||||
|
IN LONG Offset)
|
||||||
|
{
|
||||||
|
return (__atomic_fetch_and(Base, ~(1l << Offset), __ATOMIC_SEQ_CST) >> Offset) & 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs an atomic test of the specified bit of the specified 64-bit long value and resets it to 0.
|
||||||
|
*
|
||||||
|
* @param Base
|
||||||
|
* Supplies a pointer to the variable.
|
||||||
|
*
|
||||||
|
* @param Offset
|
||||||
|
* Specifies the bit position to be tested.
|
||||||
|
*
|
||||||
|
* @return This routine returns the original value of the specified bit.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTFASTCALL
|
||||||
|
UCHAR
|
||||||
|
RTL::Atomic::BitTestAndReset64(IN PLONGLONG Base,
|
||||||
|
IN LONGLONG Offset)
|
||||||
|
{
|
||||||
|
return (__atomic_fetch_and(Base, ~(1ll << Offset), __ATOMIC_SEQ_CST) >> Offset) & 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs an atomic test of the specified bit of the specified long value and sets it to 1.
|
* Performs an atomic test of the specified bit of the specified long value and sets it to 1.
|
||||||
*
|
*
|
||||||
@@ -208,7 +250,7 @@ RTL::Atomic::And64(IN PLONG_PTR Address,
|
|||||||
* @param Offset
|
* @param Offset
|
||||||
* Specifies the bit position to be tested.
|
* Specifies the bit position to be tested.
|
||||||
*
|
*
|
||||||
* @return Returns a value of the specified bit.
|
* @return This routine returns a value of the specified bit.
|
||||||
*
|
*
|
||||||
* @since XT 1.0
|
* @since XT 1.0
|
||||||
*/
|
*/
|
||||||
@@ -229,7 +271,7 @@ RTL::Atomic::BitTestAndSet(IN PLONG Base,
|
|||||||
* @param Offset
|
* @param Offset
|
||||||
* Specifies the bit position to be tested.
|
* Specifies the bit position to be tested.
|
||||||
*
|
*
|
||||||
* @return Returns a value of the specified bit.
|
* @return This routine returns a value of the specified bit.
|
||||||
*
|
*
|
||||||
* @since XT 1.0
|
* @since XT 1.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user