Use MsrItem::kNoMask.

This commit is contained in:
XMRig 2019-12-19 03:20:48 +07:00
parent a1e8c1353f
commit 12fb27e2cf
No known key found for this signature in database
GPG key ID: 446A53638BE94409
4 changed files with 8 additions and 5 deletions

View file

@ -92,7 +92,7 @@ static MsrItem rdmsr(uint32_t reg)
static bool wrmsr_on_cpu(uint32_t reg, uint32_t cpu, uint64_t value, uint64_t mask)
{
// If a bit in mask is set to 1, use new value, otherwise use old value
if (mask != uint64_t(-1)) {
if (mask != MsrItem::kNoMask) {
uint64_t old_value;
if (rdmsr_on_cpu(reg, cpu, old_value)) {
value = (value & mask) | (old_value & ~mask);

View file

@ -227,7 +227,7 @@ static bool wrmsr(HANDLE driver, uint32_t reg, uint64_t value, uint64_t mask)
static_assert(sizeof(input) == 12, "Invalid struct size for WinRing0 driver");
// If a bit in mask is set to 1, use new value, otherwise use old value
if (mask != uint64_t(-1)) {
if (mask != MsrItem::kNoMask) {
uint64_t old_value;
if (rdmsr(driver, reg, old_value)) {
value = (value & mask) | (old_value & ~mask);

View file

@ -45,7 +45,7 @@ xmrig::MsrItem::MsrItem(const rapidjson::Value &value)
m_reg = strtoul(kv[0], nullptr, 0);
m_value = strtoul(kv[1], nullptr, 0);
m_mask = (kv.size() > 2) ? strtoul(kv[2], nullptr, 0) : uint64_t(-1);
m_mask = (kv.size() > 2) ? strtoul(kv[2], nullptr, 0) : kNoMask;
}

View file

@ -31,6 +31,7 @@
#include "base/tools/String.h"
#include <limits>
#include <vector>
@ -44,8 +45,10 @@ class RxDataset;
class MsrItem
{
public:
constexpr static uint64_t kNoMask = std::numeric_limits<uint64_t>::max();
inline MsrItem() = default;
inline MsrItem(uint32_t reg, uint64_t value, uint64_t mask = uint64_t(-1)) : m_reg(reg), m_value(value), m_mask(mask) {}
inline MsrItem(uint32_t reg, uint64_t value, uint64_t mask = kNoMask) : m_reg(reg), m_value(value), m_mask(mask) {}
MsrItem(const rapidjson::Value &value);
@ -60,7 +63,7 @@ public:
private:
uint32_t m_reg = 0;
uint64_t m_value = 0;
uint64_t m_mask = uint64_t(-1);
uint64_t m_mask = kNoMask;
};