diff --git a/xtoskrnl/CMakeLists.txt b/xtoskrnl/CMakeLists.txt index f6344a3..730f302 100644 --- a/xtoskrnl/CMakeLists.txt +++ b/xtoskrnl/CMakeLists.txt @@ -36,7 +36,6 @@ list(APPEND XTOSKRNL_SOURCE ${XTOSKRNL_SOURCE_DIR}/po/idle.c ${XTOSKRNL_SOURCE_DIR}/rtl/atomic.c ${XTOSKRNL_SOURCE_DIR}/rtl/byteswap.c - ${XTOSKRNL_SOURCE_DIR}/rtl/intrin.c ${XTOSKRNL_SOURCE_DIR}/rtl/ioreg.c ${XTOSKRNL_SOURCE_DIR}/rtl/memory.c ${XTOSKRNL_SOURCE_DIR}/rtl/plist.c diff --git a/xtoskrnl/ex/rundown.c b/xtoskrnl/ex/rundown.c index 40ee5e9..07ac56d 100644 --- a/xtoskrnl/ex/rundown.c +++ b/xtoskrnl/ex/rundown.c @@ -42,7 +42,7 @@ ExAcquireRundownProtection(IN PEX_RUNDOWN_REFERENCE Descriptor) NewValue = CurrentValue + 2; /* Exchange the value */ - NewValue = (ULONG_PTR)RtlInterlockedCompareExchangePointer(&Descriptor->Ptr, (PVOID)NewValue, + NewValue = (ULONG_PTR)RtlAtomicCompareExchangePointer(&Descriptor->Ptr, (PVOID)NewValue, (PVOID)CurrentValue); /* Make sure protection acquired */ @@ -100,7 +100,7 @@ ExReleaseRundownProtection(IN PEX_RUNDOWN_REFERENCE Descriptor) { WaitBlock = (PEX_RUNDOWN_WAIT_BLOCK)(CurrentValue & ~0x1); - if(!RtlInterlockedDecrement64((PLONG_PTR)&WaitBlock->Count)) + if(!RtlAtomicDecrement64((PLONG_PTR)&WaitBlock->Count)) { KeSetEvent(&WaitBlock->WakeEvent, 0, FALSE); } @@ -113,7 +113,7 @@ ExReleaseRundownProtection(IN PEX_RUNDOWN_REFERENCE Descriptor) NewValue = CurrentValue - 2; /* Exchange the value */ - NewValue = (ULONG_PTR)RtlInterlockedCompareExchangePointer(&Descriptor->Ptr, (PVOID)NewValue, + NewValue = (ULONG_PTR)RtlAtomicCompareExchangePointer(&Descriptor->Ptr, (PVOID)NewValue, (PVOID)CurrentValue); if(NewValue == CurrentValue) diff --git a/xtoskrnl/includes/rtl.h b/xtoskrnl/includes/rtl.h index e14d277..785568f 100644 --- a/xtoskrnl/includes/rtl.h +++ b/xtoskrnl/includes/rtl.h @@ -223,21 +223,6 @@ VOID RtlInsertTailList(IN OUT PLIST_ENTRY ListHead, IN PLIST_ENTRY Entry); -XTFASTCALL -PVOID -RtlInterlockedCompareExchangePointer(IN VOLATILE PVOID *Destination, - IN PVOID Comperand, - IN PVOID Exchange); - -XTFASTCALL -LONG_PTR -RtlInterlockedDecrement64(IN VOLATILE PLONG_PTR Addend); - -XTFASTCALL -PVOID -RtlInterlockedExchangePointer(IN VOLATILE PVOID *Destination, - IN PVOID Value); - XTCDECL BOOLEAN RtlListEmpty(PLIST_ENTRY ListHead); diff --git a/xtoskrnl/rtl/atomic.c b/xtoskrnl/rtl/atomic.c index 9881623..655e8d1 100644 --- a/xtoskrnl/rtl/atomic.c +++ b/xtoskrnl/rtl/atomic.c @@ -472,6 +472,7 @@ PVOID RtlAtomicExchangePointer(IN VOLATILE PVOID *Address, IN PVOID Exchange) { + __sync_synchronize(); return (PVOID)__sync_lock_test_and_set(Address, Exchange); } diff --git a/xtoskrnl/rtl/intrin.c b/xtoskrnl/rtl/intrin.c deleted file mode 100644 index 1ab1790..0000000 --- a/xtoskrnl/rtl/intrin.c +++ /dev/null @@ -1,74 +0,0 @@ -/** - * PROJECT: ExectOS - * COPYRIGHT: See COPYING.md in the top level directory - * FILE: xtoskrnl/rtl/intrin.c - * DESCRIPTION: Interlocked operations support - * DEVELOPERS: Rafal Kupiec - */ - -#include - - -/** - * Performs an atomic compare exchange operation on the pointer value. - * - * @param Destination - * Supplues a pointer to the variable for the compare exchange operation. - * - * @param Comperand - * Supplies a pointer value used in compare operation. - * - * @param Exchange - * Supplies a pointer value used in exchange operation. - * - * @return This routine returns the initial pointer value of the Destination parameter. - * - * @since XT 1.0 - */ -XTFASTCALL -PVOID -RtlInterlockedCompareExchangePointer(IN VOLATILE PVOID *Destination, - IN PVOID Comperand, - IN PVOID Exchange) -{ - return (PVOID)__sync_val_compare_and_swap(Destination, Comperand, Exchange); -} - -/** - * Performs an atomic decrement of the 32-bit or 64bit value, depending on architecture. - * - * @param Addend - * Specifies a pointer to the variable to be decremented. - * - * @return This routine returns the decremented value. - * - * @since XT 1.0 - */ -XTFASTCALL -LONG_PTR -RtlInterlockedDecrement64(IN VOLATILE PLONG_PTR Addend) -{ - 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); -}