diff --git a/crypto/cryptonight_common.cpp b/crypto/cryptonight_common.cpp index 63ce3a4..9d03ed7 100644 --- a/crypto/cryptonight_common.cpp +++ b/crypto/cryptonight_common.cpp @@ -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); diff --git a/minethd.cpp b/minethd.cpp index 199779e..ae97133 100644 --- a/minethd.cpp +++ b/minethd.cpp @@ -42,8 +42,11 @@ void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id) #include #include #define SYSCTL_CORE_COUNT "machdep.cpu.core_count" +#elif defined(__FreeBSD__) +#include #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); diff --git a/socks.h b/socks.h index 7768706..a481a98 100644 --- a/socks.h +++ b/socks.h @@ -60,6 +60,9 @@ inline const char* sock_gai_strerror(int err, char* buf, size_t len) #include /* Needed for close() */ #include #include +#if defined(__FreeBSD__) +#include /* 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