Skip to content

Commit

Permalink
Merge branch core27 into evmone
Browse files Browse the repository at this point in the history
  • Loading branch information
timemarkovqtum committed Sep 17, 2024
2 parents d7dba86 + aab151d commit 3bb7ccb
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 184 deletions.
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ BITCOIN_CORE_H = \
compat/endian.h \
common/settings.h \
common/system.h \
common/threadpriority.h \
compressor.h \
consensus/consensus.h \
consensus/tx_check.h \
Expand Down
30 changes: 0 additions & 30 deletions src/common/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
#include <cstdint>
#include <string>

#ifndef WIN32
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#endif

// Application startup time (used for uptime calculation)
int64_t GetStartupTime();

Expand All @@ -37,30 +31,6 @@ void runCommand(const std::string& strCommand);
*/
int GetNumCores();

#ifdef WIN32
inline void SetThreadPriority(int nPriority)
{
SetThreadPriority(GetCurrentThread(), nPriority);
}
#else

#define THREAD_PRIORITY_LOWEST PRIO_MAX
#define THREAD_PRIORITY_BELOW_NORMAL 2
#define THREAD_PRIORITY_NORMAL 0
#define THREAD_PRIORITY_ABOVE_NORMAL 0

inline void SetThreadPriority(int nPriority)
{
// It's unclear if it's even possible to change thread priorities on Linux,
// but we really and truly need it for the generation threads.
#ifdef PRIO_THREAD
setpriority(PRIO_THREAD, 0, nPriority);
#else
setpriority(PRIO_PROCESS, 0, nPriority);
#endif
}
#endif

bool CheckHex(const std::string& str);

#endif // BITCOIN_COMMON_SYSTEM_H
45 changes: 45 additions & 0 deletions src/common/threadpriority.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2024-present The Qtum Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef QTUM_THREAD_PRIORITY_H
#define QTUM_THREAD_PRIORITY_H

#ifndef WIN32
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#else
#include <windows.h>
#endif

#ifdef WIN32
inline void SetThreadPriority(int nPriority)
{
HANDLE hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, GetCurrentThreadId());
if (hThread != NULL)
{
::SetThreadPriority(hThread, nPriority);
CloseHandle(hThread);
}
}
#else

#define THREAD_PRIORITY_LOWEST PRIO_MAX
#define THREAD_PRIORITY_BELOW_NORMAL 2
#define THREAD_PRIORITY_NORMAL 0
#define THREAD_PRIORITY_ABOVE_NORMAL 0

inline void SetThreadPriority(int nPriority)
{
// It's unclear if it's even possible to change thread priorities on Linux,
// but we really and truly need it for the generation threads.
#ifdef PRIO_THREAD
setpriority(PRIO_THREAD, 0, nPriority);
#else
setpriority(PRIO_PROCESS, 0, nPriority);
#endif
}
#endif

#endif // QTUM_THREAD_PRIORITY_H
1 change: 1 addition & 0 deletions src/node/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <chainparams.h>
#include <coins.h>
#include <common/args.h>
#include <common/threadpriority.h>
#include <consensus/amount.h>
#include <consensus/consensus.h>
#include <consensus/merkle.h>
Expand Down
Loading

0 comments on commit 3bb7ccb

Please sign in to comment.