Keep only atomic routines
This commit is contained in:
parent
3f2baa5b50
commit
a359c9b2e8
@ -36,7 +36,6 @@ list(APPEND XTOSKRNL_SOURCE
|
|||||||
${XTOSKRNL_SOURCE_DIR}/po/idle.c
|
${XTOSKRNL_SOURCE_DIR}/po/idle.c
|
||||||
${XTOSKRNL_SOURCE_DIR}/rtl/atomic.c
|
${XTOSKRNL_SOURCE_DIR}/rtl/atomic.c
|
||||||
${XTOSKRNL_SOURCE_DIR}/rtl/byteswap.c
|
${XTOSKRNL_SOURCE_DIR}/rtl/byteswap.c
|
||||||
${XTOSKRNL_SOURCE_DIR}/rtl/intrin.c
|
|
||||||
${XTOSKRNL_SOURCE_DIR}/rtl/ioreg.c
|
${XTOSKRNL_SOURCE_DIR}/rtl/ioreg.c
|
||||||
${XTOSKRNL_SOURCE_DIR}/rtl/memory.c
|
${XTOSKRNL_SOURCE_DIR}/rtl/memory.c
|
||||||
${XTOSKRNL_SOURCE_DIR}/rtl/plist.c
|
${XTOSKRNL_SOURCE_DIR}/rtl/plist.c
|
||||||
|
@ -42,7 +42,7 @@ ExAcquireRundownProtection(IN PEX_RUNDOWN_REFERENCE Descriptor)
|
|||||||
NewValue = CurrentValue + 2;
|
NewValue = CurrentValue + 2;
|
||||||
|
|
||||||
/* Exchange the value */
|
/* Exchange the value */
|
||||||
NewValue = (ULONG_PTR)RtlInterlockedCompareExchangePointer(&Descriptor->Ptr, (PVOID)NewValue,
|
NewValue = (ULONG_PTR)RtlAtomicCompareExchangePointer(&Descriptor->Ptr, (PVOID)NewValue,
|
||||||
(PVOID)CurrentValue);
|
(PVOID)CurrentValue);
|
||||||
|
|
||||||
/* Make sure protection acquired */
|
/* Make sure protection acquired */
|
||||||
@ -100,7 +100,7 @@ ExReleaseRundownProtection(IN PEX_RUNDOWN_REFERENCE Descriptor)
|
|||||||
{
|
{
|
||||||
WaitBlock = (PEX_RUNDOWN_WAIT_BLOCK)(CurrentValue & ~0x1);
|
WaitBlock = (PEX_RUNDOWN_WAIT_BLOCK)(CurrentValue & ~0x1);
|
||||||
|
|
||||||
if(!RtlInterlockedDecrement64((PLONG_PTR)&WaitBlock->Count))
|
if(!RtlAtomicDecrement64((PLONG_PTR)&WaitBlock->Count))
|
||||||
{
|
{
|
||||||
KeSetEvent(&WaitBlock->WakeEvent, 0, FALSE);
|
KeSetEvent(&WaitBlock->WakeEvent, 0, FALSE);
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ ExReleaseRundownProtection(IN PEX_RUNDOWN_REFERENCE Descriptor)
|
|||||||
NewValue = CurrentValue - 2;
|
NewValue = CurrentValue - 2;
|
||||||
|
|
||||||
/* Exchange the value */
|
/* Exchange the value */
|
||||||
NewValue = (ULONG_PTR)RtlInterlockedCompareExchangePointer(&Descriptor->Ptr, (PVOID)NewValue,
|
NewValue = (ULONG_PTR)RtlAtomicCompareExchangePointer(&Descriptor->Ptr, (PVOID)NewValue,
|
||||||
(PVOID)CurrentValue);
|
(PVOID)CurrentValue);
|
||||||
|
|
||||||
if(NewValue == CurrentValue)
|
if(NewValue == CurrentValue)
|
||||||
|
@ -223,21 +223,6 @@ VOID
|
|||||||
RtlInsertTailList(IN OUT PLIST_ENTRY ListHead,
|
RtlInsertTailList(IN OUT PLIST_ENTRY ListHead,
|
||||||
IN PLIST_ENTRY Entry);
|
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
|
XTCDECL
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
RtlListEmpty(PLIST_ENTRY ListHead);
|
RtlListEmpty(PLIST_ENTRY ListHead);
|
||||||
|
@ -472,6 +472,7 @@ PVOID
|
|||||||
RtlAtomicExchangePointer(IN VOLATILE PVOID *Address,
|
RtlAtomicExchangePointer(IN VOLATILE PVOID *Address,
|
||||||
IN PVOID Exchange)
|
IN PVOID Exchange)
|
||||||
{
|
{
|
||||||
|
__sync_synchronize();
|
||||||
return (PVOID)__sync_lock_test_and_set(Address, Exchange);
|
return (PVOID)__sync_lock_test_and_set(Address, Exchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <xtos.h>
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user