forked from xt-sys/exectos
More routines for performing atomic bitwise AND/OR/XOR operations
This commit is contained in:
parent
5a86d61b78
commit
9e5fb84412
@ -14,6 +14,26 @@
|
||||
#include <xttypes.h>
|
||||
|
||||
|
||||
XTFASTCALL
|
||||
CHAR
|
||||
RtlAtomicAnd8(IN VOLATILE PCHAR Address,
|
||||
IN CHAR Mask);
|
||||
|
||||
XTFASTCALL
|
||||
SHORT
|
||||
RtlAtomicAnd16(IN VOLATILE PSHORT Address,
|
||||
IN SHORT Mask);
|
||||
|
||||
XTFASTCALL
|
||||
LONG
|
||||
RtlAtomicAnd32(IN VOLATILE PLONG Address,
|
||||
IN LONG Mask);
|
||||
|
||||
XTFASTCALL
|
||||
LONGLONG
|
||||
RtlAtomicAnd64(IN VOLATILE PLONGLONG Address,
|
||||
IN LONGLONG Mask);
|
||||
|
||||
XTFASTCALL
|
||||
CHAR
|
||||
RtlAtomicCompareExchange8(IN VOLATILE PCHAR Address,
|
||||
@ -121,6 +141,46 @@ XTFASTCALL
|
||||
LONGLONG
|
||||
RtlAtomicIncrement64(IN VOLATILE PLONGLONG Address);
|
||||
|
||||
XTFASTCALL
|
||||
CHAR
|
||||
RtlAtomicOr8(IN VOLATILE PCHAR Address,
|
||||
IN CHAR Mask);
|
||||
|
||||
XTFASTCALL
|
||||
SHORT
|
||||
RtlAtomicOr16(IN VOLATILE PSHORT Address,
|
||||
IN SHORT Mask);
|
||||
|
||||
XTFASTCALL
|
||||
LONG
|
||||
RtlAtomicOr32(IN VOLATILE PLONG Address,
|
||||
IN LONG Mask);
|
||||
|
||||
XTFASTCALL
|
||||
LONGLONG
|
||||
RtlAtomicOr64(IN VOLATILE PLONGLONG Address,
|
||||
IN LONGLONG Mask);
|
||||
|
||||
XTFASTCALL
|
||||
CHAR
|
||||
RtlAtomicXor8(IN VOLATILE PCHAR Address,
|
||||
IN CHAR Mask);
|
||||
|
||||
XTFASTCALL
|
||||
SHORT
|
||||
RtlAtomicXor16(IN VOLATILE PSHORT Address,
|
||||
IN SHORT Mask);
|
||||
|
||||
XTFASTCALL
|
||||
LONG
|
||||
RtlAtomicXor32(IN VOLATILE PLONG Address,
|
||||
IN LONG Mask);
|
||||
|
||||
XTFASTCALL
|
||||
LONGLONG
|
||||
RtlAtomicXor64(IN VOLATILE PLONGLONG Address,
|
||||
IN LONGLONG Mask);
|
||||
|
||||
XTAPI
|
||||
SIZE_T
|
||||
RtlCompareMemory(IN PCVOID LeftBuffer,
|
||||
|
@ -9,6 +9,90 @@
|
||||
#include <xtos.h>
|
||||
|
||||
|
||||
/**
|
||||
* Performs an atomic bitwise AND operation on the 8-bit value.
|
||||
*
|
||||
* @param Address
|
||||
* Supplies the address of the value on which the bitwise AND operation is to be performed.
|
||||
*
|
||||
* @param Mask
|
||||
* Supplies the mask with which the bitwise AND operation is to be performed
|
||||
*
|
||||
* @return This routine returns the initial value at the given address.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTFASTCALL
|
||||
CHAR
|
||||
RtlAtomicAnd8(IN VOLATILE PCHAR Address,
|
||||
IN CHAR Mask)
|
||||
{
|
||||
return __sync_fetch_and_and(Address, Mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an atomic bitwise AND operation on the 16-bit value.
|
||||
*
|
||||
* @param Address
|
||||
* Supplies the address of the value on which the bitwise AND operation is to be performed.
|
||||
*
|
||||
* @param Mask
|
||||
* Supplies the mask with which the bitwise AND operation is to be performed
|
||||
*
|
||||
* @return This routine returns the initial value at the given address.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTFASTCALL
|
||||
SHORT
|
||||
RtlAtomicAnd16(IN VOLATILE PSHORT Address,
|
||||
IN SHORT Mask)
|
||||
{
|
||||
return __sync_fetch_and_and(Address, Mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an atomic bitwise AND operation on the 32-bit value.
|
||||
*
|
||||
* @param Address
|
||||
* Supplies the address of the value on which the bitwise AND operation is to be performed.
|
||||
*
|
||||
* @param Mask
|
||||
* Supplies the mask with which the bitwise AND operation is to be performed
|
||||
*
|
||||
* @return This routine returns the initial value at the given address.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTFASTCALL
|
||||
LONG
|
||||
RtlAtomicAnd32(IN VOLATILE PLONG Address,
|
||||
IN LONG Mask)
|
||||
{
|
||||
return __sync_fetch_and_and(Address, Mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an atomic bitwise AND operation on the 64-bit value.
|
||||
*
|
||||
* @param Address
|
||||
* Supplies the address of the value on which the bitwise AND operation is to be performed.
|
||||
*
|
||||
* @param Mask
|
||||
* Supplies the mask with which the bitwise AND operation is to be performed
|
||||
*
|
||||
* @return This routine returns the initial value at the given address.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTFASTCALL
|
||||
LONGLONG
|
||||
RtlAtomicAnd64(IN VOLATILE PLONGLONG Address,
|
||||
IN LONGLONG Mask)
|
||||
{
|
||||
return __sync_fetch_and_and(Address, Mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs atomically compare exchange operation on the 8-bit value.
|
||||
*
|
||||
@ -458,3 +542,171 @@ RtlAtomicIncrement64(IN VOLATILE PLONGLONG Address)
|
||||
{
|
||||
return __sync_add_and_fetch(Address, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an atomic bitwise OR operation on the 8-bit value.
|
||||
*
|
||||
* @param Address
|
||||
* Supplies the address of the value on which the bitwise OR operation is to be performed.
|
||||
*
|
||||
* @param Mask
|
||||
* Supplies the mask with which the bitwise OR operation is to be performed
|
||||
*
|
||||
* @return This routine returns the initial value at the given address.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTFASTCALL
|
||||
CHAR
|
||||
RtlAtomicOr8(IN VOLATILE PCHAR Address,
|
||||
IN CHAR Mask)
|
||||
{
|
||||
return __sync_fetch_and_or(Address, Mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an atomic bitwise OR operation on the 16-bit value.
|
||||
*
|
||||
* @param Address
|
||||
* Supplies the address of the value on which the bitwise OR operation is to be performed.
|
||||
*
|
||||
* @param Mask
|
||||
* Supplies the mask with which the bitwise OR operation is to be performed
|
||||
*
|
||||
* @return This routine returns the initial value at the given address.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTFASTCALL
|
||||
SHORT
|
||||
RtlAtomicOr16(IN VOLATILE PSHORT Address,
|
||||
IN SHORT Mask)
|
||||
{
|
||||
return __sync_fetch_and_or(Address, Mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an atomic bitwise OR operation on the 32-bit value.
|
||||
*
|
||||
* @param Address
|
||||
* Supplies the address of the value on which the bitwise OR operation is to be performed.
|
||||
*
|
||||
* @param Mask
|
||||
* Supplies the mask with which the bitwise OR operation is to be performed
|
||||
*
|
||||
* @return This routine returns the initial value at the given address.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTFASTCALL
|
||||
LONG
|
||||
RtlAtomicOr32(IN VOLATILE PLONG Address,
|
||||
IN LONG Mask)
|
||||
{
|
||||
return __sync_fetch_and_or(Address, Mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an atomic bitwise OR operation on the 64-bit value.
|
||||
*
|
||||
* @param Address
|
||||
* Supplies the address of the value on which the bitwise OR operation is to be performed.
|
||||
*
|
||||
* @param Mask
|
||||
* Supplies the mask with which the bitwise OR operation is to be performed
|
||||
*
|
||||
* @return This routine returns the initial value at the given address.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTFASTCALL
|
||||
LONGLONG
|
||||
RtlAtomicOr64(IN VOLATILE PLONGLONG Address,
|
||||
IN LONGLONG Mask)
|
||||
{
|
||||
return __sync_fetch_and_or(Address, Mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an atomic bitwise XOR operation on the 8-bit value.
|
||||
*
|
||||
* @param Address
|
||||
* Supplies the address of the value on which the bitwise XOR operation is to be performed.
|
||||
*
|
||||
* @param Mask
|
||||
* Supplies the mask with which the bitwise XOR operation is to be performed
|
||||
*
|
||||
* @return This routine returns the initial value at the given address.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTFASTCALL
|
||||
CHAR
|
||||
RtlAtomicXor8(IN VOLATILE PCHAR Address,
|
||||
IN CHAR Mask)
|
||||
{
|
||||
return __sync_fetch_and_xor(Address, Mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an atomic bitwise XOR operation on the 16-bit value.
|
||||
*
|
||||
* @param Address
|
||||
* Supplies the address of the value on which the bitwise XOR operation is to be performed.
|
||||
*
|
||||
* @param Mask
|
||||
* Supplies the mask with which the bitwise XOR operation is to be performed
|
||||
*
|
||||
* @return This routine returns the initial value at the given address.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTFASTCALL
|
||||
SHORT
|
||||
RtlAtomicXor16(IN VOLATILE PSHORT Address,
|
||||
IN SHORT Mask)
|
||||
{
|
||||
return __sync_fetch_and_xor(Address, Mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an atomic bitwise XOR operation on the 32-bit value.
|
||||
*
|
||||
* @param Address
|
||||
* Supplies the address of the value on which the bitwise XOR operation is to be performed.
|
||||
*
|
||||
* @param Mask
|
||||
* Supplies the mask with which the bitwise XOR operation is to be performed
|
||||
*
|
||||
* @return This routine returns the initial value at the given address.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTFASTCALL
|
||||
LONG
|
||||
RtlAtomicXor32(IN VOLATILE PLONG Address,
|
||||
IN LONG Mask)
|
||||
{
|
||||
return __sync_fetch_and_xor(Address, Mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an atomic bitwise XOR operation on the 64-bit value.
|
||||
*
|
||||
* @param Address
|
||||
* Supplies the address of the value on which the bitwise XOR operation is to be performed.
|
||||
*
|
||||
* @param Mask
|
||||
* Supplies the mask with which the bitwise XOR operation is to be performed
|
||||
*
|
||||
* @return This routine returns the initial value at the given address.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTFASTCALL
|
||||
LONGLONG
|
||||
RtlAtomicXor64(IN VOLATILE PLONGLONG Address,
|
||||
IN LONGLONG Mask)
|
||||
{
|
||||
return __sync_fetch_and_xor(Address, Mask);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user