Some FreeBSD fixes
This commit is contained in:
parent
1af1ba6b5f
commit
9c0fe73102
4 changed files with 23 additions and 4 deletions
|
@ -122,6 +122,14 @@ elseif (APPLE)
|
||||||
src/Mem_unix.cpp
|
src/Mem_unix.cpp
|
||||||
src/Platform_mac.cpp
|
src/Platform_mac.cpp
|
||||||
)
|
)
|
||||||
|
elseif (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
||||||
|
set(SOURCES_OS
|
||||||
|
src/App_unix.cpp
|
||||||
|
src/Cpu_unix.cpp
|
||||||
|
src/Mem_unix.cpp
|
||||||
|
src/Platform_unix.cpp
|
||||||
|
)
|
||||||
|
set(EXTRA_LIBS pthread kvm)
|
||||||
else()
|
else()
|
||||||
set(SOURCES_OS
|
set(SOURCES_OS
|
||||||
src/App_unix.cpp
|
src/App_unix.cpp
|
||||||
|
|
|
@ -20,8 +20,12 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/cpuset.h>
|
||||||
|
#include <pthread_np.h>
|
||||||
|
#endif
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -30,6 +34,9 @@
|
||||||
|
|
||||||
#include "Cpu.h"
|
#include "Cpu.h"
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
typedef cpuset_t cpu_set_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
void Cpu::init()
|
void Cpu::init()
|
||||||
{
|
{
|
||||||
|
@ -53,7 +60,9 @@ void Cpu::setAffinity(int id, uint64_t mask)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
|
#ifndef __FreeBSD__
|
||||||
sched_setaffinity(0, sizeof(&set), &set);
|
sched_setaffinity(0, sizeof(&set), &set);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
pthread_setaffinity_np(pthread_self(), sizeof(&set), &set);
|
pthread_setaffinity_np(pthread_self(), sizeof(&set), &set);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,10 +51,11 @@ bool Mem::allocate(int algo, int threads, bool doubleHash, bool enabled)
|
||||||
|
|
||||||
# if defined(__APPLE__)
|
# if defined(__APPLE__)
|
||||||
m_memory = static_cast<uint8_t*>(mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, VM_FLAGS_SUPERPAGE_SIZE_2MB, 0));
|
m_memory = static_cast<uint8_t*>(mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, VM_FLAGS_SUPERPAGE_SIZE_2MB, 0));
|
||||||
|
# elif defined(__FreeBSD__)
|
||||||
|
m_memory = static_cast<uint8_t*>(mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_ALIGNED_SUPER | MAP_PREFAULT_READ, -1, 0));
|
||||||
# else
|
# else
|
||||||
m_memory = static_cast<uint8_t*>(mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, 0, 0));
|
m_memory = static_cast<uint8_t*>(mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, 0, 0));
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
if (m_memory == MAP_FAILED) {
|
if (m_memory == MAP_FAILED) {
|
||||||
m_memory = static_cast<uint8_t*>(_mm_malloc(size, 16));
|
m_memory = static_cast<uint8_t*>(_mm_malloc(size, 16));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -116,6 +115,7 @@ void Platform::setThreadPriority(int priority)
|
||||||
|
|
||||||
setpriority(PRIO_PROCESS, 0, prio);
|
setpriority(PRIO_PROCESS, 0, prio);
|
||||||
|
|
||||||
|
#ifdef SCHED_IDLE
|
||||||
if (priority == 0) {
|
if (priority == 0) {
|
||||||
sched_param param;
|
sched_param param;
|
||||||
param.sched_priority = 0;
|
param.sched_priority = 0;
|
||||||
|
@ -124,4 +124,5 @@ void Platform::setThreadPriority(int priority)
|
||||||
sched_setscheduler(0, SCHED_BATCH, ¶m);
|
sched_setscheduler(0, SCHED_BATCH, ¶m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue