]> granicus.if.org Git - strace/blob - sched.c
build: fix -I options
[strace] / sched.c
1 #include "defs.h"
2
3 #include <sched.h>
4
5 #include "xlat/schedulers.h"
6 #include "xlat/sched_flags.h"
7
8 SYS_FUNC(sched_getscheduler)
9 {
10         if (entering(tcp)) {
11                 tprintf("%d", (int) tcp->u_arg[0]);
12         } else if (!syserror(tcp)) {
13                 tcp->auxstr = xlookup(schedulers, tcp->u_rval);
14                 if (tcp->auxstr != NULL)
15                         return RVAL_STR;
16         }
17         return 0;
18 }
19
20 SYS_FUNC(sched_setscheduler)
21 {
22         tprintf("%d, ", (int) tcp->u_arg[0]);
23         printxval(schedulers, tcp->u_arg[1], "SCHED_???");
24         tprints(", ");
25         printnum_int(tcp, tcp->u_arg[2], "%d");
26
27         return RVAL_DECODED;
28 }
29
30 SYS_FUNC(sched_getparam)
31 {
32         if (entering(tcp))
33                 tprintf("%d, ", (int) tcp->u_arg[0]);
34         else
35                 printnum_int(tcp, tcp->u_arg[1], "%d");
36         return 0;
37 }
38
39 SYS_FUNC(sched_setparam)
40 {
41         tprintf("%d, ", (int) tcp->u_arg[0]);
42         printnum_int(tcp, tcp->u_arg[1], "%d");
43
44         return RVAL_DECODED;
45 }
46
47 SYS_FUNC(sched_get_priority_min)
48 {
49         printxval(schedulers, tcp->u_arg[0], "SCHED_???");
50
51         return RVAL_DECODED;
52 }
53
54 SYS_FUNC(sched_rr_get_interval)
55 {
56         if (entering(tcp)) {
57                 tprintf("%d, ", (int) tcp->u_arg[0]);
58         } else {
59                 if (syserror(tcp))
60                         printaddr(tcp->u_arg[1]);
61                 else
62                         print_timespec(tcp, tcp->u_arg[1]);
63         }
64         return 0;
65 }
66
67 static void
68 print_sched_attr(struct tcb *tcp, const long addr, unsigned int size)
69 {
70         struct {
71                 uint32_t size;
72                 uint32_t sched_policy;
73                 uint64_t sched_flags;
74                 uint32_t sched_nice;
75                 uint32_t sched_priority;
76                 uint64_t sched_runtime;
77                 uint64_t sched_deadline;
78                 uint64_t sched_period;
79         } attr = {};
80
81         if (size > sizeof(attr))
82                 size = sizeof(attr);
83         if (umoven_or_printaddr(tcp, addr, size, &attr))
84                 return;
85
86         tprintf("{size=%u, sched_policy=", attr.size);
87         printxval(schedulers, attr.sched_policy, "SCHED_???");
88         tprints(", sched_flags=");
89         printflags(sched_flags, attr.sched_flags, "SCHED_FLAG_???");
90         tprintf(", sched_nice=%d", attr.sched_nice);
91         tprintf(", sched_priority=%u", attr.sched_priority);
92         tprintf(", sched_runtime=%" PRIu64, attr.sched_runtime);
93         tprintf(", sched_deadline=%" PRIu64, attr.sched_deadline);
94         tprintf(", sched_period=%" PRIu64 "}", attr.sched_period);
95 }
96
97 SYS_FUNC(sched_setattr)
98 {
99         tprintf("%d, ", (int) tcp->u_arg[0]);
100         print_sched_attr(tcp, tcp->u_arg[1], 0x100);
101         tprintf(", %u", (unsigned int) tcp->u_arg[2]);
102
103         return RVAL_DECODED;
104 }
105
106 SYS_FUNC(sched_getattr)
107 {
108         if (entering(tcp)) {
109                 tprintf("%d, ", (int) tcp->u_arg[0]);
110         } else {
111                 print_sched_attr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
112                 tprintf(", %u, %u",
113                         (unsigned int) tcp->u_arg[2],
114                         (unsigned int) tcp->u_arg[3]);
115         }
116
117         return 0;
118 }