mirror of
https://github.com/jwinterm/xmr-stak.git
synced 2026-10-17 05:41:41 +02:00
Add FreeBSD support
This commit is contained in:
@@ -146,6 +146,9 @@ cryptonight_ctx* cryptonight_alloc_ctx(size_t use_fast_mem, size_t use_mlock, al
|
||||
#if defined(__APPLE__)
|
||||
ptr->long_state = (uint8_t*)mmap(0, MEMORY, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANON, VM_FLAGS_SUPERPAGE_SIZE_2MB, 0);
|
||||
#elif defined(__FreeBSD__)
|
||||
ptr->long_state = (uint8_t*)mmap(0, MEMORY, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_ALIGNED_SUPER | MAP_PREFAULT_READ, -1, 0);
|
||||
#else
|
||||
ptr->long_state = (uint8_t*)mmap(0, MEMORY, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, 0, 0);
|
||||
|
||||
@@ -42,8 +42,11 @@ void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id)
|
||||
#include <mach/thread_policy.h>
|
||||
#include <mach/thread_act.h>
|
||||
#define SYSCTL_CORE_COUNT "machdep.cpu.core_count"
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
|
||||
|
||||
void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id)
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
@@ -51,6 +54,11 @@ void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id)
|
||||
thread_affinity_policy_data_t policy = { cpu_id };
|
||||
mach_thread = pthread_mach_thread_np(h);
|
||||
thread_policy_set(mach_thread, THREAD_AFFINITY_POLICY, (thread_policy_t)&policy, 1);
|
||||
#elif defined(__FreeBSD__)
|
||||
cpuset_t mn;
|
||||
CPU_ZERO(&mn);
|
||||
CPU_SET(cpu_id, &mn);
|
||||
pthread_setaffinity_np(h, sizeof(cpuset_t), &mn);
|
||||
#else
|
||||
cpu_set_t mn;
|
||||
CPU_ZERO(&mn);
|
||||
|
||||
@@ -60,6 +60,9 @@ inline const char* sock_gai_strerror(int err, char* buf, size_t len)
|
||||
#include <unistd.h> /* Needed for close() */
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#if defined(__FreeBSD__)
|
||||
#include <netinet/in.h> /* Needed for IPPROTO_TCP */
|
||||
#endif
|
||||
|
||||
inline void sock_init() {}
|
||||
typedef int SOCKET;
|
||||
@@ -76,7 +79,7 @@ inline void sock_close(SOCKET s)
|
||||
inline const char* sock_strerror(char* buf, size_t len)
|
||||
{
|
||||
buf[0] = '\0';
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
strerror_r(errno, buf, len);
|
||||
return buf;
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user