aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-07-01 16:42:27 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-07-01 16:42:27 +0200
commit922f6f51dba8ba710cac0679635ed811b2139a53 (patch)
tree579ec114ed4608c99634b03bbcabfd94afd6e1bd /miscutils
parentcd0f6b0c939e5098410ddb171db8c4a26cf8d623 (diff)
downloadbusybox-w32-922f6f51dba8ba710cac0679635ed811b2139a53.tar.gz
busybox-w32-922f6f51dba8ba710cac0679635ed811b2139a53.tar.bz2
busybox-w32-922f6f51dba8ba710cac0679635ed811b2139a53.zip
chrt: code shrink
function old new delta show_min_max 80 60 -20 packed_usage 26929 26896 -33 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-53) Total: -53 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/chrt.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/miscutils/chrt.c b/miscutils/chrt.c
index e2b7f8ae0..3d0da58ca 100644
--- a/miscutils/chrt.c
+++ b/miscutils/chrt.c
@@ -5,33 +5,35 @@
5 * 5 *
6 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 6 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
7 */ 7 */
8
9#include <sched.h> 8#include <sched.h>
10#include "libbb.h" 9#include "libbb.h"
11#ifndef _POSIX_PRIORITY_SCHEDULING 10#ifndef _POSIX_PRIORITY_SCHEDULING
12#warning your system may be foobared 11#warning your system may be foobared
13#endif 12#endif
13
14static const struct { 14static const struct {
15 int policy; 15 int policy;
16 char name[12]; 16 char name[sizeof("SCHED_OTHER")];
17} policies[] = { 17} policies[] = {
18 {SCHED_OTHER, "SCHED_OTHER"}, 18 {SCHED_OTHER, "SCHED_OTHER"},
19 {SCHED_FIFO, "SCHED_FIFO"}, 19 {SCHED_FIFO, "SCHED_FIFO"},
20 {SCHED_RR, "SCHED_RR"} 20 {SCHED_RR, "SCHED_RR"}
21}; 21};
22 22
23//TODO: add
24// -b, SCHED_BATCH
25// -i, SCHED_IDLE
26
23static void show_min_max(int pol) 27static void show_min_max(int pol)
24{ 28{
25 const char *fmt = "%s min/max priority\t: %d/%d\n\0%s not supported?\n"; 29 const char *fmt = "%s min/max priority\t: %u/%u\n";
26 int max, min; 30 int max, min;
31
27 max = sched_get_priority_max(pol); 32 max = sched_get_priority_max(pol);
28 min = sched_get_priority_min(pol); 33 min = sched_get_priority_min(pol);
29 if (max >= 0 && min >= 0) 34 if ((max|min) < 0)
30 printf(fmt, policies[pol].name, min, max); 35 fmt = "%s not supported\n";
31 else { 36 printf(fmt, policies[pol].name, min, max);
32 fmt += 29;
33 printf(fmt, policies[pol].name);
34 }
35} 37}
36 38
37#define OPT_m (1<<0) 39#define OPT_m (1<<0)