Implement RtlInterlockedExchangePointer() routine
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 32s
Builds / ExectOS (i686) (push) Successful in 27s

This commit is contained in:
Rafal Kupiec 2023-10-29 11:48:31 +01:00
parent 6d63750fc2
commit cf7c467637
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
2 changed files with 27 additions and 0 deletions

View File

@ -233,6 +233,11 @@ XTFASTCALL
LONG_PTR LONG_PTR
RtlInterlockedDecrementLongPtr(IN VOLATILE PLONG_PTR Addend); RtlInterlockedDecrementLongPtr(IN VOLATILE PLONG_PTR Addend);
XTFASTCALL
PVOID
RtlInterlockedExchangePointer(IN VOLATILE PVOID *Destination,
IN PVOID Value);
XTCDECL XTCDECL
BOOLEAN BOOLEAN
RtlListEmpty(PLIST_ENTRY ListHead); RtlListEmpty(PLIST_ENTRY ListHead);

View File

@ -50,3 +50,25 @@ RtlInterlockedDecrementLongPtr(IN VOLATILE PLONG_PTR Addend)
{ {
return (LONG_PTR)__sync_sub_and_fetch(Addend, 1); return (LONG_PTR)__sync_sub_and_fetch(Addend, 1);
} }
/**
* Performs an atomic assignment of the value to the pointer variable.
*
* @param Destination
* Supplies a pointer to the variable to be set.
*
* @param Value
* Supplies a value to set.
*
* @return This routine returns the initial value of the pointer variable.
*
* @since XT 1.0
*/
XTFASTCALL
PVOID
RtlInterlockedExchangePointer(IN VOLATILE PVOID *Destination,
IN PVOID Value)
{
__sync_synchronize();
return (void *)__sync_lock_test_and_set(Destination, Value);
}