It just seems to fit better there and it's always better to have things
in shared/ rather than basic/.
#include <errno.h>
#include <limits.h>
#include <linux/oom.h>
#include <errno.h>
#include <limits.h>
#include <linux/oom.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER);
}
WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER);
}
-int cpus_in_affinity_mask(void) {
- size_t n = 16;
- int r;
-
- for (;;) {
- cpu_set_t *c;
-
- c = CPU_ALLOC(n);
- if (!c)
- return -ENOMEM;
-
- if (sched_getaffinity(0, CPU_ALLOC_SIZE(n), c) >= 0) {
- int k;
-
- k = CPU_COUNT_S(CPU_ALLOC_SIZE(n), c);
- CPU_FREE(c);
-
- if (k <= 0)
- return -EINVAL;
-
- return k;
- }
-
- r = -errno;
- CPU_FREE(c);
-
- if (r != -EINVAL)
- return r;
- if (n > SIZE_MAX/2)
- return -ENOMEM;
- n *= 2;
- }
-}
-
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",
[IOPRIO_CLASS_BE] = "best-effort",
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",
[IOPRIO_CLASS_BE] = "best-effort",
- [IOPRIO_CLASS_IDLE] = "idle"
+ [IOPRIO_CLASS_IDLE] = "idle",
};
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ioprio_class, int, IOPRIO_N_CLASSES);
};
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ioprio_class, int, IOPRIO_N_CLASSES);
[SCHED_BATCH] = "batch",
[SCHED_IDLE] = "idle",
[SCHED_FIFO] = "fifo",
[SCHED_BATCH] = "batch",
[SCHED_IDLE] = "idle",
[SCHED_FIFO] = "fifo",
};
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(sched_policy, int, INT_MAX);
};
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(sched_policy, int, INT_MAX);
-
-int cpus_in_affinity_mask(void);
#include "cap-list.h"
#include "cgroup-util.h"
#include "condition.h"
#include "cap-list.h"
#include "cgroup-util.h"
#include "condition.h"
+#include "cpu-set-util.h"
#include "efivars.h"
#include "env-file.h"
#include "extract-word.h"
#include "efivars.h"
#include "env-file.h"
#include "extract-word.h"
return cpu_set_add_all(old, &cpuset);
}
return cpu_set_add_all(old, &cpuset);
}
+
+int cpus_in_affinity_mask(void) {
+ size_t n = 16;
+ int r;
+
+ for (;;) {
+ cpu_set_t *c;
+
+ c = CPU_ALLOC(n);
+ if (!c)
+ return -ENOMEM;
+
+ if (sched_getaffinity(0, CPU_ALLOC_SIZE(n), c) >= 0) {
+ int k;
+
+ k = CPU_COUNT_S(CPU_ALLOC_SIZE(n), c);
+ CPU_FREE(c);
+
+ if (k <= 0)
+ return -EINVAL;
+
+ return k;
+ }
+
+ r = -errno;
+ CPU_FREE(c);
+
+ if (r != -EINVAL)
+ return r;
+ if (n > SIZE_MAX/2)
+ return -ENOMEM;
+ n *= 2;
+ }
+}
static inline int parse_cpu_set(const char *rvalue, CPUSet *cpu_set){
return parse_cpu_set_full(rvalue, cpu_set, false, NULL, NULL, 0, NULL);
}
static inline int parse_cpu_set(const char *rvalue, CPUSet *cpu_set){
return parse_cpu_set_full(rvalue, cpu_set, false, NULL, NULL, 0, NULL);
}
+
+int cpus_in_affinity_mask(void);
#include "audit-util.h"
#include "cgroup-util.h"
#include "condition.h"
#include "audit-util.h"
#include "cgroup-util.h"
#include "condition.h"
+#include "cpu-set-util.h"
#include "efivars.h"
#include "hostname-util.h"
#include "id128-util.h"
#include "efivars.h"
#include "hostname-util.h"
#include "id128-util.h"