Skip to content

Commit aab151d

Browse files
author
timemarkovqtum
committed
Fix guix build windows
1 parent 90612c8 commit aab151d

File tree

4 files changed

+47
-30
lines changed

4 files changed

+47
-30
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ BITCOIN_CORE_H = \
158158
compat/endian.h \
159159
common/settings.h \
160160
common/system.h \
161+
common/threadpriority.h \
161162
compressor.h \
162163
consensus/consensus.h \
163164
consensus/tx_check.h \

src/common/system.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313
#include <cstdint>
1414
#include <string>
1515

16-
#ifndef WIN32
17-
#include <sys/types.h>
18-
#include <sys/time.h>
19-
#include <sys/resource.h>
20-
#endif
21-
2216
// Application startup time (used for uptime calculation)
2317
int64_t GetStartupTime();
2418

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

40-
#ifdef WIN32
41-
inline void SetThreadPriority(int nPriority)
42-
{
43-
SetThreadPriority(GetCurrentThread(), nPriority);
44-
}
45-
#else
46-
47-
#define THREAD_PRIORITY_LOWEST PRIO_MAX
48-
#define THREAD_PRIORITY_BELOW_NORMAL 2
49-
#define THREAD_PRIORITY_NORMAL 0
50-
#define THREAD_PRIORITY_ABOVE_NORMAL 0
51-
52-
inline void SetThreadPriority(int nPriority)
53-
{
54-
// It's unclear if it's even possible to change thread priorities on Linux,
55-
// but we really and truly need it for the generation threads.
56-
#ifdef PRIO_THREAD
57-
setpriority(PRIO_THREAD, 0, nPriority);
58-
#else
59-
setpriority(PRIO_PROCESS, 0, nPriority);
60-
#endif
61-
}
62-
#endif
63-
6434
bool CheckHex(const std::string& str);
6535

6636
#endif // BITCOIN_COMMON_SYSTEM_H

src/common/threadpriority.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright (c) 2024-present The Qtum Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef QTUM_THREAD_PRIORITY_H
6+
#define QTUM_THREAD_PRIORITY_H
7+
8+
#ifndef WIN32
9+
#include <sys/types.h>
10+
#include <sys/time.h>
11+
#include <sys/resource.h>
12+
#else
13+
#include <windows.h>
14+
#endif
15+
16+
#ifdef WIN32
17+
inline void SetThreadPriority(int nPriority)
18+
{
19+
HANDLE hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, GetCurrentThreadId());
20+
if (hThread != NULL)
21+
{
22+
::SetThreadPriority(hThread, nPriority);
23+
CloseHandle(hThread);
24+
}
25+
}
26+
#else
27+
28+
#define THREAD_PRIORITY_LOWEST PRIO_MAX
29+
#define THREAD_PRIORITY_BELOW_NORMAL 2
30+
#define THREAD_PRIORITY_NORMAL 0
31+
#define THREAD_PRIORITY_ABOVE_NORMAL 0
32+
33+
inline void SetThreadPriority(int nPriority)
34+
{
35+
// It's unclear if it's even possible to change thread priorities on Linux,
36+
// but we really and truly need it for the generation threads.
37+
#ifdef PRIO_THREAD
38+
setpriority(PRIO_THREAD, 0, nPriority);
39+
#else
40+
setpriority(PRIO_PROCESS, 0, nPriority);
41+
#endif
42+
}
43+
#endif
44+
45+
#endif // QTUM_THREAD_PRIORITY_H

src/node/miner.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <chainparams.h>
1010
#include <coins.h>
1111
#include <common/args.h>
12+
#include <common/threadpriority.h>
1213
#include <consensus/amount.h>
1314
#include <consensus/consensus.h>
1415
#include <consensus/merkle.h>

0 commit comments

Comments
 (0)