From 5958490c23e0ecec3dcdd618d54ba2b8c93ae49f Mon Sep 17 00:00:00 2001 From: SChernykh Date: Fri, 13 Aug 2021 12:02:03 +0200 Subject: [PATCH] Fixed Termux build --- src/base/net/stratum/DaemonClient.cpp | 2 +- src/crypto/cn/CnHash.cpp | 70 ++++++++++++++++----------- src/crypto/cn/CnHash.h | 6 ++- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/src/base/net/stratum/DaemonClient.cpp b/src/base/net/stratum/DaemonClient.cpp index 76f30c65..3a1a3abf 100644 --- a/src/base/net/stratum/DaemonClient.cpp +++ b/src/base/net/stratum/DaemonClient.cpp @@ -730,7 +730,7 @@ void xmrig::DaemonClient::ZMQRead(ssize_t nread, const uv_buf_t* buf) switch (m_ZMQConnectionState) { case ZMQ_GREETING_1: if (m_ZMQRecvBuf.size() >= kZMQGreetingSize1) { - if ((m_ZMQRecvBuf[0] == -1) && (m_ZMQRecvBuf[9] == 127) && (m_ZMQRecvBuf[10] == 3)) { + if ((m_ZMQRecvBuf[0] == static_cast(-1)) && (m_ZMQRecvBuf[9] == 127) && (m_ZMQRecvBuf[10] == 3)) { ZMQWrite(kZMQGreeting + kZMQGreetingSize1, sizeof(kZMQGreeting) - kZMQGreetingSize1); m_ZMQConnectionState = ZMQ_GREETING_2; break; diff --git a/src/crypto/cn/CnHash.cpp b/src/crypto/cn/CnHash.cpp index e7493aec..d085bf63 100644 --- a/src/crypto/cn/CnHash.cpp +++ b/src/crypto/cn/CnHash.cpp @@ -40,27 +40,35 @@ #endif -#define ADD_FN(algo) \ - m_map[algo][AV_SINGLE][Assembly::NONE] = cryptonight_single_hash; \ - m_map[algo][AV_SINGLE_SOFT][Assembly::NONE] = cryptonight_single_hash; \ - m_map[algo][AV_DOUBLE][Assembly::NONE] = cryptonight_double_hash; \ - m_map[algo][AV_DOUBLE_SOFT][Assembly::NONE] = cryptonight_double_hash; \ - m_map[algo][AV_TRIPLE][Assembly::NONE] = cryptonight_triple_hash; \ - m_map[algo][AV_TRIPLE_SOFT][Assembly::NONE] = cryptonight_triple_hash; \ - m_map[algo][AV_QUAD][Assembly::NONE] = cryptonight_quad_hash; \ - m_map[algo][AV_QUAD_SOFT][Assembly::NONE] = cryptonight_quad_hash; \ - m_map[algo][AV_PENTA][Assembly::NONE] = cryptonight_penta_hash; \ - m_map[algo][AV_PENTA_SOFT][Assembly::NONE] = cryptonight_penta_hash; +#define ADD_FN(algo) do { \ + cn_hash_fun_array* arr = new cn_hash_fun_array{}; \ + auto& data = arr->data; \ + data[AV_SINGLE][Assembly::NONE] = cryptonight_single_hash; \ + data[AV_SINGLE_SOFT][Assembly::NONE] = cryptonight_single_hash; \ + data[AV_DOUBLE][Assembly::NONE] = cryptonight_double_hash; \ + data[AV_DOUBLE_SOFT][Assembly::NONE] = cryptonight_double_hash; \ + data[AV_TRIPLE][Assembly::NONE] = cryptonight_triple_hash; \ + data[AV_TRIPLE_SOFT][Assembly::NONE] = cryptonight_triple_hash; \ + data[AV_QUAD][Assembly::NONE] = cryptonight_quad_hash; \ + data[AV_QUAD_SOFT][Assembly::NONE] = cryptonight_quad_hash; \ + data[AV_PENTA][Assembly::NONE] = cryptonight_penta_hash; \ + data[AV_PENTA_SOFT][Assembly::NONE] = cryptonight_penta_hash; \ + m_map.insert(std::make_pair(algo, arr)); \ + } while (0) #ifdef XMRIG_FEATURE_ASM -# define ADD_FN_ASM(algo) \ - m_map[algo][AV_SINGLE][Assembly::INTEL] = cryptonight_single_hash_asm; \ - m_map[algo][AV_SINGLE][Assembly::RYZEN] = cryptonight_single_hash_asm; \ - m_map[algo][AV_SINGLE][Assembly::BULLDOZER] = cryptonight_single_hash_asm; \ - m_map[algo][AV_DOUBLE][Assembly::INTEL] = cryptonight_double_hash_asm; \ - m_map[algo][AV_DOUBLE][Assembly::RYZEN] = cryptonight_double_hash_asm; \ - m_map[algo][AV_DOUBLE][Assembly::BULLDOZER] = cryptonight_double_hash_asm; +# define ADD_FN_ASM(algo) do { \ + cn_hash_fun_array* arr = new cn_hash_fun_array{}; \ + auto& data = arr->data; \ + data[AV_SINGLE][Assembly::INTEL] = cryptonight_single_hash_asm; \ + data[AV_SINGLE][Assembly::RYZEN] = cryptonight_single_hash_asm; \ + data[AV_SINGLE][Assembly::BULLDOZER] = cryptonight_single_hash_asm; \ + data[AV_DOUBLE][Assembly::INTEL] = cryptonight_double_hash_asm; \ + data[AV_DOUBLE][Assembly::RYZEN] = cryptonight_double_hash_asm; \ + data[AV_DOUBLE][Assembly::BULLDOZER] = cryptonight_double_hash_asm; \ + m_map.insert(std::make_pair(algo, arr)); \ + } while (0) namespace xmrig { @@ -288,17 +296,23 @@ xmrig::CnHash::CnHash() # endif # ifdef XMRIG_ALGO_ARGON2 - m_map[Algorithm::AR2_CHUKWA][AV_SINGLE][Assembly::NONE] = argon2::single_hash; - m_map[Algorithm::AR2_CHUKWA][AV_SINGLE_SOFT][Assembly::NONE] = argon2::single_hash; - m_map[Algorithm::AR2_CHUKWA_V2][AV_SINGLE][Assembly::NONE] = argon2::single_hash; - m_map[Algorithm::AR2_CHUKWA_V2][AV_SINGLE_SOFT][Assembly::NONE] = argon2::single_hash; - m_map[Algorithm::AR2_WRKZ][AV_SINGLE][Assembly::NONE] = argon2::single_hash; - m_map[Algorithm::AR2_WRKZ][AV_SINGLE_SOFT][Assembly::NONE] = argon2::single_hash; + m_map[Algorithm::AR2_CHUKWA] = new cn_hash_fun_array{}; + m_map[Algorithm::AR2_CHUKWA]->data[AV_SINGLE][Assembly::NONE] = argon2::single_hash; + m_map[Algorithm::AR2_CHUKWA]->data[AV_SINGLE_SOFT][Assembly::NONE] = argon2::single_hash; + + m_map[Algorithm::AR2_CHUKWA_V2] = new cn_hash_fun_array{}; + m_map[Algorithm::AR2_CHUKWA_V2]->data[AV_SINGLE][Assembly::NONE] = argon2::single_hash; + m_map[Algorithm::AR2_CHUKWA_V2]->data[AV_SINGLE_SOFT][Assembly::NONE] = argon2::single_hash; + + m_map[Algorithm::AR2_WRKZ] = new cn_hash_fun_array{}; + m_map[Algorithm::AR2_WRKZ]->data[AV_SINGLE][Assembly::NONE] = argon2::single_hash; + m_map[Algorithm::AR2_WRKZ]->data[AV_SINGLE_SOFT][Assembly::NONE] = argon2::single_hash; # endif # ifdef XMRIG_ALGO_ASTROBWT - m_map[Algorithm::ASTROBWT_DERO][AV_SINGLE][Assembly::NONE] = astrobwt::single_hash; - m_map[Algorithm::ASTROBWT_DERO][AV_SINGLE_SOFT][Assembly::NONE] = astrobwt::single_hash; + m_map[Algorithm::ASTROBWT_DERO] = new cn_hash_fun_array{}; + m_map[Algorithm::ASTROBWT_DERO]->data[AV_SINGLE][Assembly::NONE] = astrobwt::single_hash; + m_map[Algorithm::ASTROBWT_DERO]->data[AV_SINGLE_SOFT][Assembly::NONE] = astrobwt::single_hash; # endif # ifdef XMRIG_FEATURE_ASM @@ -340,11 +354,11 @@ xmrig::cn_hash_fun xmrig::CnHash::fn(const Algorithm &algorithm, AlgoVariant av, # endif # ifdef XMRIG_FEATURE_ASM - cn_hash_fun fun = it->second[av][Cpu::assembly(assembly)]; + cn_hash_fun fun = it->second->data[av][Cpu::assembly(assembly)]; if (fun) { return fun; } # endif - return it->second[av][Assembly::NONE]; + return it->second->data[av][Assembly::NONE]; } diff --git a/src/crypto/cn/CnHash.h b/src/crypto/cn/CnHash.h index 04ac4348..727ef9d5 100644 --- a/src/crypto/cn/CnHash.h +++ b/src/crypto/cn/CnHash.h @@ -62,8 +62,12 @@ public: static cn_hash_fun fn(const Algorithm &algorithm, AlgoVariant av, Assembly::Id assembly); + struct cn_hash_fun_array { + cn_hash_fun data[AV_MAX][Assembly::MAX]; + }; + private: - std::map m_map; + std::map m_map; };