Implement RtlInterlockedCompareExchangePointer() and RtlInterlockedDecrementLongPtr() atomic routines
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
This commit is contained in:
parent
33903c4374
commit
1f8026db2f
@ -230,6 +230,16 @@ 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
|
||||
RtlInterlockedDecrementLongPtr(IN VOLATILE PLONG_PTR Addend);
|
||||
|
||||
XTCDECL
|
||||
BOOLEAN
|
||||
RtlListEmpty(PLIST_ENTRY ListHead);
|
||||
|
@ -34,6 +34,7 @@ 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/memory.c
|
||||
${XTOSKRNL_SOURCE_DIR}/rtl/plist.c
|
||||
${XTOSKRNL_SOURCE_DIR}/rtl/string.c
|
||||
|
52
xtoskrnl/rtl/intrin.c
Normal file
52
xtoskrnl/rtl/intrin.c
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 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
|
||||
RtlInterlockedDecrementLongPtr(IN VOLATILE PLONG_PTR Addend)
|
||||
{
|
||||
return (LONG_PTR)__sync_sub_and_fetch(Addend, 1);
|
||||
}
|
Loading…
Reference in New Issue
Block a user