diff options
author | Rob Landley <rob@landley.net> | 2012-12-03 16:16:06 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2012-12-03 16:16:06 -0600 |
commit | 5434415c11af6ea91f61fe2e873cfc29afc5657f (patch) | |
tree | 2e003bf04b017c56a1fe39aa815beba5aae7fb53 /toys/other | |
parent | 6093554a95fee1acd5b2aaad387b92fa4ae97d41 (diff) | |
download | toybox-5434415c11af6ea91f61fe2e873cfc29afc5657f.tar.gz |
Use sched_{set,get}affinity directly so musl doesn't have to provide wrappers.
Diffstat (limited to 'toys/other')
-rw-r--r-- | toys/other/taskset.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/toys/other/taskset.c b/toys/other/taskset.c index 967bf70f..2b067d4a 100644 --- a/toys/other/taskset.c +++ b/toys/other/taskset.c @@ -23,9 +23,11 @@ config TASKSET #define FOR_taskset #include "toys.h" -// Prototype for syscall wrappers sched.h refuses to give us -int sched_setaffinity(pid_t pid, size_t size, void *cpuset); -int sched_getaffinity(pid_t pid, size_t size, void *cpuset); +#include <sys/syscall.h> +#define sched_setaffinity(pid, size, cpuset) \ + syscall(__NR_sched_setaffinity, (pid_t)pid, (size_t)size, (void *)cpuset) +#define sched_getaffinity(pid, size, cpuset) \ + syscall(__NR_sched_getaffinity, (pid_t)pid, (size_t)size, (void *)cpuset) // mask is an array of long, which makes the layout a bit weird on big // endian systems but as long as it's consistent... @@ -40,7 +42,7 @@ static void do_taskset(pid_t pid, int quiet) if (!quiet) { int j = sizeof(toybuf), flag = 0; - if (sched_getaffinity(pid, sizeof(toybuf), (void *)mask)) + if (-1 == sched_getaffinity(pid, sizeof(toybuf), (void *)mask)) perror_exit(failed, "get", pid); printf("pid %d's %s affinity mask: ", pid, i ? "new" : "current"); @@ -70,7 +72,7 @@ static void do_taskset(pid_t pid, int quiet) mask[j/(2*sizeof(long))] |= digit << 4*(j&((2*sizeof(long))-1)); } - if (sched_setaffinity(pid, sizeof(toybuf), (void *)mask)) + if (-1 == sched_setaffinity(pid, sizeof(toybuf), (void *)mask)) perror_exit(failed, "set", pid); } } |