58 lines
2.0 KiB
C++

#pragma once
#include "ehs/Types.h"
namespace ehs
{
class Lock
{
/// Does an atomic lock add operation.
/// @param [in] a The address of the value to add to.
/// @param [in] b The value to add from.
static void Add(UInt_64* a, UInt_64 b);
/// Does an atomic lock subtract operation.
/// @param [in] a The address of the value to subtract to.
/// @param [in] b The value to subtract from.
static void Sub(UInt_64* a, UInt_64 b);
/// Does an atomic lock compare exchange operation.
/// @param [in/out] a The address of the value to compare with the value of b.
/// @param [in/out] b The address of the value to compare with the value of a.
/// @param [in] setter The address of the value to set the value of b to when a and b are equal.
/// @returns True if equal.
/// @note If a and b are not equal the value at the address of a will be set to the value at the address of b.
static bool CmpXchg(UInt_64* a, UInt_64* b, UInt_64 setter);
/// Does an atomic lock and operation.
/// @param [in] a The address of the first value to compare.
/// @param [in] b The second value to compare.
static void And(UInt_64* a, UInt_64 b);
/// Does an atomic lock or operation.
/// @param [in] a The address of the first value to compare.
/// @param [in] b The second value to compare.
static void Or(UInt_64* a, UInt_64 b);
/// Does an atomic lock xor operation.
/// @param [in] a The address of the first value to compare.
/// @param [in] b The second value to compare.
static void XOr(UInt_64* a, UInt_64 b);
/// Does an atomic lock increase operation.
/// @param [in] a The address of the value to increase.
static void Inc(UInt_64* a);
/// Does an atomic lock decrease operation.
/// @param [in] a The address of the value to decrease.
static void Dec(UInt_64* a);
/// Does an atomic lock not operation.
/// @param [in] a The address of the value to not.
static void Not(UInt_64* a);
/// Does an atomic lock negate operation.
/// @param [in] a The address of the value to negate.
static void Neg(UInt_64* a);
};
}