mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-11 09:22:48 -05:00
Fix linux build.
This commit is contained in:
@@ -22,3 +22,38 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#include "Cpu.h"
|
||||
|
||||
|
||||
void Cpu::init()
|
||||
{
|
||||
# ifdef XMRIG_NO_LIBCPUID
|
||||
m_totalThreads = sysconf(_SC_NPROCESSORS_CONF);
|
||||
# endif
|
||||
|
||||
initCommon();
|
||||
}
|
||||
|
||||
|
||||
void Cpu::setAffinity(int id, unsigned long mask)
|
||||
{
|
||||
cpu_set_t set;
|
||||
CPU_ZERO(&set);
|
||||
|
||||
for (int i = 0; i < m_totalThreads; i++) {
|
||||
if (mask & (1UL << i)) {
|
||||
CPU_SET(i, &set);
|
||||
}
|
||||
}
|
||||
|
||||
if (id == -1) {
|
||||
sched_setaffinity(0, sizeof(&set), &set);
|
||||
} else {
|
||||
pthread_setaffinity_np(pthread_self(), sizeof(&set), &set);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user