Fix linux build.

This commit is contained in:
XMRig 2017-06-14 16:11:01 +03:00
parent 8ebb659cd6
commit 5af169fd7b
11 changed files with 220 additions and 3 deletions

View file

@ -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);
}
}