diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-07-04 16:44:58 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-07-04 16:44:58 +0200 |
commit | 82c121a4754a9d405b07c75796e329942af2ccc5 (patch) | |
tree | cb80da758516904383e2558b0cc626f0033e5a6e /src/util.c | |
parent | d264aa332a016501ae164a4316f0acc7da0636f4 (diff) |
dbus: complete exec coverage
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index b66eb466b6..ea8bfc1984 100644 --- a/src/util.c +++ b/src/util.c @@ -2538,6 +2538,34 @@ int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid) { return 0; } +cpu_set_t* cpu_set_malloc(unsigned *ncpus) { + cpu_set_t *r; + unsigned n = 1024; + + /* Allocates the cpuset in the right size */ + + for (;;) { + if (!(r = CPU_ALLOC(n))) + return NULL; + + if (sched_getaffinity(0, CPU_ALLOC_SIZE(n), r) >= 0) { + CPU_ZERO_S(CPU_ALLOC_SIZE(n), r); + + if (ncpus) + *ncpus = n; + + return r; + } + + CPU_FREE(r); + + if (errno != EINVAL) + return NULL; + + n *= 2; + } +} + static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime", |