Sync with base.

This commit is contained in:
XMRig 2022-04-17 06:03:39 +07:00
parent d0953a507c
commit 8a167cb2a7
No known key found for this signature in database
GPG key ID: 446A53638BE94409
45 changed files with 1159 additions and 544 deletions

View file

@ -191,7 +191,7 @@ else()
endif() endif()
endif() endif()
add_definitions(-DXMRIG_MINER_PROJECT -DXMRIG_JSON_SINGLE_LINE_ARRAY) add_definitions(-DXMRIG_MINER_PROJECT -DXMRIG_LEGACY -DXMRIG_JSON_SINGLE_LINE_ARRAY)
add_definitions(-D__STDC_FORMAT_MACROS -DUNICODE -D_FILE_OFFSET_BITS=64) add_definitions(-D__STDC_FORMAT_MACROS -DUNICODE -D_FILE_OFFSET_BITS=64)
find_package(UV REQUIRED) find_package(UV REQUIRED)

View file

@ -20,7 +20,7 @@ VS_VERSION_INFO VERSIONINFO
BEGIN BEGIN
BLOCK "000004b0" BLOCK "000004b0"
BEGIN BEGIN
VALUE "CompanyName", APP_SITE VALUE "CompanyName", APP_DOMAIN
VALUE "FileDescription", APP_DESC VALUE "FileDescription", APP_DESC
VALUE "FileVersion", APP_VERSION VALUE "FileVersion", APP_VERSION
VALUE "LegalCopyright", APP_COPYRIGHT VALUE "LegalCopyright", APP_COPYRIGHT

View file

@ -34,7 +34,6 @@
#include "base/io/log/Log.h" #include "base/io/log/Log.h"
#include "base/io/log/Tags.h" #include "base/io/log/Tags.h"
#include "base/io/Signals.h" #include "base/io/Signals.h"
#include "base/kernel/Platform.h"
#include "core/config/Config.h" #include "core/config/Config.h"
#include "core/Controller.h" #include "core/Controller.h"
#include "Summary.h" #include "Summary.h"

View file

@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -18,7 +18,7 @@
#include "backend/common/Worker.h" #include "backend/common/Worker.h"
#include "base/kernel/Platform.h" #include "base/kernel/OS.h"
#include "crypto/common/VirtualMemory.h" #include "crypto/common/VirtualMemory.h"
@ -28,6 +28,6 @@ xmrig::Worker::Worker(size_t id, int64_t affinity, int priority) :
{ {
m_node = VirtualMemory::bindToNUMANode(affinity); m_node = VirtualMemory::bindToNUMANode(affinity);
Platform::trySetThreadAffinity(affinity); OS::trySetThreadAffinity(affinity);
Platform::setThreadPriority(priority); OS::setThreadPriority(priority);
} }

View file

@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -26,6 +26,7 @@
#include "base/io/Env.h" #include "base/io/Env.h"
#include "base/io/json/Json.h" #include "base/io/json/Json.h"
#include "base/kernel/Base.h" #include "base/kernel/Base.h"
#include "base/kernel/OS.h"
#include "base/tools/Chrono.h" #include "base/tools/Chrono.h"
#include "base/tools/Cvt.h" #include "base/tools/Cvt.h"
#include "core/config/Config.h" #include "core/config/Config.h"
@ -232,6 +233,6 @@ void xmrig::Api::genWorkerId(const String &id)
{ {
m_workerId = Env::expand(id); m_workerId = Env::expand(id);
if (m_workerId.isEmpty()) { if (m_workerId.isEmpty()) {
m_workerId = Env::hostname(); m_workerId = OS::hostname();
} }
} }

View file

@ -41,8 +41,10 @@ set(HEADERS_BASE
src/base/kernel/interfaces/IStrategyListener.h src/base/kernel/interfaces/IStrategyListener.h
src/base/kernel/interfaces/ITimerListener.h src/base/kernel/interfaces/ITimerListener.h
src/base/kernel/interfaces/IWatcherListener.h src/base/kernel/interfaces/IWatcherListener.h
src/base/kernel/Platform.h src/base/kernel/Lib.h
src/base/kernel/OS.h
src/base/kernel/Process.h src/base/kernel/Process.h
src/base/kernel/Versions.h
src/base/net/dns/Dns.h src/base/net/dns/Dns.h
src/base/net/dns/DnsConfig.h src/base/net/dns/DnsConfig.h
src/base/net/dns/DnsRecord.h src/base/net/dns/DnsRecord.h
@ -111,8 +113,10 @@ set(SOURCES_BASE
src/base/kernel/config/BaseTransform.cpp src/base/kernel/config/BaseTransform.cpp
src/base/kernel/config/Title.cpp src/base/kernel/config/Title.cpp
src/base/kernel/Entry.cpp src/base/kernel/Entry.cpp
src/base/kernel/Platform.cpp src/base/kernel/Lib.cpp
src/base/kernel/OS.cpp
src/base/kernel/Process.cpp src/base/kernel/Process.cpp
src/base/kernel/Versions.cpp
src/base/net/dns/Dns.cpp src/base/net/dns/Dns.cpp
src/base/net/dns/DnsConfig.cpp src/base/net/dns/DnsConfig.cpp
src/base/net/dns/DnsRecord.cpp src/base/net/dns/DnsRecord.cpp
@ -148,19 +152,19 @@ set(SOURCES_BASE
if (WIN32) if (WIN32)
set(SOURCES_OS set(SOURCES_OS
src/base/io/json/Json_win.cpp src/base/io/json/Json_win.cpp
src/base/kernel/Platform_win.cpp src/base/kernel/OS_win.cpp
src/base/kernel/Process_win.cpp src/base/kernel/Process_win.cpp
) )
elseif (APPLE) elseif (APPLE)
set(SOURCES_OS set(SOURCES_OS
src/base/io/json/Json_unix.cpp src/base/io/json/Json_unix.cpp
src/base/kernel/Platform_mac.cpp src/base/kernel/OS_mac.cpp
src/base/kernel/Process_unix.cpp src/base/kernel/Process_unix.cpp
) )
else() else()
set(SOURCES_OS set(SOURCES_OS
src/base/io/json/Json_unix.cpp src/base/io/json/Json_unix.cpp
src/base/kernel/Platform_unix.cpp src/base/kernel/OS_unix.cpp
src/base/kernel/Process_unix.cpp src/base/kernel/Process_unix.cpp
) )
endif() endif()
@ -168,7 +172,7 @@ endif()
if (WITH_HWLOC) if (WITH_HWLOC)
list(APPEND SOURCES_OS list(APPEND SOURCES_OS
src/base/kernel/Platform_hwloc.cpp src/base/kernel/OS_hwloc.cpp
) )
endif() endif()

View file

@ -1,7 +1,7 @@
/* XMRig /* XMRig
* Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd> * Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -217,7 +217,7 @@ private:
using Algorithms = std::vector<Algorithm>; using Algorithms = std::vector<Algorithm>;
} /* namespace xmrig */ } // namespace xmrig
#endif /* XMRIG_ALGORITHM_H */ #endif // XMRIG_ALGORITHM_H

View file

@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View file

@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -84,7 +84,7 @@ private:
}; };
} /* namespace xmrig */ } // namespace xmrig
#endif /* XMRIG_COIN_H */ #endif // XMRIG_COIN_H

View file

@ -17,29 +17,15 @@
*/ */
#include "base/io/Env.h" #include "base/io/Env.h"
#include "base/kernel/OS.h"
#include "base/kernel/Process.h" #include "base/kernel/Process.h"
#include "version.h" #include "version.h"
#include <regex> #include <regex>
#include <uv.h>
#include <map> #include <map>
#ifndef _WIN32
# include <unistd.h>
#endif
#ifndef UV_MAXHOSTNAMESIZE
# ifdef MAXHOSTNAMELEN
# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1)
# else
# define UV_MAXHOSTNAMESIZE 256
# endif
#endif
namespace xmrig { namespace xmrig {
@ -51,17 +37,17 @@ static void createVariables()
{ {
variables.insert({ "XMRIG_VERSION", APP_VERSION }); variables.insert({ "XMRIG_VERSION", APP_VERSION });
variables.insert({ "XMRIG_KIND", APP_KIND }); variables.insert({ "XMRIG_KIND", APP_KIND });
variables.insert({ "XMRIG_HOSTNAME", Env::hostname() }); variables.insert({ "XMRIG_HOSTNAME", OS::hostname() });
variables.insert({ "XMRIG_EXE", Process::exepath() }); variables.insert({ "XMRIG_EXE", Process::locate(Process::ExePathLocation) });
variables.insert({ "XMRIG_EXE_DIR", Process::location(Process::ExeLocation) }); variables.insert({ "XMRIG_EXE_DIR", Process::locate(Process::ExeLocation) });
variables.insert({ "XMRIG_CWD", Process::location(Process::CwdLocation) }); variables.insert({ "XMRIG_CWD", Process::locate(Process::CwdLocation) });
variables.insert({ "XMRIG_HOME_DIR", Process::location(Process::HomeLocation) }); variables.insert({ "XMRIG_HOME_DIR", Process::locate(Process::HomeLocation) });
variables.insert({ "XMRIG_TEMP_DIR", Process::location(Process::TempLocation) }); variables.insert({ "XMRIG_TEMP_DIR", Process::locate(Process::TempLocation) });
variables.insert({ "XMRIG_DATA_DIR", Process::location(Process::DataLocation) }); variables.insert({ "XMRIG_DATA_DIR", Process::locate(Process::DataLocation) });
String hostname = "HOSTNAME"; String hostname = "HOSTNAME";
if (!getenv(hostname)) { // NOLINT(concurrency-mt-unsafe) if (!getenv(hostname)) { // NOLINT(concurrency-mt-unsafe)
variables.insert({ std::move(hostname), Env::hostname() }); variables.insert({ std::move(hostname), OS::hostname() });
} }
} }
#endif #endif
@ -138,15 +124,3 @@ xmrig::String xmrig::Env::get(const String &name, const std::map<String, String>
return static_cast<const char *>(getenv(name)); // NOLINT(concurrency-mt-unsafe) return static_cast<const char *>(getenv(name)); // NOLINT(concurrency-mt-unsafe)
} }
xmrig::String xmrig::Env::hostname()
{
char buf[UV_MAXHOSTNAMESIZE]{};
if (gethostname(buf, sizeof(buf)) == 0) {
return static_cast<const char *>(buf);
}
return {};
}

