Provide atomic bit test and clear functionality
All checks were successful
Builds / ExectOS (i686, debug) (push) Successful in 35s
Builds / ExectOS (amd64, release) (push) Successful in 35s
Builds / ExectOS (amd64, debug) (push) Successful in 42s
Builds / ExectOS (i686, release) (push) Successful in 38s

This commit is contained in:
2026-06-29 00:31:55 +02:00
parent 2868db63ca
commit 7d9c338e2a
2 changed files with 48 additions and 2 deletions

View File

@@ -36,6 +36,10 @@ namespace RTL
IN LONG Mask);
STATIC XTFASTCALL LONG_PTR And64(IN PLONG_PTR Address,
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,
IN LONG Offset);
STATIC XTFASTCALL UCHAR BitTestAndSet64(IN PLONGLONG Base,

View File

@@ -199,6 +199,48 @@ RTL::Atomic::And64(IN PLONG_PTR Address,
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.
*
@@ -208,7 +250,7 @@ RTL::Atomic::And64(IN PLONG_PTR Address,
* @param Offset
* 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
*/
@@ -229,7 +271,7 @@ RTL::Atomic::BitTestAndSet(IN PLONG Base,
* @param Offset
* 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
*/