mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-31 16:09:46 +00:00
commit
f9c0933f05
14 changed files with 40 additions and 33 deletions
2
src/3rdparty/fmt/format-inl.h
vendored
2
src/3rdparty/fmt/format-inl.h
vendored
|
@ -1754,7 +1754,7 @@ inline bool divisible_by_power_of_2(uint64_t x, int exp) FMT_NOEXCEPT {
|
|||
#ifdef FMT_BUILTIN_CTZLL
|
||||
return FMT_BUILTIN_CTZLL(x) >= exp;
|
||||
#else
|
||||
return exp < num_bits<uint64_t>()) && x == ((x >> exp) << exp);
|
||||
return (exp < num_bits<uint64_t>()) && x == ((x >> exp) << exp);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ private:
|
|||
}
|
||||
|
||||
|
||||
static std::string merge(std::string a, std::string b, uint32_t r)
|
||||
static std::string merge(const std::string& a, const std::string& b, uint32_t r)
|
||||
{
|
||||
switch (r % 4)
|
||||
{
|
||||
|
@ -323,7 +323,7 @@ private:
|
|||
}
|
||||
|
||||
|
||||
static std::string math(std::string d, std::string a, std::string b, uint32_t r)
|
||||
static std::string math(const std::string& d, const std::string& a, const std::string& b, uint32_t r)
|
||||
{
|
||||
switch (r % 11)
|
||||
{
|
||||
|
|
|
@ -836,7 +836,13 @@ xmrig::String xmrig::OclLib::getProgramBuildLog(cl_program program, cl_device_id
|
|||
return String();
|
||||
}
|
||||
|
||||
char *log = new char[size + 1]();
|
||||
char* log = nullptr;
|
||||
try {
|
||||
log = new char[size + 1]();
|
||||
}
|
||||
catch (...) {
|
||||
return String();
|
||||
}
|
||||
|
||||
if (getProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, size, log, nullptr) != CL_SUCCESS) {
|
||||
delete [] log;
|
||||
|
|
|
@ -56,8 +56,8 @@ void xmrig::LineReader::reset()
|
|||
|
||||
void xmrig::LineReader::add(const char *data, size_t size)
|
||||
{
|
||||
if (size > XMRIG_NET_BUFFER_CHUNK_SIZE - m_pos) {
|
||||
// it breakes correctness silently for long lines
|
||||
if (size + m_pos > XMRIG_NET_BUFFER_CHUNK_SIZE) {
|
||||
// it breaks correctness silently for long lines
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ std::vector<xmrig::String> xmrig::String::split(char sep) const
|
|||
|
||||
for (pos = 0; pos < m_size; ++pos) {
|
||||
if (m_data[pos] == sep) {
|
||||
if ((pos - start) > 0) {
|
||||
if (pos > start) {
|
||||
out.emplace_back(m_data + start, pos - start);
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ std::vector<xmrig::String> xmrig::String::split(char sep) const
|
|||
}
|
||||
}
|
||||
|
||||
if ((pos - start) > 0) {
|
||||
if (pos > start) {
|
||||
out.emplace_back(m_data + start, pos - start);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ Return value: TRUE indicates success, FALSE failure.
|
|||
static BOOL SetLockPagesPrivilege() {
|
||||
HANDLE token;
|
||||
|
||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token) != TRUE) {
|
||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -71,12 +71,12 @@ static BOOL SetLockPagesPrivilege() {
|
|||
tp.PrivilegeCount = 1;
|
||||
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
if (LookupPrivilegeValue(nullptr, SE_LOCK_MEMORY_NAME, &(tp.Privileges[0].Luid)) != TRUE) {
|
||||
if (!LookupPrivilegeValue(nullptr, SE_LOCK_MEMORY_NAME, &(tp.Privileges[0].Luid))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL rc = AdjustTokenPrivileges(token, FALSE, (PTOKEN_PRIVILEGES) &tp, 0, nullptr, nullptr);
|
||||
if (rc != TRUE || GetLastError() != ERROR_SUCCESS) {
|
||||
if (!rc || GetLastError() != ERROR_SUCCESS) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ static BOOL ObtainLockPagesPrivilege() {
|
|||
HANDLE token;
|
||||
PTOKEN_USER user = nullptr;
|
||||
|
||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token) == TRUE) {
|
||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) {
|
||||
DWORD size = 0;
|
||||
|
||||
GetTokenInformation(token, TokenUser, nullptr, 0, &size);
|
||||
|
|
|
@ -28,6 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
|
||||
#include "crypto/randomx/aes_hash.hpp"
|
||||
#include "base/tools/Chrono.h"
|
||||
|
@ -371,7 +372,7 @@ hashAndFillAes1Rx4_impl* softAESImpl = &hashAndFillAes1Rx4<1,1>;
|
|||
void SelectSoftAESImpl(size_t threadsCount)
|
||||
{
|
||||
constexpr int test_length_ms = 100;
|
||||
const std::vector<hashAndFillAes1Rx4_impl *> impl = {
|
||||
const std::array<hashAndFillAes1Rx4_impl *, 4> impl = {
|
||||
&hashAndFillAes1Rx4<1,1>,
|
||||
&hashAndFillAes1Rx4<2,1>,
|
||||
&hashAndFillAes1Rx4<2,2>,
|
||||
|
|
|
@ -48,7 +48,7 @@ struct randomx_cache {
|
|||
randomx::DatasetInitFunc* datasetInit;
|
||||
randomx::SuperscalarProgram programs[RANDOMX_CACHE_MAX_ACCESSES];
|
||||
|
||||
bool isInitialized() {
|
||||
bool isInitialized() const {
|
||||
return programs[0].getSize() != 0;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1076,7 +1076,7 @@ namespace randomx {
|
|||
pos += 2;
|
||||
}
|
||||
else {
|
||||
*(uint64_t*)(p + pos) = 0x840f + ((static_cast<int64_t>(jmp_offset) - 4) << 16);
|
||||
*(uint64_t*)(p + pos) = 0x840f + (static_cast<uint64_t>(jmp_offset - 4) << 16);
|
||||
pos += 6;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,11 +68,11 @@ namespace randomx {
|
|||
|
||||
alignas(64) static InstructionGeneratorX86 engine[256];
|
||||
|
||||
int registerUsage[RegistersCount];
|
||||
uint8_t* code;
|
||||
uint32_t codePos;
|
||||
uint32_t codePosFirst;
|
||||
uint32_t vm_flags;
|
||||
int registerUsage[RegistersCount] = {};
|
||||
uint8_t* code = nullptr;
|
||||
uint32_t codePos = 0;
|
||||
uint32_t codePosFirst = 0;
|
||||
uint32_t vm_flags = 0;
|
||||
|
||||
# ifdef XMRIG_FIX_RYZEN
|
||||
std::pair<const void*, const void*> mainLoopBounds;
|
||||
|
|
|
@ -282,11 +282,11 @@ namespace randomx {
|
|||
return fetchNextDefault(gen);
|
||||
}
|
||||
private:
|
||||
const char* name_;
|
||||
int index_;
|
||||
const int* counts_;
|
||||
int opsCount_;
|
||||
DecoderBuffer() : index_(-1) {}
|
||||
const char* name_ = nullptr;
|
||||
int index_ = -1;
|
||||
const int* counts_ = nullptr;
|
||||
int opsCount_ = 0;
|
||||
DecoderBuffer() = default;
|
||||
static const DecoderBuffer decodeBuffer484;
|
||||
static const DecoderBuffer decodeBuffer7333;
|
||||
static const DecoderBuffer decodeBuffer3733;
|
||||
|
@ -555,10 +555,10 @@ namespace randomx {
|
|||
const SuperscalarInstructionInfo* info_;
|
||||
int src_ = -1;
|
||||
int dst_ = -1;
|
||||
int mod_;
|
||||
uint32_t imm32_;
|
||||
SuperscalarInstructionType opGroup_;
|
||||
int opGroupPar_;
|
||||
int mod_ = 0;
|
||||
uint32_t imm32_ = 0;
|
||||
SuperscalarInstructionType opGroup_ = SuperscalarInstructionType::INVALID;
|
||||
int opGroupPar_ = 0;
|
||||
bool canReuse_ = false;
|
||||
bool groupParIsSource_ = false;
|
||||
|
||||
|
|
|
@ -39,13 +39,13 @@ namespace randomx {
|
|||
Instruction& operator()(int pc) {
|
||||
return programBuffer[pc];
|
||||
}
|
||||
uint32_t getSize() {
|
||||
uint32_t getSize() const {
|
||||
return size;
|
||||
}
|
||||
void setSize(uint32_t val) {
|
||||
size = val;
|
||||
}
|
||||
int getAddressRegister() {
|
||||
int getAddressRegister() const {
|
||||
return addrReg;
|
||||
}
|
||||
void setAddressRegister(int val) {
|
||||
|
|
|
@ -155,7 +155,7 @@ void xmrig::RxQueue::backgroundInit()
|
|||
|
||||
m_storage->init(item.seed, item.threads, item.hugePages, item.oneGbPages, item.mode, item.priority);
|
||||
|
||||
lock = std::unique_lock<std::mutex>(m_mutex);
|
||||
lock.lock();
|
||||
|
||||
if (m_state == STATE_SHUTDOWN || !m_queue.empty()) {
|
||||
continue;
|
||||
|
|
|
@ -103,7 +103,7 @@ static bool wrmsr_on_cpu(uint32_t reg, uint32_t cpu, uint64_t value, uint64_t ma
|
|||
|
||||
char msr_file_name[64]{};
|
||||
|
||||
sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
|
||||
sprintf(msr_file_name, "/dev/cpu/%u/msr", cpu);
|
||||
int fd = open(msr_file_name, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue