1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
https://gitlab.com/ananicy-cpp/ananicy-cpp/-/commit/99e64815bacaf3baa28ad89d022e33ebede94fa9
From: Antoine Viallon <antoine@lesviallon.fr>
Date: Thu, 3 Apr 2025 14:24:10 +0200
Subject: [PATCH] [Platform/Linux] rename sched_*attr symbols to avoid
conflicts with newer GLibc versions
(cherry picked from commit 6748f23c5f1eaf6c15cb771a3804e3e527015903)
--- a/src/platform/linux/priority.cpp
+++ b/src/platform/linux/priority.cpp
@@ -185,12 +185,12 @@ std::string_view test_latnice_support() noexcept {
// Use this here instead of function,
// to suppress errors from function call.
- struct sched_attr attr = {
- .size = sizeof(struct sched_attr),
+ struct ananicy_sched_attr attr = {
+ .size = sizeof(struct ananicy_sched_attr),
.sched_flags = SCHED_FLAG_LATENCY_NICE | SCHED_FLAG_KEEP_PARAMS,
.sched_latency_nice = latency_nice,
};
- const std::int32_t err = sched_setattr(pid, &attr, 0);
+ const std::int32_t err = ananicy_sched_setattr(pid, &attr, 0);
bool is_supported{};
if (err == 0 && errno == 0) {
set_latnice(pid, saved_latnice);
--- a/src/platform/linux/process_info.cpp
+++ b/src/platform/linux/process_info.cpp
@@ -104,16 +104,16 @@ static std::string get_sched_policy_name(unsigned sched_policy) {
}
}
-static sched_attr get_sched_attributes(process_id_t pid) {
+static ananicy_sched_attr get_sched_attributes(process_id_t pid) {
- ::sched_attr attr{};
- sched_getattr(static_cast<pid_t>(pid), &attr, sizeof(attr), 0);
+ ::ananicy_sched_attr attr{};
+ ananicy_sched_getattr(static_cast<pid_t>(pid), &attr, sizeof(attr), 0);
return attr;
}
bool is_realtime(process_id_t pid) {
- const sched_attr attr = get_sched_attributes(pid);
+ const ananicy_sched_attr attr = get_sched_attributes(pid);
return attr.sched_priority > 0;
}
--- a/src/platform/linux/syscalls.h
+++ b/src/platform/linux/syscalls.h
@@ -69,7 +69,7 @@ static int ioprio_get(__priority_which_t _which, id_t _who) {
#define SCHED_FLAG_KEEP_POLICY 0x08
#endif
-struct [[gnu::packed]] sched_attr {
+struct [[gnu::packed]] ananicy_sched_attr {
uint32_t size;
uint32_t sched_policy; // SCHED_(FIFO,RR,DEADLINE,OTHER,BATCH,IDLE, etc.)
@@ -94,20 +94,20 @@ struct [[gnu::packed]] sched_attr {
int32_t sched_latency_nice;
};
-static int sched_setattr(pid_t pid, const struct sched_attr *attr,
+static int ananicy_sched_setattr(pid_t pid, const struct ananicy_sched_attr *attr,
unsigned int flags) {
return static_cast<int>(syscall(__NR_sched_setattr, pid, attr, flags));
}
-static int sched_getattr(pid_t pid, struct sched_attr *attr, unsigned int size,
+static int ananicy_sched_getattr(pid_t pid, struct ananicy_sched_attr *attr, unsigned int size,
unsigned int flags) {
return static_cast<int>(syscall(__NR_sched_getattr, pid, attr, size, flags));
}
static int get_latnice(pid_t pid) {
// pid==0 refers to calling thread
- struct sched_attr attr = { .size = sizeof(struct sched_attr) };
- if (sched_getattr(pid, &attr, sizeof(attr), 0) < 0) {
+ struct ananicy_sched_attr attr = { .size = sizeof(struct ananicy_sched_attr) };
+ if (ananicy_sched_getattr(pid, &attr, sizeof(attr), 0) < 0) {
std::perror("sched_getattr");
}
return attr.sched_latency_nice; // defaults to 0
@@ -115,12 +115,12 @@ static int get_latnice(pid_t pid) {
static int set_latnice(pid_t pid, int latency_nice) {
// pid==0 refers to calling thread
- struct sched_attr attr = {
- .size = sizeof(struct sched_attr),
+ struct ananicy_sched_attr attr = {
+ .size = sizeof(struct ananicy_sched_attr),
.sched_flags = SCHED_FLAG_LATENCY_NICE | SCHED_FLAG_KEEP_PARAMS,
.sched_latency_nice = latency_nice,
};
- const int err = sched_setattr(pid, &attr, 0);
+ const int err = ananicy_sched_setattr(pid, &attr, 0);
if (err < 0) {
// sched_setattr failed
if (errno == EINVAL) {
--
GitLab
|