mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-23 12:09:22 +00:00
Code cleanup.
This commit is contained in:
parent
5999dccd57
commit
0fa5db8fa3
2 changed files with 14 additions and 4 deletions
|
@ -400,6 +400,10 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith
|
|||
|
||||
void xmrig::HwlocCpuInfo::setThreads(size_t threads)
|
||||
{
|
||||
if (!threads) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_threads = threads;
|
||||
|
||||
if (m_units.size() != m_threads) {
|
||||
|
|
|
@ -37,6 +37,14 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
static int msr_open(int32_t cpu, int flags)
|
||||
{
|
||||
const auto name = fmt::format("/dev/cpu/{}/msr", cpu < 0 ? Cpu::info()->units().front() : cpu);
|
||||
|
||||
return open(name.c_str(), flags);
|
||||
}
|
||||
|
||||
|
||||
class MsrPrivate
|
||||
{
|
||||
public:
|
||||
|
@ -85,8 +93,7 @@ bool xmrig::Msr::write(Callback &&callback)
|
|||
|
||||
bool xmrig::Msr::rdmsr(uint32_t reg, int32_t cpu, uint64_t &value) const
|
||||
{
|
||||
const auto name = fmt::format("/dev/cpu/{}/msr", cpu < 0 ? 0 : cpu);
|
||||
const int fd = open(name.c_str(), O_RDONLY);
|
||||
const int fd = msr_open(cpu, O_RDONLY);
|
||||
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
|
@ -101,8 +108,7 @@ bool xmrig::Msr::rdmsr(uint32_t reg, int32_t cpu, uint64_t &value) const
|
|||
|
||||
bool xmrig::Msr::wrmsr(uint32_t reg, uint64_t value, int32_t cpu)
|
||||
{
|
||||
const auto name = fmt::format("/dev/cpu/{}/msr", cpu < 0 ? 0 : cpu);
|
||||
int fd = open(name.c_str(), O_WRONLY);
|
||||
const int fd = msr_open(cpu, O_WRONLY);
|
||||
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue