diff --git a/CMakeLists.txt b/CMakeLists.txt index 72c9fc8..67ab6ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ if("${MHTD}" STREQUAL "MHTD-NOTFOUND") endif() find_package(OpenSSL REQUIRED) +include_directories(${OPENSSL_INCLUDE_DIR}) #set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_CONFIGURATION_TYPES "RELEASE;STATIC") diff --git a/minethd.cpp b/minethd.cpp index 181421a..02fe275 100644 --- a/minethd.cpp +++ b/minethd.cpp @@ -38,12 +38,25 @@ void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id) #else #include +#if defined(__APPLE__) +#include +#include +#define SYSCTL_CORE_COUNT "machdep.cpu.core_count" +#endif + void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id) { +#if defined(__APPLE__) + thread_port_t mach_thread; + 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); +#else cpu_set_t mn; CPU_ZERO(&mn); CPU_SET(cpu_id, &mn); pthread_setaffinity_np(h, sizeof(cpu_set_t), &mn); +#endif } #endif // _WIN32 @@ -177,7 +190,12 @@ std::vector* minethd::thread_starter(miner_work& pWork) minethd* thd = new minethd(pWork, i, &vGpuData[i]); if(cfg.cpu_aff >= 0) + { +#if defined(__APPLE__) + printer::inst()->print_msg(L1, "WARNING on MacOS thread affinity is only advisory."); +#endif thd_setaffinity(thd->oWorkThd.native_handle(), cfg.cpu_aff); + } pvThreads->push_back(thd); if(cfg.cpu_aff >= 0) diff --git a/msgstruct.h b/msgstruct.h index 27ab9ab..621f703 100644 --- a/msgstruct.h +++ b/msgstruct.h @@ -1,4 +1,5 @@ #pragma once +#include #include #include diff --git a/socks.h b/socks.h index 2d7c94f..7768706 100644 --- a/socks.h +++ b/socks.h @@ -76,7 +76,12 @@ inline void sock_close(SOCKET s) inline const char* sock_strerror(char* buf, size_t len) { buf[0] = '\0'; +#if defined(__APPLE__) + strerror_r(errno, buf, len); + return buf; +#else return strerror_r(errno, buf, len); +#endif } inline const char* sock_gai_strerror(int err, char* buf, size_t len)