summaryrefslogtreecommitdiff
path: root/src/basic/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-09-30 21:50:22 +0200
committerLennart Poettering <lennart@poettering.net>2015-09-30 22:26:16 +0200
commit618234a5258768359cb1086b152c5f08aaf89754 (patch)
tree2fb6f9820ff043bc5a6a615d343bcfebf6a6cfad /src/basic/util.c
parent94d75d6423f16f1fb66d214cb640ae3a114c5c58 (diff)
basic: split out cpu set specific APIs into cpu-set-util.[ch]
Diffstat (limited to 'src/basic/util.c')
-rw-r--r--src/basic/util.c81
1 files changed, 0 insertions, 81 deletions
diff --git a/src/basic/util.c b/src/basic/util.c
index cc50c9aa7d..33dc410c78 100644
--- a/src/basic/util.c
+++ b/src/basic/util.c
@@ -2551,87 +2551,6 @@ int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid) {
return 0;
}
-cpu_set_t* cpu_set_malloc(unsigned *ncpus) {
- cpu_set_t *c;
- unsigned n = 1024;
-
- /* Allocates the cpuset in the right size */
-
- for (;;) {
- c = CPU_ALLOC(n);
- if (!c)
- return NULL;
-
- if (sched_getaffinity(0, CPU_ALLOC_SIZE(n), c) >= 0) {
- CPU_ZERO_S(CPU_ALLOC_SIZE(n), c);
-
- if (ncpus)
- *ncpus = n;
-
- return c;
- }
-
- CPU_FREE(c);
-
- if (errno != EINVAL)
- return NULL;
-
- n *= 2;
- }
-}
-
-int parse_cpu_set_and_warn(
- const char *rvalue,
- cpu_set_t **cpu_set,
- const char *unit,
- const char *filename,
- unsigned line,
- const char *lvalue) {
-
- const char *whole_rvalue = rvalue;
- _cleanup_cpu_free_ cpu_set_t *c = NULL;
- unsigned ncpus = 0;
-
- assert(lvalue);
- assert(rvalue);
-
- for (;;) {
- _cleanup_free_ char *word = NULL;
- unsigned cpu;
- int r;
-
- r = extract_first_word(&rvalue, &word, WHITESPACE, EXTRACT_QUOTES);
- if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, r, "Invalid value for %s: %s", lvalue, whole_rvalue);
- return r;
- }
- if (r == 0)
- break;
-
- if (!c) {
- c = cpu_set_malloc(&ncpus);
- if (!c)
- return log_oom();
- }
-
- r = safe_atou(word, &cpu);
- if (r < 0 || cpu >= ncpus) {
- log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse CPU affinity '%s'", rvalue);
- return -EINVAL;
- }
-
- CPU_SET_S(cpu, CPU_ALLOC_SIZE(ncpus), c);
- }
-
- /* On success, sets *cpu_set and returns ncpus for the system. */
- if (c) {
- *cpu_set = c;
- c = NULL;
- }
-
- return (int) ncpus;
-}
-
int files_same(const char *filea, const char *fileb) {
struct stat a, b;