v29.4-roots.2 · Commit 2: [PATCH 02/21] runtime: preserve shared operator controls
src/util/ioprio.h
Before: /dev/null · After: src/util/ioprio.h
File metadata
new file mode 100644 index 0000000000000000000000000000000000000000..e0f6f557149409865d1123a3aaa60ce83add4eb6
Download original patch · Release notes
Diff rows 1–61 of 61. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
src/util/ioprio.h
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright (c) 2016 Satoshi Nakamoto
|
| 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 BITCOIN_UTIL_IOPRIO_H
|
| 6 |
+
#define BITCOIN_UTIL_IOPRIO_H
|
| 7 |
+
|
| 8 |
+
#include <bitcoin-build-config.h> // IWYU pragma: keep
|
| 9 |
+
|
| 10 |
+
#include <logging.h>
|
| 11 |
+
|
| 12 |
+
#if HAVE_IOPRIO_SYSCALL || HAVE_IOPOLICY
|
| 13 |
+
int ioprio_get();
|
| 14 |
+
int ioprio_set(int ioprio);
|
| 15 |
+
int ioprio_set_idle();
|
| 16 |
+
|
| 17 |
+
class ioprio_idler {
|
| 18 |
+
private:
|
| 19 |
+
int orig;
|
| 20 |
+
|
| 21 |
+
public:
|
| 22 |
+
ioprio_idler(const bool lowprio) {
|
| 23 |
+
if (!lowprio) {
|
| 24 |
+
orig = -1;
|
| 25 |
+
return;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
orig = ioprio_get();
|
| 29 |
+
if (orig == -1) {
|
| 30 |
+
return;
|
| 31 |
+
}
|
| 32 |
+
if (ioprio_set_idle() == -1) {
|
| 33 |
+
orig = -1;
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
~ioprio_idler() {
|
| 38 |
+
if (orig == -1) {
|
| 39 |
+
return;
|
| 40 |
+
}
|
| 41 |
+
if (ioprio_set(orig) == -1) {
|
| 42 |
+
LogPrintf("failed to restore ioprio\n");
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
};
|
| 46 |
+
#define IOPRIO_IDLER(lowprio) ioprio_idler ioprio_idler_(lowprio)
|
| 47 |
+
|
| 48 |
+
#else
|
| 49 |
+
#define ioprio_get() ((void)-1)
|
| 50 |
+
#define ioprio_set(ioprio) ((void)-1)
|
| 51 |
+
#define ioprio_set_idle() ((void)-1)
|
| 52 |
+
#define IOPRIO_IDLER(lowprio) (void)lowprio;
|
| 53 |
+
#endif
|
| 54 |
+
|
| 55 |
+
#if HAVE_WINDOWS_IOPRIO
|
| 56 |
+
bool ioprio_set_file_idle(FILE *);
|
| 57 |
+
#else
|
| 58 |
+
#define ioprio_set_file_idle(f) ((void)false)
|
| 59 |
+
#endif
|
| 60 |
+
|
| 61 |
+
#endif // BITCOIN_UTIL_IOPRIO_H
|