-
Notifications
You must be signed in to change notification settings - Fork 18
/
syscall_magic.h
79 lines (63 loc) · 1.7 KB
/
syscall_magic.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
this sticks around for documentation issues only and will be removed in the next
release - it documents the direct syscalls for affinity, without going thru glibc
*/
#if 0
/*
I don't know where this was exactly taken from, but I think I found it
in glibc.
*/
#include <linux/unistd.h>
#define __NR_sched_setaffinity 241
#define __NR_sched_getaffinity 242
/*
a nice macro to define the following:
it's a syscall with 3 args,
it returns int,
it's named sched_....,
the next arg is of type pid_t,
has the local name pid,
next is unsigned int,
with name len,
then an unsigned long *,
named user_mask_ptr
*/
_syscall3 (int, sched_setaffinity, pid_t, pid, unsigned int, len, unsigned long *, user_mask_ptr)
_syscall3 (int, sched_getaffinity, pid_t, pid, unsigned int, len, unsigned long *, user_mask_ptr)
#endif
#include <linux/kernel.h>
#include <linux/unistd.h>
#include <linux/types.h>
#include <time.h>
/* XXX use the proper syscall numbers */
#ifdef __x86_64__
#define __NR_sched_setattr 314
#define __NR_sched_getattr 315
#endif
#ifdef __i386__
#define __NR_sched_setattr 351
#define __NR_sched_getattr 352
#endif
#ifdef __arm__
#define __NR_sched_setattr 380
#define __NR_sched_getattr 381
#endif
#define SF_SIG_RORUN 2
#define SF_SIG_DMISS 4
struct sched_attr {
__u32 size;
__u32 sched_policy;
__u64 sched_flags;
/* SCHED_NORMAL, SCHED_BATCH */
__s32 sched_nice;
/* SCHED_FIFO, SCHED_RR */
__u32 sched_priority;
/* SCHED_DEADLINE */
__u64 sched_runtime;
__u64 sched_deadline;
__u64 sched_period;
};
#define sched_getattr(pid, attr, size, flags) \
syscall(__NR_sched_getattr, pid, attr, size, flags)
#define sched_setattr(pid, attr, flags) \
syscall(__NR_sched_setattr, pid, attr)