diff --git a/cmake/flags.cmake b/cmake/flags.cmake index 10386b174..f55ddcdc2 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -10,7 +10,7 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "") endif() if (CMAKE_BUILD_TYPE STREQUAL "Release") - add_definitions(/DNDEBUG) + add_definitions(-DNDEBUG) endif() include(CheckSymbolExists) @@ -32,7 +32,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") - add_definitions(/DHAVE_ROTR) + add_definitions(-DHAVE_ROTR) endif() if (WIN32) @@ -49,16 +49,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") endif() - add_definitions(/D_GNU_SOURCE) - - if (${CMAKE_VERSION} VERSION_LESS "3.1.0") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - endif() - - #set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -gdwarf-2") - - add_definitions(/DHAVE_BUILTIN_CLEAR_CACHE) + add_definitions(-D_GNU_SOURCE -DHAVE_BUILTIN_CLEAR_CACHE) elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC) set(CMAKE_C_FLAGS_RELEASE "/MP /MT /O2 /Oi /DNDEBUG /GL") @@ -67,10 +58,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC) set(CMAKE_C_FLAGS_RELWITHDEBINFO "/MP /Ob1 /Zi /DRELWITHDEBINFO") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MP /Ob1 /Zi /DRELWITHDEBINFO") - add_definitions(/D_CRT_SECURE_NO_WARNINGS) - add_definitions(/D_CRT_NONSTDC_NO_WARNINGS) - add_definitions(/DNOMINMAX) - add_definitions(/DHAVE_ROTR) + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -DNOMINMAX -DHAVE_ROTR) elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang) @@ -92,7 +80,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang) check_symbol_exists("_rotr" "x86intrin.h" HAVE_ROTR) if (HAVE_ROTR) - add_definitions(/DHAVE_ROTR) + add_definitions(-DHAVE_ROTR) endif() endif() @@ -105,6 +93,6 @@ endif() if (NOT WIN32) check_symbol_exists("__builtin___clear_cache" "stdlib.h" HAVE_BUILTIN_CLEAR_CACHE) if (HAVE_BUILTIN_CLEAR_CACHE) - add_definitions(/DHAVE_BUILTIN_CLEAR_CACHE) + add_definitions(-DHAVE_BUILTIN_CLEAR_CACHE) endif() endif() diff --git a/src/backend/opencl/runners/OclBaseRunner.cpp b/src/backend/opencl/runners/OclBaseRunner.cpp index 9e2a48a9f..33ffda6a6 100644 --- a/src/backend/opencl/runners/OclBaseRunner.cpp +++ b/src/backend/opencl/runners/OclBaseRunner.cpp @@ -23,6 +23,9 @@ */ +#include + + #include "backend/opencl/runners/OclBaseRunner.h" #include "backend/opencl/cl/OclSource.h" #include "backend/opencl/OclCache.h" diff --git a/src/backend/opencl/runners/OclCnRunner.cpp b/src/backend/opencl/runners/OclCnRunner.cpp index 9c1e85440..a9a2913ab 100644 --- a/src/backend/opencl/runners/OclCnRunner.cpp +++ b/src/backend/opencl/runners/OclCnRunner.cpp @@ -16,6 +16,9 @@ * along with this program. If not, see . */ +#include + + #include "backend/opencl/runners/OclCnRunner.h" #include "backend/opencl/kernels/Cn0Kernel.h" #include "backend/opencl/kernels/Cn1Kernel.h" diff --git a/src/backend/opencl/runners/OclKawPowRunner.cpp b/src/backend/opencl/runners/OclKawPowRunner.cpp index 275e3f9a7..f31585d80 100644 --- a/src/backend/opencl/runners/OclKawPowRunner.cpp +++ b/src/backend/opencl/runners/OclKawPowRunner.cpp @@ -16,6 +16,9 @@ * along with this program. If not, see . */ +#include + + #include "backend/opencl/runners/OclKawPowRunner.h" #include "backend/common/Tags.h" #include "3rdparty/libethash/ethash_internal.h" diff --git a/src/backend/opencl/runners/OclRxJitRunner.cpp b/src/backend/opencl/runners/OclRxJitRunner.cpp index c106c94d5..26ed52b80 100644 --- a/src/backend/opencl/runners/OclRxJitRunner.cpp +++ b/src/backend/opencl/runners/OclRxJitRunner.cpp @@ -16,6 +16,9 @@ * along with this program. If not, see . */ +#include + + #include "backend/opencl/runners/OclRxJitRunner.h" #include "backend/opencl/cl/rx/randomx_run_gfx803.h" #include "backend/opencl/cl/rx/randomx_run_gfx900.h" diff --git a/src/base/kernel/Platform.cpp b/src/base/kernel/Platform.cpp index ef2b67eb9..9baf77c2e 100644 --- a/src/base/kernel/Platform.cpp +++ b/src/base/kernel/Platform.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/kernel/Platform.h" @@ -42,9 +41,12 @@ void xmrig::Platform::init(const char *userAgent) # ifdef XMRIG_FEATURE_TLS SSL_library_init(); SSL_load_error_strings(); + +# if OPENSSL_VERSION_NUMBER < 0x30000000L || defined(LIBRESSL_VERSION_NUMBER) ERR_load_BIO_strings(); ERR_load_crypto_strings(); - SSL_load_error_strings(); +# endif + OpenSSL_add_all_digests(); # endif diff --git a/src/base/net/dns/DnsRecord.cpp b/src/base/net/dns/DnsRecord.cpp index bfa84613a..3bf8f0975 100644 --- a/src/base/net/dns/DnsRecord.cpp +++ b/src/base/net/dns/DnsRecord.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,11 +46,11 @@ xmrig::String xmrig::DnsRecord::ip() const if (m_type == AAAA) { buf = new char[45](); - uv_ip6_name(reinterpret_cast(m_data), buf, 45); + uv_ip6_name(reinterpret_cast(m_data), buf, 45); } else { buf = new char[16](); - uv_ip4_name(reinterpret_cast(m_data), buf, 16); + uv_ip4_name(reinterpret_cast(m_data), buf, 16); } return buf; diff --git a/src/base/net/dns/DnsUvBackend.cpp b/src/base/net/dns/DnsUvBackend.cpp index 8de95df54..33f27f95e 100644 --- a/src/base/net/dns/DnsUvBackend.cpp +++ b/src/base/net/dns/DnsUvBackend.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,18 +28,19 @@ namespace xmrig { -static Storage* storage = nullptr; -Storage& DnsUvBackend::getStorage() +static Storage *storage = nullptr; + + +Storage &DnsUvBackend::getStorage() { - if (storage == nullptr) storage = new Storage(); + if (storage == nullptr) { + storage = new Storage(); + } + return *storage; } -void DnsUvBackend::releaseStorage() -{ - delete storage; -} static addrinfo hints{}; @@ -61,8 +62,14 @@ xmrig::DnsUvBackend::DnsUvBackend() xmrig::DnsUvBackend::~DnsUvBackend() { - getStorage().release(m_key); - releaseStorage(); + assert(storage); + + storage->release(m_key); + + if (storage->isEmpty()) { + delete storage; + storage = nullptr; + } } diff --git a/src/base/net/http/HttpResponse.h b/src/base/net/http/HttpResponse.h index a6b44997d..9e6325989 100644 --- a/src/base/net/http/HttpResponse.h +++ b/src/base/net/http/HttpResponse.h @@ -21,6 +21,7 @@ #define XMRIG_HTTPRESPONSE_H +#include #include #include diff --git a/src/base/net/tls/TlsContext.cpp b/src/base/net/tls/TlsContext.cpp index e36217975..54b904eab 100644 --- a/src/base/net/tls/TlsContext.cpp +++ b/src/base/net/tls/TlsContext.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2018 Lee Clagett - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,6 +45,7 @@ namespace xmrig { // https://wiki.openssl.org/index.php/Diffie-Hellman_parameters +#if OPENSSL_VERSION_NUMBER < 0x30000000L || defined(LIBRESSL_VERSION_NUMBER) static DH *get_dh2048() { static unsigned char dhp_2048[] = { @@ -96,6 +97,8 @@ static DH *get_dh2048() return dh; } +#endif + } // namespace xmrig @@ -191,6 +194,7 @@ bool xmrig::TlsContext::setCipherSuites(const char *ciphersuites) bool xmrig::TlsContext::setDH(const char *dhparam) { +# if OPENSSL_VERSION_NUMBER < 0x30000000L || defined(LIBRESSL_VERSION_NUMBER) DH *dh = nullptr; if (dhparam != nullptr) { @@ -225,6 +229,34 @@ bool xmrig::TlsContext::setDH(const char *dhparam) return false; } +# else + if (dhparam != nullptr) { + EVP_PKEY *dh = nullptr; + BIO *bio = BIO_new_file(Env::expand(dhparam), "r"); + + if (bio) { + dh = PEM_read_bio_Parameters(bio, nullptr); + BIO_free(bio); + } + + if (!dh) { + LOG_ERR("PEM_read_bio_Parameters(\"%s\") failed.", dhparam); + + return false; + } + + if (SSL_CTX_set0_tmp_dh_pkey(m_ctx, dh) != 1) { + EVP_PKEY_free(dh); + + LOG_ERR("SSL_CTX_set0_tmp_dh_pkey(\"%s\") failed.", dhparam); + + return false; + } + } + else { + SSL_CTX_set_dh_auto(m_ctx, 1); + } +# endif return true; } diff --git a/src/base/net/tls/TlsContext.h b/src/base/net/tls/TlsContext.h index 9a9b3cb1c..0bb7eec3f 100644 --- a/src/base/net/tls/TlsContext.h +++ b/src/base/net/tls/TlsContext.h @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2018 Lee Clagett - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,9 +24,6 @@ #include "base/tools/Object.h" -#include - - using SSL_CTX = struct ssl_ctx_st; @@ -60,6 +57,7 @@ private: }; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_TLSCONTEXT_H */ + +#endif // XMRIG_TLSCONTEXT_H diff --git a/src/base/net/tls/TlsGen.cpp b/src/base/net/tls/TlsGen.cpp index 428920537..ad2e648b4 100644 --- a/src/base/net/tls/TlsGen.cpp +++ b/src/base/net/tls/TlsGen.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ static const char *kLocalhost = "localhost"; static EVP_PKEY *generate_pkey() { +# if OPENSSL_VERSION_NUMBER < 0x30000000L || defined(LIBRESSL_VERSION_NUMBER) auto pkey = EVP_PKEY_new(); if (!pkey) { return nullptr; @@ -53,6 +54,9 @@ static EVP_PKEY *generate_pkey() BN_free(exponent); return pkey; +# else + return EVP_RSA_gen(2048); +# endif } diff --git a/src/base/net/tls/TlsGen.h b/src/base/net/tls/TlsGen.h index c471c8ca6..193dd2d50 100644 --- a/src/base/net/tls/TlsGen.h +++ b/src/base/net/tls/TlsGen.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,7 +55,7 @@ private: }; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_TLSGEN_H */ +#endif // XMRIG_TLSGEN_H diff --git a/src/base/net/tools/Storage.h b/src/base/net/tools/Storage.h index e23e86665..390101c30 100644 --- a/src/base/net/tools/Storage.h +++ b/src/base/net/tools/Storage.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright 2018-2023 SChernykh + * Copyright 2016-2023 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,7 +42,7 @@ public: } - inline void *ptr(uintptr_t id) { return reinterpret_cast(id); } + inline TYPE *ptr(uintptr_t id) { return reinterpret_cast(id); } inline TYPE *get(const void *id) const { return get(reinterpret_cast(id)); } @@ -56,6 +56,9 @@ public: return m_data.at(id); } + inline bool isEmpty() const { return m_data.empty(); } + inline size_t size() const { return m_data.size(); } + inline void remove(const void *id) { delete release(reinterpret_cast(id)); } inline void remove(uintptr_t id) { delete release(id); } diff --git a/src/base/tools/Object.h b/src/base/tools/Object.h index 00bd9315a..f67464ab6 100644 --- a/src/base/tools/Object.h +++ b/src/base/tools/Object.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,9 @@ #define XMRIG_OBJECT_H -#include +#include +#include +#include namespace xmrig { @@ -41,6 +43,7 @@ namespace xmrig { X &operator=(X &&other) = delete; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_OBJECT_H */ + +#endif // XMRIG_OBJECT_H diff --git a/src/crypto/cn/CryptoNight_x86.h b/src/crypto/cn/CryptoNight_x86.h index 434c7363b..64622ee4c 100644 --- a/src/crypto/cn/CryptoNight_x86.h +++ b/src/crypto/cn/CryptoNight_x86.h @@ -80,7 +80,7 @@ static inline void do_skein_hash(const uint8_t *input, size_t len, uint8_t *outp void (* const extra_hashes[4])(const uint8_t *, size_t, uint8_t *) = {do_blake_hash, do_groestl_hash, do_jh_hash, do_skein_hash}; -#if defined(__i386__) || defined(_M_IX86) +#if (defined(__i386__) || defined(_M_IX86)) && !(defined(__clang__) && defined(__clang_major__) && (__clang_major__ >= 15)) static inline int64_t _mm_cvtsi128_si64(__m128i a) { return ((uint64_t)(uint32_t)_mm_cvtsi128_si32(a) | ((uint64_t)(uint32_t)_mm_cvtsi128_si32(_mm_srli_si128(a, 4)) << 32)); diff --git a/src/crypto/ghostrider/ghostrider.cpp b/src/crypto/ghostrider/ghostrider.cpp index 0ce0976eb..70138470b 100644 --- a/src/crypto/ghostrider/ghostrider.cpp +++ b/src/crypto/ghostrider/ghostrider.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright 2018-2023 SChernykh + * Copyright 2016-2023 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include "ghostrider.h" #include "sph_blake.h" #include "sph_bmw.h" diff --git a/src/crypto/rx/RxConfig.cpp b/src/crypto/rx/RxConfig.cpp index 775c93269..cb50c4d1c 100644 --- a/src/crypto/rx/RxConfig.cpp +++ b/src/crypto/rx/RxConfig.cpp @@ -256,10 +256,12 @@ void xmrig::RxConfig::readMSR(const rapidjson::Value &value) return; } - if (value.IsInt() && Cpu::info()->vendor() == ICpuInfo::VENDOR_INTEL) { + if (value.IsInt()) { const int i = std::min(value.GetInt(), 15); if (i >= 0) { - m_msrPreset.emplace_back(0x1a4, i); + if (Cpu::info()->vendor() == ICpuInfo::VENDOR_INTEL) { + m_msrPreset.emplace_back(0x1a4, i); + } } else { m_wrmsr = false; diff --git a/src/version.h b/src/version.h index 67437bcb6..0e4bbb026 100644 --- a/src/version.h +++ b/src/version.h @@ -22,7 +22,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig miner" -#define APP_VERSION "6.19.0" +#define APP_VERSION "6.19.1-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2023 xmrig.com" @@ -30,7 +30,7 @@ #define APP_VER_MAJOR 6 #define APP_VER_MINOR 19 -#define APP_VER_PATCH 0 +#define APP_VER_PATCH 1 #ifdef _MSC_VER # if (_MSC_VER >= 1930)