diff --git a/src/crypto/ghostrider/ghostrider.cpp b/src/crypto/ghostrider/ghostrider.cpp index 28fdead83..79241bd3d 100644 --- a/src/crypto/ghostrider/ghostrider.cpp +++ b/src/crypto/ghostrider/ghostrider.cpp @@ -90,7 +90,7 @@ CORE_HASH(14, whirlpool ); #undef CORE_HASH -typedef void (*core_hash_func)(const uint8_t* data, size_t size, uint8_t* output); +using core_hash_func = void (*)(const uint8_t* data, size_t size, uint8_t* output); static const core_hash_func core_hash[15] = { h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14 }; namespace xmrig @@ -169,6 +169,8 @@ static struct AlgoTune struct HelperThread { + XMRIG_DISABLE_COPY_MOVE_DEFAULT(HelperThread) + HelperThread(hwloc_bitmap_t cpu_set, int priority, bool is8MB) : m_cpuSet(cpu_set), m_priority(priority), m_is8MB(is8MB) { uv_mutex_init(&m_mutex); @@ -198,14 +200,17 @@ struct HelperThread struct TaskBase { - virtual ~TaskBase() {} - virtual void run() = 0; + XMRIG_DISABLE_COPY_MOVE(TaskBase) + + TaskBase() = default; + virtual ~TaskBase() = default; + virtual void run() = 0; }; template struct Task : TaskBase { - inline Task(T&& task) : m_task(std::move(task)) + explicit inline Task(T&& task) : m_task(std::move(task)) { static_assert(sizeof(Task) <= 128, "Task struct is too large"); } @@ -223,7 +228,7 @@ struct HelperThread inline void launch_task(T&& task) { uv_mutex_lock(&m_mutex); - new (&m_tasks[m_numTasks++]) Task(std::move(task)); + new (&m_tasks[m_numTasks++]) Task(std::forward(task)); uv_cond_signal(&m_cond); uv_mutex_unlock(&m_mutex); } @@ -294,7 +299,7 @@ void benchmark() hwloc_topology_t topology = reinterpret_cast(Cpu::info())->topology(); hwloc_obj_t pu = hwloc_get_pu_obj_by_os_index(topology, thread_index1); - hwloc_obj_t pu2; + hwloc_obj_t pu2 = nullptr; hwloc_get_closest_objs(topology, pu, &pu2, 1); uint32_t thread_index2 = pu2 ? pu2->os_index : thread_index1; @@ -585,9 +590,13 @@ void hash_octa(const uint8_t* data, size_t size, uint8_t* output, cryptonight_ct uint8_t tmp[64 * N]; if (helper && (tune[cn_indices[0]].threads == 2) && (tune[cn_indices[1]].threads == 2) && (tune[cn_indices[2]].threads == 2)) { - const size_t n = N / 2; + constexpr size_t n = N / 2; + + helper->launch_task([av, data, size, &ctx_memory, ctx, &cn_indices, &core_indices, &tmp, output, tune]() { +# ifdef _MSC_VER + constexpr size_t n = N / 2; +# endif - helper->launch_task([n, av, data, size, &ctx_memory, ctx, &cn_indices, &core_indices, &tmp, output, tune]() { const uint8_t* input = data; size_t input_size = size;