diff options
author | Rob Landley <rob@landley.net> | 2018-11-13 17:22:37 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2018-11-13 17:22:37 -0600 |
commit | 833fb23fe8b485d5bb4544c10b9e5577b2c51982 (patch) | |
tree | e9b57e74f652b6c02b6ee99b23f0f551601c151a /toys | |
parent | 457dda2930287e4bb1bbc3c3ff56fcd4e9ffa3de (diff) | |
download | toybox-833fb23fe8b485d5bb4544c10b9e5577b2c51982.tar.gz |
Instead of #warning about the musl bug, work around it (wrap syscalls ourselves)
Diffstat (limited to 'toys')
-rw-r--r-- | toys/other/chrt.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/toys/other/chrt.c b/toys/other/chrt.c index a1c37a05..618de84d 100644 --- a/toys/other/chrt.c +++ b/toys/other/chrt.c @@ -28,11 +28,24 @@ config CHRT #include "toys.h" GLOBALS( - long pid; + long p; ) #ifndef _POSIX_PRIORITY_SCHEDULING -#warning "musl-libc intentionally broke sched_get_priority_min() and friends in commit 1e21e78bf7a5 because its maintainer didn't like those Linux system calls" +// musl-libc intentionally broke sched_get_priority_min() and friends in +// commit 1e21e78bf7a5 because its maintainer didn't like those Linux +// system calls, so work around it here. +#include <sys/syscall.h> +#define sched_get_priority_min(policy) \ + (int)syscall(SYS_sched_get_priority_min, (int)policy) +#define sched_get_priority_max(policy) \ + (int)syscall(SYS_sched_get_priority_max, (int)policy) +#define sched_getparam(pid, param) \ + syscall(SYS_sched_getparam, (pid_t)pid, (void *)param) +#define sched_getscheduler(pid) \ + syscall(SYS_sched_getscheduler, (pid_t)pid) +#define sched_setscheduler(pid, scheduler, param) \ + syscall(SYS_sched_setscheduler, (pid_t)pid, (int)scheduler, (void *)param) #endif char *polnames[] = { @@ -57,13 +70,13 @@ void chrt_main(void) if (toys.optflags==FLAG_p && !*toys.optargs) { char *s = "???", *R = ""; - if (-1==(pol = sched_getscheduler(TT.pid))) perror_exit("pid %ld", TT.pid); + if (-1==(pol = sched_getscheduler(TT.p))) perror_exit("pid %ld", TT.p); if (pol & SCHED_RESET_ON_FORK) R = "|SCHED_RESET_ON_FORK"; if ((pol &= ~SCHED_RESET_ON_FORK)<ARRAY_LEN(polnames)) s = polnames[pol]; - printf("pid %ld's current scheduling policy: %s%s\n", TT.pid, s, R); + printf("pid %ld's current scheduling policy: %s%s\n", TT.p, s, R); - if (sched_getparam(TT.pid, (void *)&pri)) perror_exit("sched_getparam"); - printf("pid %ld's current scheduling priority: %d\n", TT.pid, pri); + if (sched_getparam(TT.p, (void *)&pri)) perror_exit("sched_getparam"); + printf("pid %ld's current scheduling priority: %d\n", TT.p, pri); return; } @@ -78,7 +91,7 @@ void chrt_main(void) sched_get_priority_max(pol)); if (toys.optflags&FLAG_R) pol |= SCHED_RESET_ON_FORK; - if (sched_setscheduler(TT.pid, pol, (void *)&pri)) + if (sched_setscheduler(TT.p, pol, (void *)&pri)) perror_exit("sched_setscheduler"); if (*(toys.optargs+1)) xexec(toys.optargs+1); |