From 6106bf30def3e3d6099d59d663cf6751c996a8bf Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 8 Apr 2022 14:33:16 +0700 Subject: [PATCH] Backport non breaking changes from the new base. --- src/base/api/requests/ApiRequest.cpp | 11 +---- src/base/api/requests/ApiRequest.h | 11 +---- src/base/api/requests/HttpApiRequest.cpp | 1 - src/base/api/requests/HttpApiRequest.h | 1 - src/base/crypto/keccak.cpp | 13 ++---- src/base/crypto/keccak.h | 12 ++--- src/base/io/Async.cpp | 4 +- src/base/io/Async.h | 4 +- src/base/io/json/Json_win.cpp | 26 +++-------- src/base/io/log/FileLogWriter.cpp | 1 - src/base/io/log/backends/FileLog.cpp | 5 +-- src/base/io/log/backends/FileLog.h | 4 +- src/base/io/log/backends/SysLog.cpp | 8 ++-- src/base/io/log/backends/SysLog.h | 4 +- src/base/kernel/Process_unix.cpp | 5 +-- src/base/kernel/Process_win.cpp | 5 +-- src/base/kernel/interfaces/IAsyncListener.h | 4 +- src/base/kernel/interfaces/IClientListener.h | 16 +++---- src/base/kernel/interfaces/IConfigTransform.h | 14 +++--- src/base/kernel/interfaces/IConsoleListener.h | 4 +- src/base/kernel/interfaces/IHttpListener.h | 4 +- src/base/kernel/interfaces/ILineListener.h | 10 +---- src/base/kernel/interfaces/IStrategy.h | 18 ++++---- .../kernel/interfaces/IStrategyListener.h | 10 +---- .../kernel/interfaces/ITcpServerListener.h | 22 ++++----- src/base/kernel/interfaces/ITimerListener.h | 4 +- src/base/kernel/interfaces/IWatcherListener.h | 16 +++---- src/base/net/dns/DnsRecord.cpp | 1 - src/base/net/dns/DnsRecord.h | 4 +- src/base/net/dns/DnsRecords.h | 4 +- src/base/net/dns/DnsRequest.h | 7 +-- src/base/net/dns/DnsUvBackend.cpp | 23 +++++----- src/base/net/dns/DnsUvBackend.h | 9 ++-- src/base/net/http/Fetch.h | 1 - src/base/net/http/HttpApiResponse.cpp | 1 - src/base/net/http/HttpClient.h | 1 - src/base/net/http/HttpContext.cpp | 1 - src/base/net/http/HttpContext.h | 1 - src/base/net/http/HttpData.cpp | 1 - src/base/net/http/HttpData.h | 1 - src/base/net/http/HttpListener.cpp | 1 - src/base/net/http/HttpResponse.cpp | 1 - src/base/net/http/HttpServer.cpp | 1 - src/base/net/https/HttpsClient.cpp | 5 +-- src/base/net/https/HttpsClient.h | 5 +-- src/base/net/https/HttpsContext.h | 5 +-- src/base/net/https/HttpsServer.h | 4 +- src/base/net/stratum/DaemonClient.cpp | 20 +++------ src/base/net/stratum/Job.cpp | 16 +++---- src/base/net/stratum/Job.h | 14 ++---- src/base/net/stratum/Pools.cpp | 13 ++---- src/base/net/stratum/Pools.h | 10 +---- src/base/net/stratum/ProxyUrl.cpp | 5 +-- src/base/net/stratum/ProxyUrl.h | 4 +- src/base/net/stratum/Socks5.cpp | 5 +-- src/base/net/stratum/Socks5.h | 4 +- src/base/net/stratum/SubmitResult.h | 10 +---- .../stratum/strategies/FailoverStrategy.cpp | 6 +-- .../net/stratum/strategies/FailoverStrategy.h | 4 +- .../stratum/strategies/SinglePoolStrategy.cpp | 12 +---- .../stratum/strategies/SinglePoolStrategy.h | 10 +---- .../net/stratum/strategies/StrategyProxy.h | 10 +---- src/base/net/tls/ServerTls.cpp | 5 +-- src/base/net/tls/ServerTls.h | 5 +-- src/base/net/tools/LineReader.cpp | 5 +-- src/base/net/tools/LineReader.h | 4 +- src/base/net/tools/MemPool.h | 4 +- src/base/net/tools/NetBuffer.cpp | 5 +-- src/base/net/tools/NetBuffer.h | 4 +- src/base/net/tools/TcpServer.cpp | 11 +---- src/base/net/tools/TcpServer.h | 10 +---- src/base/tools/Baton.h | 4 +- src/base/tools/Buffer.h | 4 +- src/base/tools/Cvt.cpp | 45 ++++++++++++++++--- src/base/tools/Cvt.h | 9 +++- src/base/tools/Handle.h | 4 +- src/base/tools/Object.h | 12 +++-- src/base/tools/String.cpp | 2 +- src/base/tools/String.h | 38 +++++++++------- src/base/tools/Timer.cpp | 22 ++------- src/base/tools/Timer.h | 16 +++---- src/base/tools/bswap_64.h | 26 +++++------ 82 files changed, 280 insertions(+), 412 deletions(-) diff --git a/src/base/api/requests/ApiRequest.cpp b/src/base/api/requests/ApiRequest.cpp index 4f0bd044..841cd6a3 100644 --- a/src/base/api/requests/ApiRequest.cpp +++ b/src/base/api/requests/ApiRequest.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -22,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/api/requests/ApiRequest.h" diff --git a/src/base/api/requests/ApiRequest.h b/src/base/api/requests/ApiRequest.h index c87e822c..92f357b3 100644 --- a/src/base/api/requests/ApiRequest.h +++ b/src/base/api/requests/ApiRequest.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -22,7 +16,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_APIREQUEST_H #define XMRIG_APIREQUEST_H diff --git a/src/base/api/requests/HttpApiRequest.cpp b/src/base/api/requests/HttpApiRequest.cpp index de43f752..c0138780 100644 --- a/src/base/api/requests/HttpApiRequest.cpp +++ b/src/base/api/requests/HttpApiRequest.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/api/requests/HttpApiRequest.h" #include "3rdparty/llhttp/llhttp.h" #include "3rdparty/rapidjson/error/en.h" diff --git a/src/base/api/requests/HttpApiRequest.h b/src/base/api/requests/HttpApiRequest.h index cb159757..a1de5d86 100644 --- a/src/base/api/requests/HttpApiRequest.h +++ b/src/base/api/requests/HttpApiRequest.h @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_HTTPAPIREQUEST_H #define XMRIG_HTTPAPIREQUEST_H diff --git a/src/base/crypto/keccak.cpp b/src/base/crypto/keccak.cpp index aa60275c..5c2176dd 100644 --- a/src/base/crypto/keccak.cpp +++ b/src/base/crypto/keccak.cpp @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2011 Markku-Juhani O. Saarinen - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2011 Markku-Juhani O. Saarinen + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -23,7 +17,6 @@ * along with this program. If not, see . */ - #include diff --git a/src/base/crypto/keccak.h b/src/base/crypto/keccak.h index 2b039c90..ace23e11 100644 --- a/src/base/crypto/keccak.h +++ b/src/base/crypto/keccak.h @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2011 Markku-Juhani O. Saarinen - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2011 Markku-Juhani O. Saarinen + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/io/Async.cpp b/src/base/io/Async.cpp index 255be8c0..c50cdf6e 100644 --- a/src/base/io/Async.cpp +++ b/src/base/io/Async.cpp @@ -1,8 +1,8 @@ /* XMRig * Copyright (c) 2015-2020 libuv project contributors. * Copyright (c) 2020 cohcho - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/io/Async.h b/src/base/io/Async.h index 19491082..823eea1d 100644 --- a/src/base/io/Async.h +++ b/src/base/io/Async.h @@ -1,8 +1,8 @@ /* XMRig * Copyright (c) 2015-2020 libuv project contributors. * Copyright (c) 2020 cohcho - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/io/json/Json_win.cpp b/src/base/io/json/Json_win.cpp index 499ae129..3d24cd4a 100644 --- a/src/base/io/json/Json_win.cpp +++ b/src/base/io/json/Json_win.cpp @@ -34,37 +34,21 @@ #include "3rdparty/rapidjson/istreamwrapper.h" #include "3rdparty/rapidjson/ostreamwrapper.h" #include "3rdparty/rapidjson/prettywriter.h" +#include "base/tools/Cvt.h" namespace xmrig { -#if defined(_MSC_VER) || defined (__GNUC__) -static std::wstring toUtf16(const char *str) -{ - const int size = static_cast(strlen(str)); - std::wstring ret; - - int len = MultiByteToWideChar(CP_UTF8, 0, str, size, nullptr, 0); - if (len > 0) { - ret.resize(static_cast(len)); - MultiByteToWideChar(CP_UTF8, 0, str, size, &ret[0], len); - } - - return ret; -} -#endif - - #if defined(_MSC_VER) # define OPEN_IFS(name) \ - std::ifstream ifs(toUtf16(name), std::ios_base::in | std::ios_base::binary); \ + std::ifstream ifs(Cvt::toUtf16(name), std::ios_base::in | std::ios_base::binary); \ if (!ifs.is_open()) { \ return false; \ } #elif defined(__GNUC__) # define OPEN_IFS(name) \ - const int fd = _wopen(toUtf16(name).c_str(), _O_RDONLY | _O_BINARY); \ + const int fd = _wopen(Cvt::toUtf16(name).c_str(), _O_RDONLY | _O_BINARY); \ if (fd == -1) { \ return false; \ } \ @@ -99,12 +83,12 @@ bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc) constexpr const std::ios_base::openmode mode = std::ios_base::out | std::ios_base::binary | std::ios_base::trunc; # if defined(_MSC_VER) - std::ofstream ofs(toUtf16(fileName), mode); + std::ofstream ofs(Cvt::toUtf16(fileName), mode); if (!ofs.is_open()) { return false; } # elif defined(__GNUC__) - const int fd = _wopen(toUtf16(fileName).c_str(), _O_WRONLY | _O_BINARY | _O_CREAT | _O_TRUNC, _S_IWRITE); + const int fd = _wopen(Cvt::toUtf16(fileName).c_str(), _O_WRONLY | _O_BINARY | _O_CREAT | _O_TRUNC, _S_IWRITE); if (fd == -1) { return false; } diff --git a/src/base/io/log/FileLogWriter.cpp b/src/base/io/log/FileLogWriter.cpp index b41f7f39..132b15b7 100644 --- a/src/base/io/log/FileLogWriter.cpp +++ b/src/base/io/log/FileLogWriter.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/io/log/FileLogWriter.h" #include "base/io/Env.h" diff --git a/src/base/io/log/backends/FileLog.cpp b/src/base/io/log/backends/FileLog.cpp index 51e5b1f7..c7df9095 100644 --- a/src/base/io/log/backends/FileLog.cpp +++ b/src/base/io/log/backends/FileLog.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2019 Spudz76 - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include "base/io/log/backends/FileLog.h" diff --git a/src/base/io/log/backends/FileLog.h b/src/base/io/log/backends/FileLog.h index c52cefd9..8919ce4c 100644 --- a/src/base/io/log/backends/FileLog.h +++ b/src/base/io/log/backends/FileLog.h @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2019 Spudz76 - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/io/log/backends/SysLog.cpp b/src/base/io/log/backends/SysLog.cpp index bd333908..d93bd483 100644 --- a/src/base/io/log/backends/SysLog.cpp +++ b/src/base/io/log/backends/SysLog.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2019 Spudz76 - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -17,7 +17,7 @@ * along with this program. If not, see . */ - +#include #include @@ -43,5 +43,5 @@ void xmrig::SysLog::print(uint64_t, int level, const char *line, size_t offset, return; } - syslog(level == -1 ? LOG_INFO : level, "%s", line + offset); + syslog(level == -1 ? LOG_INFO : std::min(level, LOG_DEBUG), "%s", line + offset); } diff --git a/src/base/io/log/backends/SysLog.h b/src/base/io/log/backends/SysLog.h index 447ad006..8bab4957 100644 --- a/src/base/io/log/backends/SysLog.h +++ b/src/base/io/log/backends/SysLog.h @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2019 Spudz76 - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/kernel/Process_unix.cpp b/src/base/kernel/Process_unix.cpp index 3f1fdeb2..6bbf557f 100644 --- a/src/base/kernel/Process_unix.cpp +++ b/src/base/kernel/Process_unix.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 #include diff --git a/src/base/kernel/Process_win.cpp b/src/base/kernel/Process_win.cpp index a8d5d2d4..1bcfaa58 100644 --- a/src/base/kernel/Process_win.cpp +++ b/src/base/kernel/Process_win.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/kernel/interfaces/IAsyncListener.h b/src/base/kernel/interfaces/IAsyncListener.h index 868646fe..d5a19d4d 100644 --- a/src/base/kernel/interfaces/IAsyncListener.h +++ b/src/base/kernel/interfaces/IAsyncListener.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/kernel/interfaces/IClientListener.h b/src/base/kernel/interfaces/IClientListener.h index 4f2be302..5165d02f 100644 --- a/src/base/kernel/interfaces/IClientListener.h +++ b/src/base/kernel/interfaces/IClientListener.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -30,6 +24,7 @@ #include "3rdparty/rapidjson/fwd.h" +#include "base/tools/Object.h" namespace xmrig { @@ -44,7 +39,10 @@ class SubmitResult; class IClientListener { public: - virtual ~IClientListener() = default; + XMRIG_DISABLE_COPY_MOVE(IClientListener) + + IClientListener() = default; + virtual ~IClientListener() = default; virtual void onClose(IClient *client, int failures) = 0; virtual void onJobReceived(IClient *client, const Job &job, const rapidjson::Value ¶ms) = 0; diff --git a/src/base/kernel/interfaces/IConfigTransform.h b/src/base/kernel/interfaces/IConfigTransform.h index c8ada0b8..2f022925 100644 --- a/src/base/kernel/interfaces/IConfigTransform.h +++ b/src/base/kernel/interfaces/IConfigTransform.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -27,6 +21,7 @@ #include "3rdparty/rapidjson/fwd.h" +#include "base/tools/Object.h" namespace xmrig { @@ -39,6 +34,9 @@ class String; class IConfigTransform { public: + XMRIG_DISABLE_COPY_MOVE(IConfigTransform) + + IConfigTransform() = default; virtual ~IConfigTransform() = default; virtual void finalize(rapidjson::Document &doc) = 0; diff --git a/src/base/kernel/interfaces/IConsoleListener.h b/src/base/kernel/interfaces/IConsoleListener.h index 69433210..194bc72f 100644 --- a/src/base/kernel/interfaces/IConsoleListener.h +++ b/src/base/kernel/interfaces/IConsoleListener.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/kernel/interfaces/IHttpListener.h b/src/base/kernel/interfaces/IHttpListener.h index 931d1933..0588412e 100644 --- a/src/base/kernel/interfaces/IHttpListener.h +++ b/src/base/kernel/interfaces/IHttpListener.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/kernel/interfaces/ILineListener.h b/src/base/kernel/interfaces/ILineListener.h index a7d34901..bd8fb10d 100644 --- a/src/base/kernel/interfaces/ILineListener.h +++ b/src/base/kernel/interfaces/ILineListener.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/kernel/interfaces/IStrategy.h b/src/base/kernel/interfaces/IStrategy.h index fc34521d..690cf543 100644 --- a/src/base/kernel/interfaces/IStrategy.h +++ b/src/base/kernel/interfaces/IStrategy.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -29,6 +23,9 @@ #include +#include "base/tools/Object.h" + + namespace xmrig { @@ -41,7 +38,10 @@ class ProxyUrl; class IStrategy { public: - virtual ~IStrategy() = default; + XMRIG_DISABLE_COPY_MOVE(IStrategy) + + IStrategy() = default; + virtual ~IStrategy() = default; virtual bool isActive() const = 0; virtual IClient *client() const = 0; diff --git a/src/base/kernel/interfaces/IStrategyListener.h b/src/base/kernel/interfaces/IStrategyListener.h index 605d15a9..60d54d74 100644 --- a/src/base/kernel/interfaces/IStrategyListener.h +++ b/src/base/kernel/interfaces/IStrategyListener.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/kernel/interfaces/ITcpServerListener.h b/src/base/kernel/interfaces/ITcpServerListener.h index 3cb1576e..28b747a6 100644 --- a/src/base/kernel/interfaces/ITcpServerListener.h +++ b/src/base/kernel/interfaces/ITcpServerListener.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -26,10 +20,13 @@ #define XMRIG_ITCPSERVERLISTENER_H -#include +#include -typedef struct uv_stream_s uv_stream_t; +#include "base/tools/Object.h" + + +using uv_stream_t = struct uv_stream_s; namespace xmrig { @@ -41,7 +38,10 @@ class String; class ITcpServerListener { public: - virtual ~ITcpServerListener() = default; + XMRIG_DISABLE_COPY_MOVE(ITcpServerListener) + + ITcpServerListener() = default; + virtual ~ITcpServerListener() = default; virtual void onConnection(uv_stream_t *stream, uint16_t port) = 0; }; diff --git a/src/base/kernel/interfaces/ITimerListener.h b/src/base/kernel/interfaces/ITimerListener.h index d169b12e..5122923a 100644 --- a/src/base/kernel/interfaces/ITimerListener.h +++ b/src/base/kernel/interfaces/ITimerListener.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/kernel/interfaces/IWatcherListener.h b/src/base/kernel/interfaces/IWatcherListener.h index a62b4b53..110e67db 100644 --- a/src/base/kernel/interfaces/IWatcherListener.h +++ b/src/base/kernel/interfaces/IWatcherListener.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -26,6 +20,9 @@ #define XMRIG_IWATCHERLISTENER_H +#include "base/tools/Object.h" + + namespace xmrig { @@ -35,6 +32,9 @@ class String; class IWatcherListener { public: + XMRIG_DISABLE_COPY_MOVE(IWatcherListener) + + IWatcherListener() = default; virtual ~IWatcherListener() = default; virtual void onFileChanged(const String &fileName) = 0; diff --git a/src/base/net/dns/DnsRecord.cpp b/src/base/net/dns/DnsRecord.cpp index bfa84613..4ff1acf8 100644 --- a/src/base/net/dns/DnsRecord.cpp +++ b/src/base/net/dns/DnsRecord.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include diff --git a/src/base/net/dns/DnsRecord.h b/src/base/net/dns/DnsRecord.h index 7a68ea2f..b4b50d04 100644 --- a/src/base/net/dns/DnsRecord.h +++ b/src/base/net/dns/DnsRecord.h @@ -54,7 +54,7 @@ private: }; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_DNSRECORD_H */ +#endif // XMRIG_DNSRECORD_H diff --git a/src/base/net/dns/DnsRecords.h b/src/base/net/dns/DnsRecords.h index cfa19217..4d9248b6 100644 --- a/src/base/net/dns/DnsRecords.h +++ b/src/base/net/dns/DnsRecords.h @@ -42,7 +42,7 @@ private: }; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_DNSRECORDS_H */ +#endif // XMRIG_DNSRECORDS_H diff --git a/src/base/net/dns/DnsRequest.h b/src/base/net/dns/DnsRequest.h index 036eaa34..4ee54fd0 100644 --- a/src/base/net/dns/DnsRequest.h +++ b/src/base/net/dns/DnsRequest.h @@ -23,9 +23,6 @@ #include "base/tools/Object.h" -#include - - namespace xmrig { @@ -44,7 +41,7 @@ public: }; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_DNSREQUEST_H */ +#endif // XMRIG_DNSREQUEST_H diff --git a/src/base/net/dns/DnsUvBackend.cpp b/src/base/net/dns/DnsUvBackend.cpp index 8de95df5..a300fdf2 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-2022 SChernykh + * Copyright (c) 2016-2022 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 @@ -28,17 +27,17 @@ namespace xmrig { -static Storage* storage = nullptr; + +static Storage *storage = nullptr; + Storage& DnsUvBackend::getStorage() { - if (storage == nullptr) storage = new Storage(); - return *storage; -} + if (!storage) { + storage = new Storage(); + } -void DnsUvBackend::releaseStorage() -{ - delete storage; + return *storage; } static addrinfo hints{}; @@ -62,7 +61,9 @@ xmrig::DnsUvBackend::DnsUvBackend() xmrig::DnsUvBackend::~DnsUvBackend() { getStorage().release(m_key); - releaseStorage(); + + delete storage; + storage = nullptr; } diff --git a/src/base/net/dns/DnsUvBackend.h b/src/base/net/dns/DnsUvBackend.h index 3c2436c7..4f5cba6f 100644 --- a/src/base/net/dns/DnsUvBackend.h +++ b/src/base/net/dns/DnsUvBackend.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2022 SChernykh + * Copyright (c) 2016-2022 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 @@ -62,11 +62,10 @@ private: uintptr_t m_key; static Storage& getStorage(); - void releaseStorage(); }; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_DNSUVBACKEND_H */ +#endif // XMRIG_DNSUVBACKEND_H diff --git a/src/base/net/http/Fetch.h b/src/base/net/http/Fetch.h index 6c02e348..99d48a4f 100644 --- a/src/base/net/http/Fetch.h +++ b/src/base/net/http/Fetch.h @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_FETCH_H #define XMRIG_FETCH_H diff --git a/src/base/net/http/HttpApiResponse.cpp b/src/base/net/http/HttpApiResponse.cpp index e6758df9..3d48fb47 100644 --- a/src/base/net/http/HttpApiResponse.cpp +++ b/src/base/net/http/HttpApiResponse.cpp @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include "base/net/http/HttpApiResponse.h" #include "3rdparty/rapidjson/prettywriter.h" #include "3rdparty/rapidjson/stringbuffer.h" diff --git a/src/base/net/http/HttpClient.h b/src/base/net/http/HttpClient.h index ccda2e56..1520936b 100644 --- a/src/base/net/http/HttpClient.h +++ b/src/base/net/http/HttpClient.h @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_HTTPCLIENT_H #define XMRIG_HTTPCLIENT_H diff --git a/src/base/net/http/HttpContext.cpp b/src/base/net/http/HttpContext.cpp index 948873c9..1a1b7e1d 100644 --- a/src/base/net/http/HttpContext.cpp +++ b/src/base/net/http/HttpContext.cpp @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include "base/net/http/HttpContext.h" #include "3rdparty/llhttp/llhttp.h" #include "base/kernel/interfaces/IHttpListener.h" diff --git a/src/base/net/http/HttpContext.h b/src/base/net/http/HttpContext.h index 9178cf7c..af180172 100644 --- a/src/base/net/http/HttpContext.h +++ b/src/base/net/http/HttpContext.h @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_HTTPCONTEXT_H #define XMRIG_HTTPCONTEXT_H diff --git a/src/base/net/http/HttpData.cpp b/src/base/net/http/HttpData.cpp index b243118c..50e44043 100644 --- a/src/base/net/http/HttpData.cpp +++ b/src/base/net/http/HttpData.cpp @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include "base/net/http/HttpData.h" #include "3rdparty/llhttp/llhttp.h" #include "3rdparty/rapidjson/document.h" diff --git a/src/base/net/http/HttpData.h b/src/base/net/http/HttpData.h index 3337999a..19b85f64 100644 --- a/src/base/net/http/HttpData.h +++ b/src/base/net/http/HttpData.h @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_HTTPDATA_H #define XMRIG_HTTPDATA_H diff --git a/src/base/net/http/HttpListener.cpp b/src/base/net/http/HttpListener.cpp index 695e0f82..93b26ffe 100644 --- a/src/base/net/http/HttpListener.cpp +++ b/src/base/net/http/HttpListener.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/net/http/HttpListener.h" #include "3rdparty/llhttp/llhttp.h" #include "base/io/log/Log.h" diff --git a/src/base/net/http/HttpResponse.cpp b/src/base/net/http/HttpResponse.cpp index 216e3e51..15820f18 100644 --- a/src/base/net/http/HttpResponse.cpp +++ b/src/base/net/http/HttpResponse.cpp @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include "base/net/http/HttpResponse.h" #include "3rdparty/llhttp/llhttp.h" #include "base/io/log/Log.h" diff --git a/src/base/net/http/HttpServer.cpp b/src/base/net/http/HttpServer.cpp index aab75003..b440731c 100644 --- a/src/base/net/http/HttpServer.cpp +++ b/src/base/net/http/HttpServer.cpp @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include #include diff --git a/src/base/net/https/HttpsClient.cpp b/src/base/net/https/HttpsClient.cpp index e901b1e0..9d389671 100644 --- a/src/base/net/https/HttpsClient.cpp +++ b/src/base/net/https/HttpsClient.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2014-2019 heapwolf - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include #include #include diff --git a/src/base/net/https/HttpsClient.h b/src/base/net/https/HttpsClient.h index bd0c65ff..aa32cb99 100644 --- a/src/base/net/https/HttpsClient.h +++ b/src/base/net/https/HttpsClient.h @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2014-2019 heapwolf - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_HTTPSCLIENT_H #define XMRIG_HTTPSCLIENT_H diff --git a/src/base/net/https/HttpsContext.h b/src/base/net/https/HttpsContext.h index ff060f02..b5d5175a 100644 --- a/src/base/net/https/HttpsContext.h +++ b/src/base/net/https/HttpsContext.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2022 SChernykh + * Copyright (c) 2016-2022 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 . */ - #ifndef XMRIG_HTTPSCONTEXT_H #define XMRIG_HTTPSCONTEXT_H diff --git a/src/base/net/https/HttpsServer.h b/src/base/net/https/HttpsServer.h index ad21162f..21f3d6cf 100644 --- a/src/base/net/https/HttpsServer.h +++ b/src/base/net/https/HttpsServer.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2022 SChernykh + * Copyright (c) 2016-2022 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 diff --git a/src/base/net/stratum/DaemonClient.cpp b/src/base/net/stratum/DaemonClient.cpp index 056c7225..23a581cf 100644 --- a/src/base/net/stratum/DaemonClient.cpp +++ b/src/base/net/stratum/DaemonClient.cpp @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2019 Howard Chu - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2019 Howard Chu + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -23,7 +17,6 @@ * along with this program. If not, see . */ - #include @@ -64,9 +57,9 @@ namespace xmrig { Storage DaemonClient::m_storage; -static const char* kBlocktemplateBlob = "blocktemplate_blob"; -static const char* kBlockhashingBlob = "blockhashing_blob"; -static const char* kLastError = "lasterror"; +static const char *kBlocktemplateBlob = "blocktemplate_blob"; +static const char *kBlockhashingBlob = "blockhashing_blob"; +static const char *kLastError = "lasterror"; static const char *kGetHeight = "/getheight"; static const char *kGetInfo = "/getinfo"; static const char *kHash = "hash"; @@ -105,6 +98,7 @@ xmrig::DaemonClient::~DaemonClient() { delete m_timer; delete m_ZMQSocket; + # ifdef XMRIG_FEATURE_TLS delete m_wss.m_socket; # endif diff --git a/src/base/net/stratum/Job.cpp b/src/base/net/stratum/Job.cpp index fd002d0e..d6c91701 100644 --- a/src/base/net/stratum/Job.cpp +++ b/src/base/net/stratum/Job.cpp @@ -1,14 +1,8 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018 Lee Clagett - * Copyright 2019 Howard Chu - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright (c) 2018 Lee Clagett + * Copyright (c) 2019 Howard Chu + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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,7 +18,6 @@ * along with this program. If not, see . */ - #include #include @@ -176,6 +169,7 @@ int32_t xmrig::Job::nonceOffset() const return 39; } + uint32_t xmrig::Job::getNumTransactions() const { if (!(m_algorithm.isCN() || m_algorithm.family() == Algorithm::RANDOM_X)) { diff --git a/src/base/net/stratum/Job.h b/src/base/net/stratum/Job.h index 3fb31baa..56fdf92c 100644 --- a/src/base/net/stratum/Job.h +++ b/src/base/net/stratum/Job.h @@ -1,14 +1,8 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018 Lee Clagett - * Copyright 2019 Howard Chu - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright (c) 2018 Lee Clagett + * Copyright (c) 2019 Howard Chu + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/net/stratum/Pools.cpp b/src/base/net/stratum/Pools.cpp index a2374b9d..3211c661 100644 --- a/src/base/net/stratum/Pools.cpp +++ b/src/base/net/stratum/Pools.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -22,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/net/stratum/Pools.h" #include "3rdparty/rapidjson/document.h" #include "base/io/log/Log.h" @@ -171,7 +164,7 @@ uint32_t xmrig::Pools::benchSize() const return m_benchmark ? m_benchmark->size() : 0; # else return 0; -# endif +# endif } diff --git a/src/base/net/stratum/Pools.h b/src/base/net/stratum/Pools.h index b3f6b081..42f37e81 100644 --- a/src/base/net/stratum/Pools.h +++ b/src/base/net/stratum/Pools.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/net/stratum/ProxyUrl.cpp b/src/base/net/stratum/ProxyUrl.cpp index ad4542bc..48d80414 100644 --- a/src/base/net/stratum/ProxyUrl.cpp +++ b/src/base/net/stratum/ProxyUrl.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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/net/stratum/ProxyUrl.h" #include "3rdparty/rapidjson/document.h" diff --git a/src/base/net/stratum/ProxyUrl.h b/src/base/net/stratum/ProxyUrl.h index 0604dd9d..f4ab2edb 100644 --- a/src/base/net/stratum/ProxyUrl.h +++ b/src/base/net/stratum/ProxyUrl.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/net/stratum/Socks5.cpp b/src/base/net/stratum/Socks5.cpp index d61aa329..a89087a0 100644 --- a/src/base/net/stratum/Socks5.cpp +++ b/src/base/net/stratum/Socks5.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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/net/stratum/Socks5.h" diff --git a/src/base/net/stratum/Socks5.h b/src/base/net/stratum/Socks5.h index 286ae183..36707ce0 100644 --- a/src/base/net/stratum/Socks5.h +++ b/src/base/net/stratum/Socks5.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/net/stratum/SubmitResult.h b/src/base/net/stratum/SubmitResult.h index a180f6fa..b98869f4 100644 --- a/src/base/net/stratum/SubmitResult.h +++ b/src/base/net/stratum/SubmitResult.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/net/stratum/strategies/FailoverStrategy.cpp b/src/base/net/stratum/strategies/FailoverStrategy.cpp index 604f5596..d532421e 100644 --- a/src/base/net/stratum/strategies/FailoverStrategy.cpp +++ b/src/base/net/stratum/strategies/FailoverStrategy.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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,12 +16,10 @@ * along with this program. If not, see . */ - #include "base/net/stratum/strategies/FailoverStrategy.h" #include "3rdparty/rapidjson/document.h" #include "base/kernel/interfaces/IClient.h" #include "base/kernel/interfaces/IStrategyListener.h" -#include "base/kernel/Platform.h" xmrig::FailoverStrategy::FailoverStrategy(const std::vector &pools, int retryPause, int retries, IStrategyListener *listener, bool quiet) : diff --git a/src/base/net/stratum/strategies/FailoverStrategy.h b/src/base/net/stratum/strategies/FailoverStrategy.h index a25c82b7..e0bfc0a5 100644 --- a/src/base/net/stratum/strategies/FailoverStrategy.h +++ b/src/base/net/stratum/strategies/FailoverStrategy.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/net/stratum/strategies/SinglePoolStrategy.cpp b/src/base/net/stratum/strategies/SinglePoolStrategy.cpp index fc0fc562..37ae7a14 100644 --- a/src/base/net/stratum/strategies/SinglePoolStrategy.cpp +++ b/src/base/net/stratum/strategies/SinglePoolStrategy.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -22,12 +16,10 @@ * along with this program. If not, see . */ - #include "base/net/stratum/strategies/SinglePoolStrategy.h" #include "3rdparty/rapidjson/document.h" #include "base/kernel/interfaces/IClient.h" #include "base/kernel/interfaces/IStrategyListener.h" -#include "base/kernel/Platform.h" #include "base/net/stratum/Pool.h" diff --git a/src/base/net/stratum/strategies/SinglePoolStrategy.h b/src/base/net/stratum/strategies/SinglePoolStrategy.h index 90b85c7d..bdedd743 100644 --- a/src/base/net/stratum/strategies/SinglePoolStrategy.h +++ b/src/base/net/stratum/strategies/SinglePoolStrategy.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/net/stratum/strategies/StrategyProxy.h b/src/base/net/stratum/strategies/StrategyProxy.h index 2c0fc235..505d5071 100644 --- a/src/base/net/stratum/strategies/StrategyProxy.h +++ b/src/base/net/stratum/strategies/StrategyProxy.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/net/tls/ServerTls.cpp b/src/base/net/tls/ServerTls.cpp index abae315d..338777c7 100644 --- a/src/base/net/tls/ServerTls.cpp +++ b/src/base/net/tls/ServerTls.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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/net/tls/ServerTls.h" diff --git a/src/base/net/tls/ServerTls.h b/src/base/net/tls/ServerTls.h index 20337eb6..d1751975 100644 --- a/src/base/net/tls/ServerTls.h +++ b/src/base/net/tls/ServerTls.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 . */ - #ifndef XMRIG_SERVERTLS_H #define XMRIG_SERVERTLS_H diff --git a/src/base/net/tools/LineReader.cpp b/src/base/net/tools/LineReader.cpp index 07d0f1dc..e811547b 100644 --- a/src/base/net/tools/LineReader.cpp +++ b/src/base/net/tools/LineReader.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2020 cohcho - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include "base/net/tools/LineReader.h" #include "base/kernel/constants.h" #include "base/kernel/interfaces/ILineListener.h" diff --git a/src/base/net/tools/LineReader.h b/src/base/net/tools/LineReader.h index da6e6967..e84853b6 100644 --- a/src/base/net/tools/LineReader.h +++ b/src/base/net/tools/LineReader.h @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2020 cohcho - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/net/tools/MemPool.h b/src/base/net/tools/MemPool.h index 8a0a126b..196c67fc 100644 --- a/src/base/net/tools/MemPool.h +++ b/src/base/net/tools/MemPool.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/net/tools/NetBuffer.cpp b/src/base/net/tools/NetBuffer.cpp index 8931f06e..f597ca3a 100644 --- a/src/base/net/tools/NetBuffer.cpp +++ b/src/base/net/tools/NetBuffer.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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/net/tools/NetBuffer.h" #include "base/kernel/constants.h" #include "base/net/tools/MemPool.h" diff --git a/src/base/net/tools/NetBuffer.h b/src/base/net/tools/NetBuffer.h index a7a2ee05..93616601 100644 --- a/src/base/net/tools/NetBuffer.h +++ b/src/base/net/tools/NetBuffer.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/net/tools/TcpServer.cpp b/src/base/net/tools/TcpServer.cpp index 06d4033a..9e516a00 100644 --- a/src/base/net/tools/TcpServer.cpp +++ b/src/base/net/tools/TcpServer.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -22,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/kernel/interfaces/ITcpServerListener.h" #include "base/net/tools/TcpServer.h" #include "base/tools/Handle.h" diff --git a/src/base/net/tools/TcpServer.h b/src/base/net/tools/TcpServer.h index de464d37..24ae42d6 100644 --- a/src/base/net/tools/TcpServer.h +++ b/src/base/net/tools/TcpServer.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/tools/Baton.h b/src/base/tools/Baton.h index accaf51c..3ccac6b4 100644 --- a/src/base/tools/Baton.h +++ b/src/base/tools/Baton.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/tools/Buffer.h b/src/base/tools/Buffer.h index 91c98e64..871e7a6a 100644 --- a/src/base/tools/Buffer.h +++ b/src/base/tools/Buffer.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/tools/Cvt.cpp b/src/base/tools/Cvt.cpp index 3f083a26..fa464253 100644 --- a/src/base/tools/Cvt.cpp +++ b/src/base/tools/Cvt.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2013-2020 Frank Denis - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2022 SChernykh + * Copyright (c) 2016-2022 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 @@ -17,6 +17,10 @@ * along with this program. If not, see . */ +#ifdef XMRIG_OS_WIN +# include +#endif + #include "base/tools/Cvt.h" #include "3rdparty/rapidjson/document.h" @@ -25,7 +29,7 @@ #include -#ifdef XMRIG_SODIUM +#if defined(XMRIG_FEATURE_SODIUM) || defined(XMRIG_SODIUM) # include #endif @@ -63,7 +67,7 @@ static char *cvt_bin2hex(char *const hex, const size_t hex_maxlen, const unsigne } -#ifndef XMRIG_SODIUM +#if !defined(XMRIG_FEATURE_SODIUM) && !defined(XMRIG_SODIUM) static std::random_device randomDevice; static std::mt19937 randomEngine(randomDevice()); @@ -224,7 +228,7 @@ xmrig::Buffer xmrig::Cvt::randomBytes(const size_t size) { Buffer buf(size); -# ifndef XMRIG_SODIUM +# if !defined(XMRIG_FEATURE_SODIUM) && !defined(XMRIG_SODIUM) std::uniform_int_distribution<> dis(0, 255); for (size_t i = 0; i < size; ++i) { @@ -284,7 +288,7 @@ xmrig::String xmrig::Cvt::toHex(const uint8_t *in, size_t size) void xmrig::Cvt::randomBytes(void *buf, size_t size) { -# ifndef XMRIG_SODIUM +# if !defined(XMRIG_FEATURE_SODIUM) && !defined(XMRIG_SODIUM) std::uniform_int_distribution<> dis(0, 255); for (size_t i = 0; i < size; ++i) { @@ -294,3 +298,32 @@ void xmrig::Cvt::randomBytes(void *buf, size_t size) randombytes_buf(buf, size); # endif } + + +#ifdef XMRIG_OS_WIN +std::string xmrig::Cvt::toUtf8(const wchar_t *str, int size) +{ + std::string ret; + const int len = WideCharToMultiByte(CP_UTF8, 0, str, size, nullptr, 0, nullptr, nullptr); + if (len > 0) { + ret.resize(static_cast(len)); + WideCharToMultiByte(CP_UTF8, 0, str, size, &ret[0], len, nullptr, nullptr); + } + + return ret; +} + + +std::wstring xmrig::Cvt::toUtf16(const char *str, int size) +{ + std::wstring ret; + + const int len = MultiByteToWideChar(CP_UTF8, 0, str, size, nullptr, 0); + if (len > 0) { + ret.resize(static_cast(len)); + MultiByteToWideChar(CP_UTF8, 0, str, size, &ret[0], len); + } + + return ret; +} +#endif diff --git a/src/base/tools/Cvt.h b/src/base/tools/Cvt.h index 58058127..b546cd03 100644 --- a/src/base/tools/Cvt.h +++ b/src/base/tools/Cvt.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2022 SChernykh + * Copyright (c) 2016-2022 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 @@ -57,6 +57,11 @@ public: static rapidjson::Value toHex(const uint8_t *in, size_t size, rapidjson::Document &doc); static String toHex(const uint8_t *in, size_t size); static void randomBytes(void *buf, size_t size); + +# ifdef XMRIG_OS_WIN + static std::string toUtf8(const wchar_t *str, int size = -1); + static std::wstring toUtf16(const char *str, int size = -1); +# endif }; diff --git a/src/base/tools/Handle.h b/src/base/tools/Handle.h index fcd34147..de269549 100644 --- a/src/base/tools/Handle.h +++ b/src/base/tools/Handle.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 diff --git a/src/base/tools/Object.h b/src/base/tools/Object.h index 00bd9315..6614b312 100644 --- a/src/base/tools/Object.h +++ b/src/base/tools/Object.h @@ -20,7 +20,9 @@ #define XMRIG_OBJECT_H -#include +#include +#include +#include namespace xmrig { @@ -41,6 +43,10 @@ namespace xmrig { X &operator=(X &&other) = delete; -} /* namespace xmrig */ +#define XMRIG_DECL_PRIVATE() class Private; const std::shared_ptr d; -#endif /* XMRIG_OBJECT_H */ + +} // namespace xmrig + + +#endif // XMRIG_OBJECT_H diff --git a/src/base/tools/String.cpp b/src/base/tools/String.cpp index 2d9ef4da..676ac207 100644 --- a/src/base/tools/String.cpp +++ b/src/base/tools/String.cpp @@ -26,7 +26,7 @@ xmrig::String::String(const char *str, size_t size) : m_size(size) { - if (str == nullptr) { + if (str == nullptr || size == 0) { m_size = 0; return; diff --git a/src/base/tools/String.h b/src/base/tools/String.h index 59d6f1a2..b9fed894 100644 --- a/src/base/tools/String.h +++ b/src/base/tools/String.h @@ -59,25 +59,29 @@ public: inline bool contains(const char *str) const { return isNull() ? false : strstr(m_data, str) != nullptr; } - inline bool isEmpty() const { return size() == 0; } - inline bool isNull() const { return m_data == nullptr; } - inline bool isValid() const { return m_data != nullptr; } - inline char *data() { return m_data; } - inline const char *data() const { return m_data; } - inline size_t size() const { return m_size; } + inline bool isEmpty() const { return size() == 0; } + inline bool isNull() const { return m_data == nullptr; } + inline bool isValid() const { return m_data != nullptr; } + inline char *data() { return m_data; } + inline const char *data() const { return m_data; } + inline int32_t toInt(int32_t dv = 0) const { return isEmpty() ? dv : strtol(data(), nullptr, 0); } + inline int64_t toInt64(int64_t dv = 0) const { return isEmpty() ? dv : strtoll(data(), nullptr, 0); } + inline size_t size() const { return m_size; } + inline uint32_t toUint(uint32_t dv = 0) const { return isEmpty() ? dv : strtoul(data(), nullptr, 0); } + inline uint64_t toUint64(uint64_t dv = 0) const { return isEmpty() ? dv : strtoull(data(), nullptr, 0); } - inline bool operator!=(const char *str) const { return !isEqual(str); } - inline bool operator!=(const String &other) const { return !isEqual(other); } - inline bool operator<(const String &str) const { return !isEmpty() && !str.isEmpty() && strcmp(data(), str.data()) < 0; } - inline bool operator==(const char *str) const { return isEqual(str); } - inline bool operator==(const String &other) const { return isEqual(other); } - inline operator const char*() const { return m_data; } - inline String &operator=(char *str) { move(str); return *this; } - inline String &operator=(const char *str) { copy(str); return *this; } - inline String &operator=(const String &str) { copy(str); return *this; } - inline String &operator=(std::nullptr_t) { delete [] m_data; m_data = nullptr; m_size = 0; return *this; } - inline String &operator=(String &&other) noexcept { move(std::move(other)); return *this; } + inline bool operator!=(const char *str) const { return !isEqual(str); } + inline bool operator!=(const String &other) const { return !isEqual(other); } + inline bool operator<(const String &str) const { return !isEmpty() && !str.isEmpty() && strcmp(data(), str.data()) < 0; } + inline bool operator==(const char *str) const { return isEqual(str); } + inline bool operator==(const String &other) const { return isEqual(other); } + inline operator const char*() const { return m_data; } + inline String &operator=(char *str) { move(str); return *this; } + inline String &operator=(const char *str) { copy(str); return *this; } + inline String &operator=(const String &str) { copy(str); return *this; } + inline String &operator=(std::nullptr_t) { delete [] m_data; m_data = nullptr; m_size = 0; return *this; } + inline String &operator=(String &&other) noexcept { move(std::move(other)); return *this; } rapidjson::Value toJSON() const; rapidjson::Value toJSON(rapidjson::Document &doc) const; diff --git a/src/base/tools/Timer.cpp b/src/base/tools/Timer.cpp index 858d1219..0ad79278 100644 --- a/src/base/tools/Timer.cpp +++ b/src/base/tools/Timer.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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,29 +16,15 @@ * along with this program. If not, see . */ - #include "base/tools/Timer.h" #include "base/kernel/interfaces/ITimerListener.h" #include "base/tools/Handle.h" -xmrig::Timer::Timer(ITimerListener *listener) : - m_listener(listener) -{ - init(); -} - - -xmrig::Timer::Timer(ITimerListener *listener, uint64_t timeout, uint64_t repeat) : - m_listener(listener) -{ - init(); - start(timeout, repeat); -} - - xmrig::Timer::~Timer() { + stop(); + Handle::close(m_timer); } diff --git a/src/base/tools/Timer.h b/src/base/tools/Timer.h index 8fd040f8..f9c01626 100644 --- a/src/base/tools/Timer.h +++ b/src/base/tools/Timer.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 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 @@ -26,9 +26,6 @@ using uv_timer_t = struct uv_timer_s; #include "base/tools/Object.h" -#include - - namespace xmrig { @@ -40,8 +37,9 @@ class Timer public: XMRIG_DISABLE_COPY_MOVE_DEFAULT(Timer); - Timer(ITimerListener *listener); - Timer(ITimerListener *listener, uint64_t timeout, uint64_t repeat); + Timer(ITimerListener *listener, uint64_t repeat) : m_listener(listener) { init(); start(repeat, repeat); } + Timer(ITimerListener *listener, uint64_t timeout, uint64_t repeat) : m_listener(listener) { init(); start(timeout, repeat); } + Timer(ITimerListener *listener) : m_listener(listener) { init(); } ~Timer(); inline int id() const { return m_id; } @@ -63,7 +61,7 @@ private: }; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_TIMER_H */ +#endif // XMRIG_TIMER_H diff --git a/src/base/tools/bswap_64.h b/src/base/tools/bswap_64.h index 462a3355..9fc3f397 100644 --- a/src/base/tools/bswap_64.h +++ b/src/base/tools/bswap_64.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2022 SChernykh + * Copyright (c) 2016-2022 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 @@ -19,21 +19,17 @@ #ifndef XMRIG_BSWAP_64_H #define XMRIG_BSWAP_64_H + #ifdef _MSC_VER - -#include -#define bswap_64(x) _byteswap_uint64(x) -#define bswap_32(x) _byteswap_ulong(x) - +# include +# define bswap_64(x) _byteswap_uint64(x) +# define bswap_32(x) _byteswap_ulong(x) #elif defined __GNUC__ - -#define bswap_64(x) __builtin_bswap64(x) -#define bswap_32(x) __builtin_bswap32(x) - +# define bswap_64(x) __builtin_bswap64(x) +# define bswap_32(x) __builtin_bswap32(x) #else - -#include - +# include #endif -#endif /* XMRIG_BSWAP_64_H */ + +#endif // XMRIG_BSWAP_64_H