View file

@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -34,7 +34,6 @@ class Env
public: public:
static String expand(const char *in, const std::map<String, String> &extra = {}); static String expand(const char *in, const std::map<String, String> &extra = {});
static String get(const String &name, const std::map<String, String> &extra = {}); static String get(const String &name, const std::map<String, String> &extra = {});
static String hostname();
}; };

View file

@ -29,7 +29,7 @@
#include "base/io/log/Tags.h" #include "base/io/log/Tags.h"
#include "base/io/Watcher.h" #include "base/io/Watcher.h"
#include "base/kernel/interfaces/IBaseListener.h" #include "base/kernel/interfaces/IBaseListener.h"
#include "base/kernel/Platform.h" #include "base/kernel/OS.h"
#include "base/kernel/Process.h" #include "base/kernel/Process.h"
#include "base/net/tools/NetBuffer.h" #include "base/net/tools/NetBuffer.h"
#include "core/config/Config.h" #include "core/config/Config.h"
@ -130,17 +130,17 @@ private:
return config.release(); return config.release();
} }
chain.addFile(Process::location(Process::DataLocation, "config.json")); chain.addFile(Process::locate(Process::DataLocation, "config.json"));
if (read(chain, config)) { if (read(chain, config)) {
return config.release(); return config.release();
} }
chain.addFile(Process::location(Process::HomeLocation, "." APP_ID ".json")); chain.addFile(Process::locate(Process::HomeLocation, "." APP_ID ".json"));
if (read(chain, config)) { if (read(chain, config)) {
return config.release(); return config.release();
} }
chain.addFile(Process::location(Process::HomeLocation, ".config" XMRIG_DIR_SEPARATOR APP_ID ".json")); chain.addFile(Process::locate(Process::HomeLocation, ".config" XMRIG_DIR_SEPARATOR APP_ID ".json"));
if (read(chain, config)) { if (read(chain, config)) {
return config.release(); return config.release();
} }
@ -187,7 +187,8 @@ int xmrig::Base::init()
d_ptr->api->addListener(this); d_ptr->api->addListener(this);
# endif # endif
Platform::init(config()->userAgent()); OS::init();
Process::setUserAgent(config()->userAgent());
if (isBackground()) { if (isBackground()) {
Log::setBackground(true); Log::setBackground(true);

View file

@ -1,12 +1,6 @@
/* XMRig /* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com> * Copyright (c) 2016-2022 SChernykh <https://github.com/SChernykh>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -22,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <cstdio> #include <cstdio>
#include <uv.h> #include <uv.h>
@ -42,6 +35,7 @@
#include "base/kernel/Entry.h" #include "base/kernel/Entry.h"
#include "base/kernel/Process.h" #include "base/kernel/Process.h"
#include "base/tools/Arguments.h"
#include "core/config/usage.h" #include "core/config/usage.h"
#include "version.h" #include "version.h"
@ -107,7 +101,7 @@ static int showVersion()
#ifdef XMRIG_FEATURE_HWLOC #ifdef XMRIG_FEATURE_HWLOC
static int exportTopology(const Process &) static int exportTopology(const Process &)
{ {
const String path = Process::location(Process::ExeLocation, "topology.xml"); const String path = Process::locate(Process::ExeLocation, "topology.xml");
hwloc_topology_t topology = nullptr; hwloc_topology_t topology = nullptr;
hwloc_topology_init(&topology); hwloc_topology_init(&topology);

View file

@ -1,12 +1,6 @@
/* XMRig /* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com> * Copyright (c) 2016-2022 SChernykh <https://github.com/SChernykh>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

78
src/base/kernel/Lib.cpp Normal file
View file

@ -0,0 +1,78 @@
/* XMRig
* Copyright (c) 2016-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "base/kernel/Lib.h"
#include <cassert>
#include <uv.h>
namespace xmrig {
class Lib::Private
{
public:
bool open = false;
uv_lib_t lib{};
};
} // namespace xmrig
xmrig::Lib::Lib() :
d(std::make_shared<Private>())
{
}
bool xmrig::Lib::isOpen() const
{
return d->open;
}
bool xmrig::Lib::open(const char *filename)
{
assert(!isOpen());
return (d->open = uv_dlopen(filename, &d->lib) == 0);
}
bool xmrig::Lib::sym(const char *name, void **ptr)
{
return isOpen() && uv_dlsym(&d->lib, name, ptr);
}
const char *xmrig::Lib::lastError() const
{
return uv_dlerror(&d->lib);
}
void xmrig::Lib::close()
{
if (isOpen()) {
uv_dlclose(&d->lib);
d->open = false;
}
}

View file

@ -1,5 +1,5 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2016-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -16,42 +16,39 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef XMRIG_LIB_H
#include "base/kernel/Platform.h" #define XMRIG_LIB_H
#include <cstring> #include "base/tools/Object.h"
#include <uv.h>
#ifdef XMRIG_FEATURE_TLS
# include <openssl/ssl.h>
# include <openssl/err.h>
#endif
namespace xmrig { namespace xmrig {
String Platform::m_userAgent;
class Lib
{
public:
XMRIG_DISABLE_COPY_MOVE(Lib)
Lib();
inline ~Lib() { close(); }
bool isOpen() const;
bool open(const char *filename);
bool sym(const char *name, void **ptr);
const char *lastError() const;
void close();
template<typename T>
inline bool sym(const char *name, T t) { return sym(name, reinterpret_cast<void **>(t)); }
private:
XMRIG_DECL_PRIVATE()
};
} // namespace xmrig } // namespace xmrig
void xmrig::Platform::init(const char *userAgent) #endif // XMRIG_LIB_H
{
# ifdef XMRIG_FEATURE_TLS
SSL_library_init();
SSL_load_error_strings();
ERR_load_BIO_strings();
ERR_load_crypto_strings();
SSL_load_error_strings();
OpenSSL_add_all_digests();
# endif
if (userAgent) {
m_userAgent = userAgent;
}
else {
m_userAgent = createUserAgent();
}
}

99
src/base/kernel/OS.cpp Normal file
View file

@ -0,0 +1,99 @@
/* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <uv.h>
#include "base/kernel/OS.h"
#include "3rdparty/fmt/core.h"
#include "base/kernel/Process.h"
#include "base/kernel/Versions.h"
#include "version.h"
#ifndef XMRIG_OS_WIN
# include <unistd.h>
#endif
#ifndef UV_MAXHOSTNAMESIZE
# ifdef MAXHOSTNAMELEN
# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1)
# else
# define UV_MAXHOSTNAMESIZE 256
# endif
#endif
namespace xmrig {
#if (XMRIG_ARM == 8 || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64))
const char *OS::arch = "arm64";
#elif (XMRIG_ARM == 7 || defined(__arm__) || defined(_M_ARM))
const char *OS::arch = "arm";
#elif (defined(__x86_64__) || defined(_M_AMD64))
const char *OS::arch = "x86_64";
#elif (defined(_X86_) || defined(_M_IX86))
const char *OS::arch = "x86";
#else
static_assert (false, "Unsupported CPU or compiler");
#endif
} // namespace xmrig
std::string xmrig::OS::userAgent()
{
return fmt::format("{}/{} ({}; {}) uv/{} {}/{}",
APP_NAME,
APP_VERSION,
name(),
arch,
Process::versions()[Versions::kUv],
Versions::kCompiler,
Process::versions()[Versions::kCompiler]
);
}
#ifndef XMRIG_OS_WIN
xmrig::String xmrig::OS::hostname()
{
char buf[UV_MAXHOSTNAMESIZE]{};
if (gethostname(buf, sizeof(buf)) == 0) {
return static_cast<const char *>(buf);
}
return {};
}
#endif
uint64_t xmrig::OS::freemem()
{
return uv_get_free_memory();
}
uint64_t xmrig::OS::totalmem()
{
return uv_get_total_memory();
}

View file

@ -16,50 +16,43 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef XMRIG_PLATFORM_H #ifndef XMRIG_OS_H
#define XMRIG_PLATFORM_H #define XMRIG_OS_H
#include <cstdint>
#include "base/tools/String.h" #include "base/tools/String.h"
#include <string>
namespace xmrig { namespace xmrig {
class Platform class OS
{ {
public: public:
static inline bool trySetThreadAffinity(int64_t cpu_id) static const char *arch;
{
if (cpu_id < 0) {
return false;
}
return setThreadAffinity(static_cast<uint64_t>(cpu_id));
}
static bool setThreadAffinity(uint64_t cpu_id);
static void init(const char *userAgent);
static void setProcessPriority(int priority);
static void setThreadPriority(int priority);
static inline bool isUserActive(uint64_t ms) { return idleTime() < ms; } static inline bool isUserActive(uint64_t ms) { return idleTime() < ms; }
static inline const String &userAgent() { return m_userAgent; } static inline bool trySetThreadAffinity(int64_t cpu_id) { return cpu_id >= 0 && setThreadAffinity(static_cast<uint64_t>(cpu_id)); }
static bool isOnBatteryPower(); static bool isOnBatteryPower();
static bool setThreadAffinity(uint64_t cpu_id);
static std::string name();
static std::string userAgent();
static String hostname();
static uint64_t freemem();
static uint64_t idleTime(); static uint64_t idleTime();
static uint64_t totalmem();
private: static void destroy();
static char *createUserAgent(); static void init();
static void setProcessPriority(int priority);
static String m_userAgent; static void setThreadPriority(int priority);
}; };
} // namespace xmrig } // namespace xmrig
#endif /* XMRIG_PLATFORM_H */ #endif // XMRIG_OS_H

View file

@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "base/kernel/OS.h"
#include "base/kernel/Platform.h"
#include "backend/cpu/platform/HwlocCpuInfo.h" #include "backend/cpu/platform/HwlocCpuInfo.h"
#include "backend/cpu/Cpu.h" #include "backend/cpu/Cpu.h"
@ -27,7 +26,7 @@
#ifndef XMRIG_OS_APPLE #ifndef XMRIG_OS_APPLE
bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id) bool xmrig::OS::setThreadAffinity(uint64_t cpu_id)
{ {
auto cpu = static_cast<HwlocCpuInfo *>(Cpu::info()); auto cpu = static_cast<HwlocCpuInfo *>(Cpu::info());
hwloc_obj_t pu = hwloc_get_pu_obj_by_os_index(cpu->topology(), static_cast<unsigned>(cpu_id)); hwloc_obj_t pu = hwloc_get_pu_obj_by_os_index(cpu->topology(), static_cast<unsigned>(cpu_id));

View file

@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <IOKit/IOKitLib.h> #include <IOKit/IOKitLib.h>
#include <IOKit/ps/IOPowerSources.h> #include <IOKit/ps/IOPowerSources.h>
#include <stdio.h> #include <stdio.h>
@ -27,46 +26,58 @@
#include <fstream> #include <fstream>
#include "base/kernel/Platform.h" #include "base/kernel/OS.h"
#include "version.h"
char *xmrig::Platform::createUserAgent() bool xmrig::OS::isOnBatteryPower()
{ {
constexpr const size_t max = 256; return IOPSGetTimeRemainingEstimate() != kIOPSTimeRemainingUnlimited;
char *buf = new char[max]();
int length = snprintf(buf, max,
"%s/%s (Macintosh; macOS"
# ifdef XMRIG_ARM
"; arm64"
# else
"; x86_64"
# endif
") libuv/%s", APP_NAME, APP_VERSION, uv_version_string());
# ifdef __clang__
length += snprintf(buf + length, max - length, " clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
# elif defined(__GNUC__)
length += snprintf(buf + length, max - length, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
# endif
return buf;
} }
bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id) bool xmrig::OS::setThreadAffinity(uint64_t /*cpu_id*/)
{ {
return true; return true;
} }
void xmrig::Platform::setProcessPriority(int) std::string xmrig::OS::name()
{
return "macOS";
}
uint64_t xmrig::OS::idleTime()
{
uint64_t idle_time = 0;
const auto service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOHIDSystem"));
const auto property = IORegistryEntryCreateCFProperty(service, CFSTR("HIDIdleTime"), kCFAllocatorDefault, 0);
CFNumberGetValue((CFNumberRef)property, kCFNumberSInt64Type, &idle_time);
CFRelease(property);
IOObjectRelease(service);
return idle_time / 1000000U;
}
void xmrig::OS::destroy()
{ {
} }
void xmrig::Platform::setThreadPriority(int priority) void xmrig::OS::init()
{
}
void xmrig::OS::setProcessPriority(int)
{
}
void xmrig::OS::setThreadPriority(int priority)
{ {
if (priority == -1) { if (priority == -1) {
return; return;
@ -101,24 +112,3 @@ void xmrig::Platform::setThreadPriority(int priority)
setpriority(PRIO_PROCESS, 0, prio); setpriority(PRIO_PROCESS, 0, prio);
} }
bool xmrig::Platform::isOnBatteryPower()
{
return IOPSGetTimeRemainingEstimate() != kIOPSTimeRemainingUnlimited;
}
uint64_t xmrig::Platform::idleTime()
{
uint64_t idle_time = 0;
const auto service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOHIDSystem"));
const auto property = IORegistryEntryCreateCFProperty(service, CFSTR("HIDIdleTime"), kCFAllocatorDefault, 0);
CFNumberGetValue((CFNumberRef)property, kCFNumberSInt64Type, &idle_time);
CFRelease(property);
IOObjectRelease(service);
return idle_time / 1000000U;
}

View file

@ -37,8 +37,7 @@
#include <limits> #include <limits>
#include "base/kernel/Platform.h" #include "base/kernel/OS.h"
#include "version.h"
#ifdef __FreeBSD__ #ifdef __FreeBSD__
@ -46,35 +45,24 @@ typedef cpuset_t cpu_set_t;
#endif #endif
char *xmrig::Platform::createUserAgent() bool xmrig::OS::isOnBatteryPower()
{ {
constexpr const size_t max = 256; for (int i = 0; i <= 1; ++i) {
char buf[64];
char *buf = new char[max](); snprintf(buf, 64, "/sys/class/power_supply/BAT%d/status", i);
int length = snprintf(buf, max, "%s/%s (Linux ", APP_NAME, APP_VERSION); std::ifstream f(buf);
if (f.is_open()) {
# if defined(__x86_64__) std::string status;
length += snprintf(buf + length, max - length, "x86_64) libuv/%s", uv_version_string()); f >> status;
# elif defined(__aarch64__) return (status == "Discharging");
length += snprintf(buf + length, max - length, "aarch64) libuv/%s", uv_version_string()); }
# elif defined(__arm__) }
length += snprintf(buf + length, max - length, "arm) libuv/%s", uv_version_string()); return false;
# else
length += snprintf(buf + length, max - length, "i686) libuv/%s", uv_version_string());
# endif
# ifdef __clang__
length += snprintf(buf + length, max - length, " clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
# elif defined(__GNUC__)
length += snprintf(buf + length, max - length, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
# endif
return buf;
} }
#ifndef XMRIG_FEATURE_HWLOC #ifndef XMRIG_FEATURE_HWLOC
bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id) bool xmrig::OS::setThreadAffinity(uint64_t cpu_id)
{ {
cpu_set_t mn; cpu_set_t mn;
CPU_ZERO(&mn); CPU_ZERO(&mn);
@ -92,12 +80,38 @@ bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id)
#endif #endif
void xmrig::Platform::setProcessPriority(int) std::string xmrig::OS::name()
{
# ifdef __FreeBSD__
return "FreeBSD";
# else
return "Linux";
# endif
}
uint64_t xmrig::OS::idleTime()
{
return std::numeric_limits<uint64_t>::max();
}
void xmrig::OS::destroy()
{ {
} }
void xmrig::Platform::setThreadPriority(int priority) void xmrig::OS::init()
{
}
void xmrig::OS::setProcessPriority(int)
{
}
void xmrig::OS::setThreadPriority(int priority)
{ {
if (priority == -1) { if (priority == -1) {
return; return;
@ -143,25 +157,3 @@ void xmrig::Platform::setThreadPriority(int priority)
} }
# endif # endif
} }
bool xmrig::Platform::isOnBatteryPower()
{
for (int i = 0; i <= 1; ++i) {
char buf[64];
snprintf(buf, 64, "/sys/class/power_supply/BAT%d/status", i);
std::ifstream f(buf);
if (f.is_open()) {
std::string status;
f >> status;
return (status == "Discharging");
}
}
return false;
}
uint64_t xmrig::Platform::idleTime()
{
return std::numeric_limits<uint64_t>::max();
}

View file

@ -16,16 +16,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <algorithm>
#include <winsock2.h>
#include <windows.h>
#include <uv.h> #include <uv.h>
#include <limits>
#include "base/kernel/Platform.h" #include "base/kernel/OS.h"
#include "version.h" #include "3rdparty/fmt/core.h"
#include "base/kernel/Lib.h"
#include "base/tools/Cvt.h"
#ifndef UV_MAXHOSTNAMESIZE
# define UV_MAXHOSTNAMESIZE 256
#endif
namespace xmrig {
typedef int (WSAAPI *GetHostNameW_t)(PWSTR, int); // NOLINT(modernize-use-using)
static Lib ws2_32;
static GetHostNameW_t pGetHostNameW = nullptr;
static inline OSVERSIONINFOEX winOsVersion() static inline OSVERSIONINFOEX winOsVersion()
@ -46,32 +58,21 @@ static inline OSVERSIONINFOEX winOsVersion()
} }
char *xmrig::Platform::createUserAgent() } // namespace xmrig
bool xmrig::OS::isOnBatteryPower()
{ {
const auto osver = winOsVersion(); SYSTEM_POWER_STATUS st;
constexpr const size_t max = 256; if (GetSystemPowerStatus(&st)) {
return (st.ACLineStatus == 0);
char *buf = new char[max](); }
int length = snprintf(buf, max, "%s/%s (Windows NT %lu.%lu", APP_NAME, APP_VERSION, osver.dwMajorVersion, osver.dwMinorVersion); return false;
# if defined(__x86_64__) || defined(_M_AMD64)
length += snprintf(buf + length, max - length, "; Win64; x64) libuv/%s", uv_version_string());
# else
length += snprintf(buf + length, max - length, ") libuv/%s", uv_version_string());
# endif
# ifdef __GNUC__
snprintf(buf + length, max - length, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
# elif _MSC_VER
snprintf(buf + length, max - length, " msvc/%d", MSVC_VERSION);
# endif
return buf;
} }
#ifndef XMRIG_FEATURE_HWLOC #ifndef XMRIG_FEATURE_HWLOC
bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id) bool xmrig::OS::setThreadAffinity(uint64_t cpu_id)
{ {
const bool result = (SetThreadAffinityMask(GetCurrentThread(), 1ULL << cpu_id) != 0); const bool result = (SetThreadAffinityMask(GetCurrentThread(), 1ULL << cpu_id) != 0);
Sleep(1); Sleep(1);
@ -80,7 +81,70 @@ bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id)
#endif #endif
void xmrig::Platform::setProcessPriority(int priority) std::string xmrig::OS::name()
{
const auto osver = winOsVersion();
return fmt::format("Windows {}.{}", osver.dwMajorVersion, osver.dwMinorVersion);
}
xmrig::String xmrig::OS::hostname()
{
if (pGetHostNameW) {
WCHAR buf[UV_MAXHOSTNAMESIZE]{};
if (pGetHostNameW(buf, UV_MAXHOSTNAMESIZE) == 0) {
return Cvt::toUtf8(buf).c_str();
}
}
char buf[UV_MAXHOSTNAMESIZE]{};
if (gethostname(buf, sizeof(buf)) == 0) {
return static_cast<const char *>(buf);
}
return {};
}
uint64_t xmrig::OS::idleTime()
{
LASTINPUTINFO info{};
info.cbSize = sizeof(LASTINPUTINFO);
if (!GetLastInputInfo(&info)) {
return std::numeric_limits<uint64_t>::max();
}
return static_cast<uint64_t>(GetTickCount() - info.dwTime);
}
void xmrig::OS::destroy()
{
# ifdef XMRIG_FEATURE_COM
CoUninitialize();
# endif
ws2_32.close();
}
void xmrig::OS::init()
{
# ifdef XMRIG_FEATURE_COM
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
# endif
if (ws2_32.open("Ws2_32.dll")) {
ws2_32.sym("GetHostNameW", &pGetHostNameW);
}
}
void xmrig::OS::setProcessPriority(int priority)
{ {
if (priority == -1) { if (priority == -1) {
return; return;
@ -117,7 +181,7 @@ void xmrig::Platform::setProcessPriority(int priority)
} }
void xmrig::Platform::setThreadPriority(int priority) void xmrig::OS::setThreadPriority(int priority)
{ {
if (priority == -1) { if (priority == -1) {
return; return;
@ -152,26 +216,3 @@ void xmrig::Platform::setThreadPriority(int priority)
SetThreadPriority(GetCurrentThread(), prio); SetThreadPriority(GetCurrentThread(), prio);
} }
bool xmrig::Platform::isOnBatteryPower()
{
SYSTEM_POWER_STATUS st;
if (GetSystemPowerStatus(&st)) {
return (st.ACLineStatus == 0);
}
return false;
}
uint64_t xmrig::Platform::idleTime()
{
LASTINPUTINFO info{};
info.cbSize = sizeof(LASTINPUTINFO);
if (!GetLastInputInfo(&info)) {
return std::numeric_limits<uint64_t>::max();
}
return static_cast<uint64_t>(GetTickCount() - info.dwTime);
}

View file

@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -23,10 +23,25 @@
#include "base/kernel/Process.h" #include "base/kernel/Process.h"
#include "3rdparty/fmt/core.h" #include "3rdparty/fmt/core.h"
#include "base/kernel/OS.h"
#include "base/kernel/Versions.h"
#include "base/tools/Arguments.h"
#include "base/tools/Chrono.h" #include "base/tools/Chrono.h"
#include "version.h" #include "version.h"
#ifndef XMRIG_LEGACY
# include "base/kernel/Events.h"
# include "base/kernel/events/ExitEvent.h"
#endif
#ifdef XMRIG_FEATURE_TLS
# include <openssl/ssl.h>
# include <openssl/err.h>
#endif
#ifdef XMRIG_OS_WIN #ifdef XMRIG_OS_WIN
# ifdef _MSC_VER # ifdef _MSC_VER
# include <direct.h> # include <direct.h>
@ -42,62 +57,22 @@
namespace xmrig { namespace xmrig {
static char pathBuf[520]; class Process::Private
static std::string dataDir;
static std::string getPath(Process::Location location)
{ {
size_t size = sizeof(pathBuf); public:
Private(int argc, char **argv) : arguments(argc, argv)
if (location == Process::DataLocation) { {
if (!dataDir.empty()) { # ifdef XMRIG_FEATURE_TLS
return dataDir; SSL_library_init();
} SSL_load_error_strings();
ERR_load_BIO_strings();
location = Process::ExeLocation; ERR_load_crypto_strings();
} SSL_load_error_strings();
OpenSSL_add_all_digests();
if (location == Process::HomeLocation) {
# if UV_VERSION_HEX >= 0x010600
return uv_os_homedir(pathBuf, &size) < 0 ? "" : std::string(pathBuf, size);
# else
location = Process::ExeLocation;
# endif # endif
} }
if (location == Process::TempLocation) { void setDataDir(const char *path)
# if UV_VERSION_HEX >= 0x010900
return uv_os_tmpdir(pathBuf, &size) < 0 ? "" : std::string(pathBuf, size);
# else
location = Process::ExeLocation;
# endif
}
if (location == Process::ExeLocation) {
if (uv_exepath(pathBuf, &size) < 0) {
return {};
}
auto path = std::string(pathBuf, size);
const auto pos = path.rfind(*XMRIG_DIR_SEPARATOR);
if (pos != std::string::npos) {
return path.substr(0, pos);
}
return path;
}
if (location == Process::CwdLocation) {
return uv_cwd(pathBuf, &size) < 0 ? "" : std::string(pathBuf, size);
}
return {};
}
static void setDataDir(const char *path)
{ {
if (path == nullptr) { if (path == nullptr) {
return; return;
@ -109,32 +84,100 @@ static void setDataDir(const char *path)
} }
if (!dir.empty() && uv_chdir(dir.c_str()) == 0) { if (!dir.empty() && uv_chdir(dir.c_str()) == 0) {
dataDir = dir; dataDir = { dir.data(), dir.size() };
} }
} }
Arguments arguments;
const char *version = APP_VERSION;
int exitCode = 0;
String dataDir;
String userAgent;
Versions versions;
# ifndef XMRIG_LEGACY
Events events;
# endif
};
Process::Private *Process::d = nullptr;
} // namespace xmrig } // namespace xmrig
xmrig::Process::Process(int argc, char **argv) : xmrig::Process::Process(int argc, char **argv)
m_arguments(argc, argv)
{ {
d = new Private(argc, argv);
OS::init();
srand(static_cast<unsigned int>(Chrono::currentMSecsSinceEpoch() ^ reinterpret_cast<uintptr_t>(this))); srand(static_cast<unsigned int>(Chrono::currentMSecsSinceEpoch() ^ reinterpret_cast<uintptr_t>(this)));
setDataDir(m_arguments.value("--data-dir", "-d")); d_fn()->setDataDir(arguments().value("--data-dir", "-d"));
# ifdef XMRIG_SHARED_DATADIR # ifdef XMRIG_SHARED_DATADIR
if (dataDir.empty()) { if (d_fn()->dataDir.isEmpty()) {
dataDir = fmt::format("{}" XMRIG_DIR_SEPARATOR ".xmrig" XMRIG_DIR_SEPARATOR, location(HomeLocation)); auto dataDir = fmt::format("{}" XMRIG_DIR_SEPARATOR ".xmrig" XMRIG_DIR_SEPARATOR, locate(HomeLocation));
MKDIR(dataDir); MKDIR(dataDir);
dataDir += APP_KIND; dataDir += APP_KIND;
MKDIR(dataDir); MKDIR(dataDir);
uv_chdir(dataDir.c_str()); if (uv_chdir(dataDir.c_str()) == 0) {
d_fn()->dataDir = { dataDir.c_str(), dataDir.size() };
}
} }
# endif # endif
if (d_fn()->dataDir.isEmpty()) {
d_fn()->dataDir = locate(ExeLocation);
}
}
xmrig::Process::~Process()
{
OS::destroy();
delete d;
d = nullptr;
}
const xmrig::Arguments &xmrig::Process::arguments()
{
return d_fn()->arguments;
}
const char *xmrig::Process::version()
{
return d_fn()->version;
}
const xmrig::String &xmrig::Process::userAgent()
{
if (d_fn()->userAgent.isEmpty()) {
d_fn()->userAgent = OS::userAgent().c_str();
}
return d_fn()->userAgent;
}
const xmrig::Versions &xmrig::Process::versions()
{
return d_fn()->versions;
}
int xmrig::Process::exitCode()
{
return d_fn()->exitCode;
} }
@ -148,20 +191,94 @@ int xmrig::Process::ppid()
} }
xmrig::String xmrig::Process::exepath() xmrig::String xmrig::Process::locate(Location location, const char *fileName)
{ {
size_t size = sizeof(pathBuf); auto path = locate(location);
if (path.isNull() || fileName == nullptr) {
return uv_exepath(pathBuf, &size) < 0 ? String("") : String(pathBuf, size); return path;
}
xmrig::String xmrig::Process::location(Location location, const char *fileName)
{
auto path = getPath(location);
if (path.empty() || fileName == nullptr) {
return path.c_str();
} }
return fmt::format("{}" XMRIG_DIR_SEPARATOR "{}", path, fileName).c_str(); return fmt::format("{}" XMRIG_DIR_SEPARATOR "{}", path, fileName).c_str();
} }
xmrig::String xmrig::Process::locate(Location location)
{
char buf[520]{};
size_t size = sizeof(buf);
if (location == ExePathLocation && uv_exepath(buf, &size) >= 0) {
return { buf, size };
}
if (location == Process::DataLocation && !d_fn()->dataDir.isEmpty()) {
return d_fn()->dataDir;
}
# if UV_VERSION_HEX >= 0x010600
if (location == Process::HomeLocation && uv_os_homedir(buf, &size) >= 0) {
return { buf, size };
}
# endif
# if UV_VERSION_HEX >= 0x010900
if (location == Process::TempLocation && uv_os_tmpdir(buf, &size) >= 0) {
return { buf, size };
}
# endif
if (location == Process::CwdLocation && uv_cwd(buf, &size) >= 0) {
return { buf, size };
}
if (location == Process::ExeLocation) {
if (uv_exepath(buf, &size) < 0) {
return {};
}
auto path = std::string(buf, size);
const auto pos = path.rfind(*XMRIG_DIR_SEPARATOR);
if (pos != std::string::npos) {
return path.substr(0, pos).c_str();
}
return { buf, size };
}
return location != ExeLocation ? locate(ExeLocation) : String();
}
void xmrig::Process::exit(int code)
{
if (code != -1) {
d_fn()->exitCode = code;
}
# ifndef XMRIG_LEGACY
events().post<ExitEvent>(exitCode());
# endif
}
void xmrig::Process::setUserAgent(const String &userAgent)
{
d_fn()->userAgent = userAgent;
}
#ifndef XMRIG_LEGACY
xmrig::Events &xmrig::Process::events()
{
return d_fn()->events;
}
#endif
xmrig::Process::Private *xmrig::Process::d_fn()
{
assert(d);
return d;
}

View file

@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -20,7 +20,8 @@
#define XMRIG_PROCESS_H #define XMRIG_PROCESS_H
#include "base/tools/Arguments.h" #include "base/tools/Object.h"
#include "base/tools/String.h"
#ifdef WIN32 #ifdef WIN32
@ -33,10 +34,18 @@
namespace xmrig { namespace xmrig {
class Arguments;
class Events;
class Versions;
class Process class Process
{ {
public: public:
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Process)
enum Location { enum Location {
ExePathLocation,
ExeLocation, ExeLocation,
CwdLocation, CwdLocation,
DataLocation, DataLocation,
@ -45,20 +54,34 @@ public:
}; };
Process(int argc, char **argv); Process(int argc, char **argv);
~Process();
static const Arguments &arguments();
static const char *version();
static const String &userAgent();
static const Versions &versions();
static int exitCode();
static int pid(); static int pid();
static int ppid(); static int ppid();
static String exepath(); static String locate(Location location, const char *fileName);
static String location(Location location, const char *fileName = nullptr); static String locate(Location location);
static void exit(int code = -1);
static void setUserAgent(const String &userAgent);
inline const Arguments &arguments() const { return m_arguments; } # ifndef XMRIG_LEGACY
static Events &events();
# endif
private: private:
Arguments m_arguments; class Private;
static Private *d_fn();
static Private *d;
}; };
} /* namespace xmrig */ } // namespace xmrig
#endif /* XMRIG_PROCESS_H */ #endif // XMRIG_PROCESS_H

View file

@ -0,0 +1,203 @@
/* XMRig
* Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "base/kernel/Versions.h"
#include "3rdparty/fmt/core.h"
#include "3rdparty/rapidjson/document.h"
#include "version.h"
#include <uv.h>
#ifdef XMRIG_FEATURE_HTTP
# include "3rdparty/llhttp/llhttp.h"
#endif
#ifdef XMRIG_FEATURE_TLS
# include <openssl/opensslv.h>
#endif
#ifdef XMRIG_FEATURE_SODIUM
# include <sodium.h>
#endif
#ifdef XMRIG_FEATURE_SQLITE
# include "3rdparty/sqlite/sqlite3.h"
#endif
#ifdef XMRIG_FEATURE_HWLOC
# include "backend/cpu/Cpu.h"
#endif
#ifdef XMRIG_FEATURE_POSTGRESQL
# include <libpq-fe.h>
#endif
namespace xmrig {
const char *Versions::kApp = "app";
const char *Versions::kBase = "base";
const char *Versions::kFmt = "fmt";
const char *Versions::kRapidjson = "rapidjson";
const char *Versions::kUv = "uv";
#if defined (__INTEL_LLVM_COMPILER)
const char *Versions::kCompiler = "icx";
#elif defined(__INTEL_COMPILER)
const char *Versions::kCompiler = "icc";
#elif defined(__clang__)
const char *Versions::kCompiler = "clang";
#elif defined(__GNUC__)
const char *Versions::kCompiler = "gcc";
#elif defined(_MSC_VER)
# if (_MSC_VER >= 1930)
# define MSVC_VERSION 2022
# elif (_MSC_VER >= 1920 && _MSC_VER < 1930)
# define MSVC_VERSION 2019
# elif (_MSC_VER >= 1910 && _MSC_VER < 1920)
# define MSVC_VERSION 2017
# elif _MSC_VER == 1900
# define MSVC_VERSION 2015
# else
# define MSVC_VERSION 0
# endif
const char *Versions::kCompiler = "MSVC";
#else
const char *Versions::kCompiler = "unknown";
#endif
#ifdef XMRIG_FEATURE_HTTP
const char *Versions::kLlhttp = "llhttp";
#endif
#ifdef XMRIG_FEATURE_TLS
# if defined(LIBRESSL_VERSION_TEXT)
const char *Versions::kTls = "libressl";
# else
const char *Versions::kTls = "openssl";
# endif
#endif
#ifdef XMRIG_FEATURE_SODIUM
const char *Versions::kSodium = "sodium";
#endif
#ifdef XMRIG_FEATURE_SQLITE
const char *Versions::kSqlite = "sqlite";
#endif
#ifdef XMRIG_FEATURE_HWLOC
const char *Versions::kHwloc = "hwloc";
#endif
#ifdef XMRIG_FEATURE_POSTGRESQL
const char *kPq = "pq";
#endif
} // namespace xmrig
xmrig::Versions::Versions()
{
m_data.insert({ kApp, APP_VERSION });
m_data.insert({ kBase, fmt::format("{}.{}.{}", XMRIG_BASE_VERSION / 10000, XMRIG_BASE_VERSION / 100 % 100, XMRIG_BASE_VERSION % 100).c_str() });
m_data.insert({ kUv, uv_version_string() });
m_data.insert({ kRapidjson, RAPIDJSON_VERSION_STRING });
m_data.insert({ kFmt, fmt::format("{}.{}.{}", FMT_VERSION / 10000, FMT_VERSION / 100 % 100, FMT_VERSION % 100).c_str() });
# if defined (__INTEL_LLVM_COMPILER)
m_data.insert({ kCompiler, fmt::format("{}.{}.{}", __INTEL_LLVM_COMPILER / 10000, __INTEL_LLVM_COMPILER / 100 % 100, __INTEL_LLVM_COMPILER % 100).c_str() });
# elif defined (__INTEL_COMPILER)
# if (__INTEL_COMPILER >= 2020)
m_data.insert({ kCompiler, XMRIG_TOSTRING(__INTEL_COMPILER) });
# else
m_data.insert({ kCompiler, fmt::format("{}.{}.{}", __INTEL_COMPILER / 100, __INTEL_COMPILER / 10 % 10, __INTEL_COMPILER % 10).c_str() });
# endif
# elif defined(__clang__)
m_data.insert({ kCompiler, XMRIG_TOSTRING(__clang_major__.__clang_minor__.__clang_patchlevel__) });
# elif defined(__GNUC__)
m_data.insert({ kCompiler, XMRIG_TOSTRING(__GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__) });
# elif defined(_MSC_VER)
m_data.insert({ kCompiler, XMRIG_TOSTRING(MSVC_VERSION) });
# endif
# ifdef XMRIG_FEATURE_HTTP
m_data.insert({ kLlhttp, XMRIG_TOSTRING(LLHTTP_VERSION_MAJOR.LLHTTP_VERSION_MINOR.LLHTTP_VERSION_PATCH) });
# endif
# ifdef XMRIG_FEATURE_TLS
# if defined(LIBRESSL_VERSION_TEXT)
m_data.insert({ kTls, String(LIBRESSL_VERSION_TEXT).split(' ')[1] });
# elif defined(OPENSSL_VERSION_TEXT)
m_data.insert({ kTls, String(OPENSSL_VERSION_TEXT).split(' ')[1] });
# endif
# endif
# ifdef XMRIG_FEATURE_SODIUM
m_data.insert({ kSodium, sodium_version_string() });
# endif
# ifdef XMRIG_FEATURE_SQLITE
m_data.insert({ kSqlite, sqlite3_libversion() });
# endif
# if defined(XMRIG_FEATURE_HWLOC) && defined(XMRIG_LEGACY)
m_data.insert({ kHwloc, String(Cpu::info()->backend()).split('/')[1] });
# endif
# ifdef XMRIG_FEATURE_POSTGRESQL
m_data.insert({ kPq, fmt::format("{}.{}", PQlibVersion() / 10000, PQlibVersion() % 100).c_str() });
# endif
}
const xmrig::String &xmrig::Versions::get(const char *key) const
{
static const String empty;
const auto it = m_data.find(key);
return it != m_data.end() ? it->second : empty;
}
rapidjson::Value xmrig::Versions::toJSON(rapidjson::Document &doc) const
{
using namespace rapidjson;
Value out(kObjectType);
toJSON(out, doc);
return out;
}
void xmrig::Versions::toJSON(rapidjson::Value &out, rapidjson::Document &doc) const
{
auto &allocator = doc.GetAllocator();
const auto &data = get();
for (const auto &kv : data) {
out.AddMember(kv.first.toJSON(), kv.second.toJSON(), allocator);
}
}

View file

@ -0,0 +1,83 @@
/* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_VERSIONS_H
#define XMRIG_VERSIONS_H
#include "base/tools/String.h"
#include <map>
namespace xmrig {
class Versions
{
public:
static const char *kApp;
static const char *kBase;
static const char *kCompiler;
static const char *kFmt;
static const char *kRapidjson;
static const char *kUv;
# ifdef XMRIG_FEATURE_HTTP
static const char *kLlhttp;
# endif
# ifdef XMRIG_FEATURE_TLS
static const char *kTls;
# endif
# ifdef XMRIG_FEATURE_SODIUM
static const char *kSodium;
# endif
# ifdef XMRIG_FEATURE_SQLITE
static const char *kSqlite;
# endif
# ifdef XMRIG_FEATURE_HWLOC
static const char *kHwloc;
# endif
# ifdef XMRIG_FEATURE_POSTGRESQL
static const char *kPq;
# endif
Versions();
inline const std::map<String, String> &get() const { return m_data; }
inline const String &operator[](const char *key) const { return get(key); }
const String &get(const char *key) const;
rapidjson::Value toJSON(rapidjson::Document &doc) const;
void toJSON(rapidjson::Value &out, rapidjson::Document &doc) const;
private:
std::map<String, String> m_data;
};
} /* namespace xmrig */
#endif /* XMRIG_VERSIONS_H */

View file

@ -0,0 +1,49 @@
/* XMRig
* Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_BASE_VERSION_H
#define XMRIG_BASE_VERSION_H
// The base version in the form major * 10000 + minor * 100 + patch.
#define XMRIG_BASE_VERSION 70000
#ifndef APP_DOMAIN
# define APP_DOMAIN "xmrig.com"
#endif
#ifndef APP_COPYRIGHT
# define APP_COPYRIGHT "Copyright (C) 2016-2022 xmrig.com"
#endif
#define XMRIG_STRINGIFY(x) #x
#define XMRIG_TOSTRING(x) XMRIG_STRINGIFY(x)
#ifdef GIT_COMMIT_HASH
# define XMRIG_GIT_COMMIT_HASH XMRIG_TOSTRING(GIT_COMMIT_HASH)
#else
# define XMRIG_GIT_COMMIT_HASH "0000000"
#endif
#ifdef GIT_BRANCH
# define XMRIG_GIT_BRANCH XMRIG_TOSTRING(GIT_BRANCH)
# define APP_VERSION XMRIG_TOSTRING(APP_VER_MAJOR.APP_VER_MINOR.APP_VER_PATCH) "-" XMRIG_GIT_BRANCH
#else
# define APP_VERSION XMRIG_TOSTRING(APP_VER_MAJOR.APP_VER_MINOR.APP_VER_PATCH)
#endif
#endif // XMRIG_BASE_VERSION_H

View file

@ -35,6 +35,7 @@
#include "base/net/dns/DnsConfig.h" #include "base/net/dns/DnsConfig.h"
#include "base/net/stratum/Pool.h" #include "base/net/stratum/Pool.h"
#include "base/net/stratum/Pools.h" #include "base/net/stratum/Pools.h"
#include "base/tools/Arguments.h"
#include "core/config/Config_platform.h" #include "core/config/Config_platform.h"

View file

@ -17,11 +17,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "base/net/http/HttpClient.h" #include "base/net/http/HttpClient.h"
#include "3rdparty/llhttp/llhttp.h" #include "3rdparty/llhttp/llhttp.h"
#include "base/io/log/Log.h" #include "base/io/log/Log.h"
#include "base/kernel/Platform.h" #include "base/kernel/Process.h"
#include "base/net/dns/Dns.h" #include "base/net/dns/Dns.h"
#include "base/net/dns/DnsRecords.h" #include "base/net/dns/DnsRecords.h"
#include "base/net/tools/NetBuffer.h" #include "base/net/tools/NetBuffer.h"
@ -95,7 +94,7 @@ void xmrig::HttpClient::handshake()
{ {
headers.insert({ "Host", host() }); headers.insert({ "Host", host() });
headers.insert({ "Connection", "close" }); headers.insert({ "Connection", "close" });
headers.insert({ "User-Agent", Platform::userAgent().data() }); headers.insert({ "User-Agent", Process::userAgent().data() });
if (!body.empty()) { if (!body.empty()) {
headers.insert({ "Content-Length", std::to_string(body.size()) }); headers.insert({ "Content-Length", std::to_string(body.size()) });

View file

@ -28,7 +28,7 @@
#include "3rdparty/rapidjson/document.h" #include "3rdparty/rapidjson/document.h"
#include "base/io/json/Json.h" #include "base/io/json/Json.h"
#include "base/io/log/Log.h" #include "base/io/log/Log.h"
#include "base/kernel/Platform.h" #include "base/kernel/Process.h"
#include "base/net/stratum/Client.h" #include "base/net/stratum/Client.h"
#if defined XMRIG_ALGO_KAWPOW || defined XMRIG_ALGO_GHOSTRIDER #if defined XMRIG_ALGO_KAWPOW || defined XMRIG_ALGO_GHOSTRIDER
@ -224,12 +224,12 @@ xmrig::IClient *xmrig::Pool::createClient(int id, IClientListener *listener) con
# if defined XMRIG_ALGO_KAWPOW || defined XMRIG_ALGO_GHOSTRIDER # if defined XMRIG_ALGO_KAWPOW || defined XMRIG_ALGO_GHOSTRIDER
const uint32_t f = m_algorithm.family(); const uint32_t f = m_algorithm.family();
if ((f == Algorithm::KAWPOW) || (f == Algorithm::GHOSTRIDER) || (m_coin == Coin::RAVEN)) { if ((f == Algorithm::KAWPOW) || (f == Algorithm::GHOSTRIDER) || (m_coin == Coin::RAVEN)) {
client = new EthStratumClient(id, Platform::userAgent(), listener); client = new EthStratumClient(id, Process::userAgent(), listener);
} }
else else
# endif # endif
{ {
client = new Client(id, Platform::userAgent(), listener); client = new Client(id, Process::userAgent(), listener);
} }
} }
# ifdef XMRIG_FEATURE_HTTP # ifdef XMRIG_FEATURE_HTTP
@ -237,12 +237,12 @@ xmrig::IClient *xmrig::Pool::createClient(int id, IClientListener *listener) con
client = new DaemonClient(id, listener); client = new DaemonClient(id, listener);
} }
else if (m_mode == MODE_SELF_SELECT) { else if (m_mode == MODE_SELF_SELECT) {
client = new SelfSelectClient(id, Platform::userAgent(), listener, m_submitToOrigin); client = new SelfSelectClient(id, Process::userAgent(), listener, m_submitToOrigin);
} }
# endif # endif
# if defined XMRIG_ALGO_KAWPOW || defined XMRIG_ALGO_GHOSTRIDER # if defined XMRIG_ALGO_KAWPOW || defined XMRIG_ALGO_GHOSTRIDER
else if (m_mode == MODE_AUTO_ETH) { else if (m_mode == MODE_AUTO_ETH) {
client = new AutoClient(id, Platform::userAgent(), listener); client = new AutoClient(id, Process::userAgent(), listener);
} }
# endif # endif
# ifdef XMRIG_FEATURE_BENCHMARK # ifdef XMRIG_FEATURE_BENCHMARK

View file

@ -18,7 +18,6 @@
#include "base/net/tls/TlsGen.h" #include "base/net/tls/TlsGen.h"
#include "base/io/log/Log.h" #include "base/io/log/Log.h"
#include "version.h"
#include <openssl/ssl.h> #include <openssl/ssl.h>
@ -106,7 +105,7 @@ void xmrig::TlsGen::generate(const char *commonName)
throw std::runtime_error("unable to write certificate to disk."); throw std::runtime_error("unable to write certificate to disk.");
} }
# if defined(XMRIG_BASE_VERSION) # if !defined(XMRIG_LEGACY)
LOG_NOTICE("%s " MAGENTA_BOLD("generated") WHITE_BOLD(" \"%s/%s\" ") "CN=" WHITE_BOLD("\"%s\""), tls_tag(), m_cert.data(), m_certKey.data(), cn()); LOG_NOTICE("%s " MAGENTA_BOLD("generated") WHITE_BOLD(" \"%s/%s\" ") "CN=" WHITE_BOLD("\"%s\""), tls_tag(), m_cert.data(), m_certKey.data(), cn());
# endif # endif
} }

View file

@ -1,8 +1,8 @@
/* XMRig /* XMRig
* Copyright 2012-2013 The Cryptonote developers * Copyright (c) 2012-2013 The Cryptonote developers
* Copyright 2014-2021 The Monero Project * Copyright (c) 2014-2021 The Monero Project
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -18,28 +18,33 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "base/crypto/keccak.h" #include "base/crypto/keccak.h"
#include "base/tools/cryptonote/Signatures.h" #include "base/tools/cryptonote/Signatures.h"
#include "base/tools/Cvt.h"
extern "C" { extern "C" {
#ifdef XMRIG_LEGACY
# include "base/tools/cryptonote/crypto-ops.h" # include "base/tools/cryptonote/crypto-ops.h"
#else
# include "3rdparty/cryptonote/crypto-ops.h"
#endif
} }
#include "base/tools/Cvt.h" #if defined(XMRIG_PROXY_PROJECT) || !defined(XMRIG_PROFILER_H)
#ifdef XMRIG_PROXY_PROJECT
# define PROFILE_SCOPE(x) # define PROFILE_SCOPE(x)
#else #else
# include "crypto/rx/Profiler.h" # include "crypto/rx/Profiler.h"
#endif #endif
struct ec_scalar { char data[32]; }; namespace xmrig {
struct hash { char data[32]; };
struct ec_point { char data[32]; };
struct ec_scalar { uint8_t data[32]; };
struct hash { uint8_t data[32]; };
struct ec_point { uint8_t data[32]; };
struct signature { ec_scalar c, r; }; struct signature { ec_scalar c, r; };
struct s_comm { hash h; ec_point key; ec_point comm; }; struct s_comm { hash h; ec_point key; ec_point comm; };
@ -48,15 +53,15 @@ static inline void random_scalar(ec_scalar& res)
{ {
// Don't care about bias or possible 0 after reduce: probability ~10^-76, not happening in this universe. // Don't care about bias or possible 0 after reduce: probability ~10^-76, not happening in this universe.
// Performance matters more. It's a miner after all. // Performance matters more. It's a miner after all.
xmrig::Cvt::randomBytes(res.data, sizeof(res.data)); Cvt::randomBytes(res.data, sizeof(res.data));
sc_reduce32((uint8_t*) res.data); sc_reduce32(res.data);
} }
static void hash_to_scalar(const void* data, size_t length, ec_scalar &res) static void hash_to_scalar(const void* data, size_t length, ec_scalar &res)
{ {
xmrig::keccak((const uint8_t*) data, length, (uint8_t*) &res, sizeof(res)); keccak(reinterpret_cast<const uint8_t*>(data), length, res.data, sizeof(res));
sc_reduce32((uint8_t*) &res); sc_reduce32(res.data);
} }
@ -81,10 +86,11 @@ static void derivation_to_scalar(const uint8_t* derivation, size_t output_index,
} }
namespace xmrig { } // namespace xmrig
void generate_signature(const uint8_t* prefix_hash, const uint8_t* pub, const uint8_t* sec, uint8_t* sig_bytes) // NOLINTNEXTLINE(readability-non-const-parameter)
void xmrig::generate_signature(const uint8_t *prefix_hash, const uint8_t *pub, const uint8_t *sec, uint8_t *sig_bytes)
{ {
PROFILE_SCOPE(GenerateSignature); PROFILE_SCOPE(GenerateSignature);
@ -99,20 +105,20 @@ void generate_signature(const uint8_t* prefix_hash, const uint8_t* pub, const ui
do { do {
random_scalar(k); random_scalar(k);
ge_scalarmult_base(&tmp3, (unsigned char*)&k); ge_scalarmult_base(&tmp3, k.data);
ge_p3_tobytes((unsigned char*)&buf.comm, &tmp3); ge_p3_tobytes(buf.comm.data, &tmp3);
hash_to_scalar(&buf, sizeof(s_comm), sig.c); hash_to_scalar(&buf, sizeof(s_comm), sig.c);
if (!sc_isnonzero((const unsigned char*)sig.c.data)) { if (!sc_isnonzero(sig.c.data)) {
continue; continue;
} }
sc_mulsub((unsigned char*)&sig.r, (unsigned char*)&sig.c, sec, (unsigned char*)&k); sc_mulsub(sig.r.data, sig.c.data, sec, k.data);
} while (!sc_isnonzero((const unsigned char*)sig.r.data)); } while (!sc_isnonzero(sig.r.data));
} }
bool check_signature(const uint8_t* prefix_hash, const uint8_t* pub, const uint8_t* sig_bytes) bool xmrig::check_signature(const uint8_t *prefix_hash, const uint8_t *pub, const uint8_t *sig_bytes)
{ {
ge_p2 tmp2; ge_p2 tmp2;
ge_p3 tmp3; ge_p3 tmp3;
@ -128,12 +134,12 @@ bool check_signature(const uint8_t* prefix_hash, const uint8_t* pub, const uint8
const signature &sig = *reinterpret_cast<const signature *>(sig_bytes); const signature &sig = *reinterpret_cast<const signature *>(sig_bytes);
if (sc_check((const uint8_t*)&sig.c) != 0 || sc_check((const uint8_t*)&sig.r) != 0 || !sc_isnonzero((const uint8_t*)&sig.c)) { if (sc_check(sig.c.data) != 0 || sc_check(sig.r.data) != 0 || !sc_isnonzero(sig.c.data)) {
return false; return false;
} }
ge_double_scalarmult_base_vartime(&tmp2, (const uint8_t*)&sig.c, &tmp3, (const uint8_t*)&sig.r); ge_double_scalarmult_base_vartime(&tmp2, sig.c.data, &tmp3, sig.r.data);
ge_tobytes((uint8_t*)&buf.comm, &tmp2); ge_tobytes(buf.comm.data, &tmp2);
static const ec_point infinity = { { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; static const ec_point infinity = { { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} };
if (memcmp(&buf.comm, &infinity, 32) == 0) { if (memcmp(&buf.comm, &infinity, 32) == 0) {
@ -141,13 +147,13 @@ bool check_signature(const uint8_t* prefix_hash, const uint8_t* pub, const uint8
} }
hash_to_scalar(&buf, sizeof(s_comm), c); hash_to_scalar(&buf, sizeof(s_comm), c);
sc_sub((uint8_t*)&c, (uint8_t*)&c, (const uint8_t*)&sig.c); sc_sub(c.data, c.data, sig.c.data);
return sc_isnonzero((uint8_t*)&c) == 0; return sc_isnonzero(c.data) == 0;
} }
bool generate_key_derivation(const uint8_t* key1, const uint8_t* key2, uint8_t* derivation) bool xmrig::generate_key_derivation(const uint8_t *key1, const uint8_t *key2, uint8_t *derivation)
{ {
ge_p3 point; ge_p3 point;
ge_p2 point2; ge_p2 point2;
@ -166,16 +172,16 @@ bool generate_key_derivation(const uint8_t* key1, const uint8_t* key2, uint8_t*
} }
void derive_secret_key(const uint8_t* derivation, size_t output_index, const uint8_t* base, uint8_t* derived_key) void xmrig::derive_secret_key(const uint8_t *derivation, size_t output_index, const uint8_t *base, uint8_t *derived_key)
{ {
ec_scalar scalar; ec_scalar scalar;
derivation_to_scalar(derivation, output_index, scalar); derivation_to_scalar(derivation, output_index, scalar);
sc_add(derived_key, base, (uint8_t*) &scalar); sc_add(derived_key, base, scalar.data);
} }
bool derive_public_key(const uint8_t* derivation, size_t output_index, const uint8_t* base, uint8_t* derived_key) bool xmrig::derive_public_key(const uint8_t *derivation, size_t output_index, const uint8_t *base, uint8_t *derived_key)
{ {
ec_scalar scalar; ec_scalar scalar;
ge_p3 point1; ge_p3 point1;
@ -189,7 +195,7 @@ bool derive_public_key(const uint8_t* derivation, size_t output_index, const uin
} }
derivation_to_scalar(derivation, output_index, scalar); derivation_to_scalar(derivation, output_index, scalar);
ge_scalarmult_base(&point2, (uint8_t*) &scalar); ge_scalarmult_base(&point2, scalar.data);
ge_p3_to_cached(&point3, &point2); ge_p3_to_cached(&point3, &point2);
ge_add(&point4, &point1, &point3); ge_add(&point4, &point1, &point3);
ge_p1p1_to_p2(&point5, &point4); ge_p1p1_to_p2(&point5, &point4);
@ -199,14 +205,14 @@ bool derive_public_key(const uint8_t* derivation, size_t output_index, const uin
} }
void derive_view_secret_key(const uint8_t* spend_secret_key, uint8_t* view_secret_key) void xmrig::derive_view_secret_key(const uint8_t *spend_secret_key, uint8_t *view_secret_key)
{ {
keccak(spend_secret_key, 32, view_secret_key, 32); keccak(spend_secret_key, 32, view_secret_key, 32);
sc_reduce32(view_secret_key); sc_reduce32(view_secret_key);
} }
void generate_keys(uint8_t* pub, uint8_t* sec) void xmrig::generate_keys(uint8_t *pub, uint8_t *sec)
{ {
random_scalar(*((ec_scalar*)sec)); random_scalar(*((ec_scalar*)sec));
@ -216,7 +222,7 @@ void generate_keys(uint8_t* pub, uint8_t* sec)
} }
bool secret_key_to_public_key(const uint8_t* sec, uint8_t* pub) bool xmrig::secret_key_to_public_key(const uint8_t *sec, uint8_t *pub)
{ {
if (sc_check(sec) != 0) { if (sc_check(sec) != 0) {
return false; return false;
@ -228,6 +234,3 @@ bool secret_key_to_public_key(const uint8_t* sec, uint8_t* pub)
return true; return true;
} }
} /* namespace xmrig */

View file

@ -1,8 +1,8 @@
/* XMRig /* XMRig
* Copyright 2012-2013 The Cryptonote developers * Copyright (c) 2012-2013 The Cryptonote developers
* Copyright 2014-2021 The Monero Project * Copyright (c) 2014-2021 The Monero Project
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -29,7 +29,7 @@ namespace xmrig {
void generate_signature(const uint8_t *prefix_hash, const uint8_t *pub, const uint8_t *sec, uint8_t *sig); void generate_signature(const uint8_t *prefix_hash, const uint8_t *pub, const uint8_t *sec, uint8_t *sig);
bool check_signature(const uint8_t* prefix_hash, const uint8_t* pub, const uint8_t* sig); bool check_signature(const uint8_t *prefix_hash, const uint8_t *pub, const uint8_t *sig_bytes);
bool generate_key_derivation(const uint8_t *key1, const uint8_t *key2, uint8_t *derivation); bool generate_key_derivation(const uint8_t *key1, const uint8_t *key2, uint8_t *derivation);
void derive_secret_key(const uint8_t *derivation, size_t output_index, const uint8_t *base, uint8_t *derived_key); void derive_secret_key(const uint8_t *derivation, size_t output_index, const uint8_t *base, uint8_t *derived_key);
@ -40,7 +40,7 @@ void derive_view_secret_key(const uint8_t* spend_secret_key, uint8_t* view_secre
void generate_keys(uint8_t *pub, uint8_t *sec); void generate_keys(uint8_t *pub, uint8_t *sec);
bool secret_key_to_public_key(const uint8_t *sec, uint8_t *pub); bool secret_key_to_public_key(const uint8_t *sec, uint8_t *pub);
} /* namespace xmrig */ } // namespace xmrig
#endif /* XMRIG_SIGNATURES_H */ #endif // XMRIG_SIGNATURES_H

View file

@ -1,8 +1,11 @@
/* /* XMRig
* Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -18,16 +21,12 @@
* it with OpenSSL (or a modified version of that library), containing parts * it with OpenSSL (or a modified version of that library), containing parts
* covered by the terms of OpenSSL License and SSLeay License, the licensors * covered by the terms of OpenSSL License and SSLeay License, the licensors
* of this Program grant you additional permission to convey the resulting work. * of this Program grant you additional permission to convey the resulting work.
*
*/ */
#ifndef XMRIG_UMUL128_H #ifndef XMRIG_UMUL128_H
#define XMRIG_UMUL128_H #define XMRIG_UMUL128_H
#include "version.h"
#include <cstdint> #include <cstdint>
@ -72,7 +71,7 @@ static inline uint64_t xmrig_umul128(uint64_t multiplier, uint64_t multiplicand,
#endif #endif
#if !defined(XMRIG_BASE_VERSION) #if defined(XMRIG_LEGACY)
# define __umul128 xmrig_umul128 # define __umul128 xmrig_umul128
#endif #endif

View file

@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -22,19 +22,20 @@
#include "core/Miner.h" #include "core/Miner.h"
#include "core/Taskbar.h"
#include "3rdparty/rapidjson/document.h" #include "3rdparty/rapidjson/document.h"
#include "backend/common/Hashrate.h" #include "backend/common/Hashrate.h"
#include "backend/cpu/Cpu.h" #include "backend/cpu/Cpu.h"
#include "backend/cpu/CpuBackend.h" #include "backend/cpu/CpuBackend.h"
#include "base/io/log/Log.h" #include "base/io/log/Log.h"
#include "base/io/log/Tags.h" #include "base/io/log/Tags.h"
#include "base/kernel/Platform.h" #include "base/kernel/OS.h"
#include "base/kernel/Process.h"
#include "base/net/stratum/Job.h" #include "base/net/stratum/Job.h"
#include "base/tools/Object.h" #include "base/tools/Object.h"
#include "base/tools/Timer.h" #include "base/tools/Timer.h"
#include "core/config/Config.h" #include "core/config/Config.h"
#include "core/Controller.h" #include "core/Controller.h"
#include "core/Taskbar.h"
#include "crypto/common/Nonce.h" #include "crypto/common/Nonce.h"
#include "version.h" #include "version.h"
@ -154,7 +155,7 @@ public:
reply.AddMember("version", APP_VERSION, allocator); reply.AddMember("version", APP_VERSION, allocator);
reply.AddMember("kind", APP_KIND, allocator); reply.AddMember("kind", APP_KIND, allocator);
reply.AddMember("ua", Platform::userAgent().toJSON(), allocator); reply.AddMember("ua", Process::userAgent().toJSON(), allocator);
reply.AddMember("cpu", Cpu::toJSON(doc), allocator); reply.AddMember("cpu", Cpu::toJSON(doc), allocator);
reply.AddMember("donate_level", controller->config()->pools().donateLevel(), allocator); reply.AddMember("donate_level", controller->config()->pools().donateLevel(), allocator);
reply.AddMember("paused", !enabled, allocator); reply.AddMember("paused", !enabled, allocator);
@ -387,8 +388,8 @@ xmrig::Miner::Miner(Controller *controller)
{ {
const int priority = controller->config()->cpu().priority(); const int priority = controller->config()->cpu().priority();
if (priority >= 0) { if (priority >= 0) {
Platform::setProcessPriority(priority); OS::setProcessPriority(priority);
Platform::setThreadPriority(std::min(priority + 1, 5)); OS::setThreadPriority(std::min(priority + 1, 5));
} }
# ifdef XMRIG_FEATURE_PROFILING # ifdef XMRIG_FEATURE_PROFILING
@ -669,11 +670,11 @@ void xmrig::Miner::onTimer(const Timer *)
}; };
if (config->isPauseOnBattery()) { if (config->isPauseOnBattery()) {
autoPause(d_ptr->battery_power, Platform::isOnBatteryPower(), YELLOW_BOLD("on battery power"), GREEN_BOLD("on AC power")); autoPause(d_ptr->battery_power, OS::isOnBatteryPower(), YELLOW_BOLD("on battery power"), GREEN_BOLD("on AC power"));
} }
if (config->isPauseOnActive()) { if (config->isPauseOnActive()) {
autoPause(d_ptr->user_active, Platform::isUserActive(config->idleTime()), YELLOW_BOLD("user active"), GREEN_BOLD("user inactive")); autoPause(d_ptr->user_active, OS::isUserActive(config->idleTime()), YELLOW_BOLD("user active"), GREEN_BOLD("user inactive"));
} }
if (stopMiner) { if (stopMiner) {

View file

@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View file

@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "ghostrider.h" #include "ghostrider.h"
#include "sph_blake.h" #include "sph_blake.h"
#include "sph_bmw.h" #include "sph_bmw.h"
@ -48,7 +47,7 @@
#include <uv.h> #include <uv.h>
#ifdef XMRIG_FEATURE_HWLOC #ifdef XMRIG_FEATURE_HWLOC
#include "base/kernel/Platform.h" #include "base/kernel/OS.h"
#include "backend/cpu/platform/HwlocCpuInfo.h" #include "backend/cpu/platform/HwlocCpuInfo.h"
#include <hwloc.h> #include <hwloc.h>
#endif #endif
@ -241,7 +240,7 @@ struct HelperThread
} }
} }
Platform::setThreadPriority(m_priority); OS::setThreadPriority(m_priority);
uv_mutex_lock(&m_mutex); uv_mutex_lock(&m_mutex);
m_ready = true; m_ready = true;
@ -299,8 +298,8 @@ void benchmark()
std::swap(thread_index1, thread_index2); std::swap(thread_index1, thread_index2);
} }
Platform::setThreadAffinity(thread_index1); OS::setThreadAffinity(thread_index1);
Platform::setThreadPriority(3); OS::setThreadPriority(3);
constexpr uint32_t N = 1U << 21; constexpr uint32_t N = 1U << 21;

View file

@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2019 tevador <tevador@gmail.com> * Copyright (c) 2018-2019 tevador <tevador@gmail.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,7 +21,7 @@
#include "backend/cpu/Cpu.h" #include "backend/cpu/Cpu.h"
#include "base/io/log/Log.h" #include "base/io/log/Log.h"
#include "base/io/log/Tags.h" #include "base/io/log/Tags.h"
#include "base/kernel/Platform.h" #include "base/kernel/OS.h"
#include "crypto/common/VirtualMemory.h" #include "crypto/common/VirtualMemory.h"
#include "crypto/randomx/randomx.h" #include "crypto/randomx/randomx.h"
#include "crypto/rx/RxAlgo.h" #include "crypto/rx/RxAlgo.h"
@ -37,7 +37,7 @@ namespace xmrig {
static void init_dataset_wrapper(randomx_dataset *dataset, randomx_cache *cache, uint32_t startItem, uint32_t itemCount, int priority) static void init_dataset_wrapper(randomx_dataset *dataset, randomx_cache *cache, uint32_t startItem, uint32_t itemCount, int priority)
{ {
Platform::setThreadPriority(priority); OS::setThreadPriority(priority);
if (Cpu::info()->hasAVX2() && (itemCount % 5)) { if (Cpu::info()->hasAVX2() && (itemCount % 5)) {
randomx_init_dataset(dataset, cache, startItem, itemCount - (itemCount % 5)); randomx_init_dataset(dataset, cache, startItem, itemCount - (itemCount % 5));

View file

@ -1,7 +1,7 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2019 tevador <tevador@gmail.com> * Copyright (c) 2018-2019 tevador <tevador@gmail.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2019 tevador <tevador@gmail.com> * Copyright (c) 2018-2019 tevador <tevador@gmail.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -22,7 +22,7 @@
#include "backend/cpu/platform/HwlocCpuInfo.h" #include "backend/cpu/platform/HwlocCpuInfo.h"
#include "base/io/log/Log.h" #include "base/io/log/Log.h"
#include "base/io/log/Tags.h" #include "base/io/log/Tags.h"
#include "base/kernel/Platform.h" #include "base/kernel/OS.h"
#include "base/tools/Chrono.h" #include "base/tools/Chrono.h"
#include "crypto/rx/RxAlgo.h" #include "crypto/rx/RxAlgo.h"
#include "crypto/rx/RxCache.h" #include "crypto/rx/RxCache.h"
@ -52,7 +52,7 @@ static bool bindToNUMANode(uint32_t nodeId)
} }
if (cpu->membind(node->nodeset)) { if (cpu->membind(node->nodeset)) {
Platform::setThreadAffinity(static_cast<uint64_t>(hwloc_bitmap_first(node->cpuset))); OS::setThreadAffinity(static_cast<uint64_t>(hwloc_bitmap_first(node->cpuset)));
return true; return true;
} }

View file

@ -1,7 +1,7 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2019 tevador <tevador@gmail.com> * Copyright (c) 2018-2019 tevador <tevador@gmail.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View file

@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,11 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "hw/msr/Msr.h" #include "hw/msr/Msr.h"
#include "backend/cpu/Cpu.h" #include "backend/cpu/Cpu.h"
#include "base/io/log/Log.h" #include "base/io/log/Log.h"
#include "base/kernel/Platform.h" #include "base/kernel/OS.h"
#include <string> #include <string>
@ -213,7 +212,7 @@ bool xmrig::Msr::write(Callback &&callback)
std::thread thread([&callback, &units, &success]() { std::thread thread([&callback, &units, &success]() {
for (int32_t pu : units) { for (int32_t pu : units) {
if (!Platform::setThreadAffinity(pu)) { if (!OS::setThreadAffinity(pu)) {
continue; continue;
} }

View file

@ -24,7 +24,7 @@
#include "net/strategies/DonateStrategy.h" #include "net/strategies/DonateStrategy.h"
#include "3rdparty/rapidjson/document.h" #include "3rdparty/rapidjson/document.h"
#include "base/crypto/keccak.h" #include "base/crypto/keccak.h"
#include "base/kernel/Platform.h" #include "base/kernel/Process.h"
#include "base/net/stratum/Client.h" #include "base/net/stratum/Client.h"
#include "base/net/stratum/Job.h" #include "base/net/stratum/Job.h"
#include "base/net/stratum/strategies/FailoverStrategy.h" #include "base/net/stratum/strategies/FailoverStrategy.h"
@ -262,7 +262,7 @@ xmrig::IClient *xmrig::DonateStrategy::createProxy()
pool.setAlgo(client->pool().algorithm()); pool.setAlgo(client->pool().algorithm());
pool.setProxy(client->pool().proxy()); pool.setProxy(client->pool().proxy());
IClient *proxy = new Client(-1, Platform::userAgent(), this); IClient *proxy = new Client(-1, Process::userAgent(), this);
proxy->setPool(pool); proxy->setPool(pool);
proxy->setQuiet(true); proxy->setQuiet(true);

View file

@ -14,6 +14,13 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional permission under GNU GPL version 3 section 7
*
* If you modify this Program, or any covered work, by linking or combining
* it with OpenSSL (or a modified version of that library), containing parts
* covered by the terms of OpenSSL License and SSLeay License, the licensors
* of this Program grant you additional permission to convey the resulting work.
*/ */
#ifndef XMRIG_VERSION_H #ifndef XMRIG_VERSION_H
@ -22,34 +29,12 @@
#define APP_ID "xmrig" #define APP_ID "xmrig"
#define APP_NAME "XMRig" #define APP_NAME "XMRig"
#define APP_DESC "XMRig miner" #define APP_DESC "XMRig miner"
#define APP_VERSION "6.17.1-dev"
#define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2022 xmrig.com"
#define APP_KIND "miner" #define APP_KIND "miner"
#define APP_VER_MAJOR 6 #define APP_VER_MAJOR 6
#define APP_VER_MINOR 17 #define APP_VER_MINOR 99
#define APP_VER_PATCH 1 #define APP_VER_PATCH 0
#ifdef _MSC_VER #include "base/kernel/base-version.h"
# if (_MSC_VER >= 1930)
# define MSVC_VERSION 2022
# elif (_MSC_VER >= 1920 && _MSC_VER < 1930)
# define MSVC_VERSION 2019
# elif (_MSC_VER >= 1910 && _MSC_VER < 1920)
# define MSVC_VERSION 2017
# elif _MSC_VER == 1900
# define MSVC_VERSION 2015
# elif _MSC_VER == 1800
# define MSVC_VERSION 2013
# elif _MSC_VER == 1700
# define MSVC_VERSION 2012
# elif _MSC_VER == 1600
# define MSVC_VERSION 2010
# else
# define MSVC_VERSION 0
# endif
#endif
#endif /* XMRIG_VERSION_H */ #endif /* XMRIG_VERSION_H */