… | |
… | |
9 | #define _GNU_SOURCE |
9 | #define _GNU_SOURCE |
10 | #include <sched.h> |
10 | #include <sched.h> |
11 | #include <unistd.h> |
11 | #include <unistd.h> |
12 | #include <sys/syscall.h> |
12 | #include <sys/syscall.h> |
13 | |
13 | |
|
|
14 | #ifdef __has_include |
|
|
15 | #if !__has_include("linux/kcmp.h") // use "" as GCC wrongly expands macros |
|
|
16 | #undef SYS_kcmp |
|
|
17 | #endif |
|
|
18 | #endif |
|
|
19 | |
14 | #ifdef SYS_kcmp |
20 | #ifdef SYS_kcmp |
15 | #include <linux/kcmp.h> |
21 | #include "linux/kcmp.h" |
16 | #define kcmp(pid1,pid2,type,idx1,idx2) \ |
22 | #define kcmp(pid1,pid2,type,idx1,idx2) \ |
17 | syscall (SYS_kcmp, (pid_t)pid1, (pid_t)pid2, \ |
23 | syscall (SYS_kcmp, (pid_t)pid1, (pid_t)pid2, \ |
18 | (int)type, (unsigned long)idx1, (unsigned long)idx2) |
24 | (int)type, (unsigned long)idx1, (unsigned long)idx2) |
19 | #else |
25 | #else |
20 | #define kcmp(pid1,pid2,type,idx1,idx2) \ |
26 | #define kcmp(pid1,pid2,type,idx1,idx2) \ |
… | |
… | |
68 | |
74 | |
69 | static const struct { |
75 | static const struct { |
70 | const char *name; |
76 | const char *name; |
71 | IV iv; |
77 | IV iv; |
72 | } *civ, const_iv[] = { |
78 | } *civ, const_iv[] = { |
73 | # define const_iv(name) { # name, (IV)name }, |
79 | # define const_iv(name) { # name, (IV)name }, |
|
|
80 | # define const_iv_clone(name) { # name, (IV) CLONE_ ## name }, |
74 | # ifdef CLONE_FILES |
81 | # ifdef CLONE_FILES |
75 | const_iv (CLONE_FILES) |
82 | const_iv_clone (FILES) |
76 | # endif |
83 | # endif |
77 | # ifdef CLONE_FS |
84 | # ifdef CLONE_FS |
78 | const_iv (CLONE_FS) |
85 | const_iv_clone (FS) |
79 | # endif |
86 | # endif |
80 | # ifdef CLONE_NEWNS |
87 | # ifdef CLONE_NEWNS |
81 | const_iv (CLONE_NEWNS) |
88 | const_iv_clone (NEWNS) |
82 | # endif |
89 | # endif |
83 | # ifdef CLONE_VM |
90 | # ifdef CLONE_VM |
84 | const_iv (CLONE_VM) |
91 | const_iv_clone (VM) |
85 | # endif |
92 | # endif |
86 | # ifdef CLONE_THREAD |
93 | # ifdef CLONE_THREAD |
87 | const_iv (CLONE_THREAD) |
94 | const_iv_clone (THREAD) |
88 | # endif |
95 | # endif |
89 | # ifdef CLONE_SIGHAND |
96 | # ifdef CLONE_SIGHAND |
90 | const_iv (CLONE_SIGHAND) |
97 | const_iv_clone (SIGHAND) |
91 | # endif |
98 | # endif |
92 | # ifdef CLONE_SYSVSEM |
99 | # ifdef CLONE_SYSVSEM |
93 | const_iv (CLONE_SYSVSEM) |
100 | const_iv_clone (SYSVSEM) |
94 | # endif |
101 | # endif |
95 | # ifdef CLONE_NEWUTS |
102 | # ifdef CLONE_NEWUTS |
96 | const_iv (CLONE_NEWUTS) |
103 | const_iv_clone (NEWUTS) |
97 | # endif |
104 | # endif |
98 | # ifdef CLONE_NEWIPC |
105 | # ifdef CLONE_NEWIPC |
99 | const_iv (CLONE_NEWIPC) |
106 | const_iv_clone (NEWIPC) |
100 | # endif |
107 | # endif |
101 | # ifdef CLONE_NEWNET |
108 | # ifdef CLONE_NEWNET |
102 | const_iv (CLONE_NEWNET) |
109 | const_iv_clone (NEWNET) |
103 | # endif |
110 | # endif |
104 | # ifdef CLONE_PTRACE |
111 | # ifdef CLONE_PTRACE |
105 | const_iv (CLONE_PTRACE) |
112 | const_iv_clone (PTRACE) |
106 | # endif |
113 | # endif |
107 | # ifdef CLONE_VFORK |
114 | # ifdef CLONE_VFORK |
108 | const_iv (CLONE_VFORK) |
115 | const_iv_clone (VFORK) |
109 | # endif |
116 | # endif |
110 | # ifdef CLONE_SETTLS |
117 | # ifdef CLONE_SETTLS |
111 | const_iv (CLONE_SETTLS) |
118 | const_iv_clone (SETTLS) |
112 | # endif |
119 | # endif |
113 | # ifdef CLONE_PARENT_SETTID |
120 | # ifdef CLONE_PARENT_SETTID |
114 | const_iv (CLONE_PARENT_SETTID) |
121 | const_iv_clone (PARENT_SETTID) |
115 | # endif |
122 | # endif |
116 | # ifdef CLONE_CHILD_CLEARTID |
123 | # ifdef CLONE_CHILD_CLEARTID |
117 | const_iv (CLONE_CHILD_CLEARTID) |
124 | const_iv_clone (CHILD_CLEARTID) |
118 | # endif |
125 | # endif |
119 | # ifdef CLONE_DETACHED |
126 | # ifdef CLONE_DETACHED |
120 | const_iv (CLONE_DETACHED) |
127 | const_iv_clone (DETACHED) |
121 | # endif |
128 | # endif |
122 | # ifdef CLONE_UNTRACED |
129 | # ifdef CLONE_UNTRACED |
123 | const_iv (CLONE_UNTRACED) |
130 | const_iv_clone (UNTRACED) |
124 | # endif |
131 | # endif |
125 | # ifdef CLONE_CHILD_SETTID |
132 | # ifdef CLONE_CHILD_SETTID |
126 | const_iv (CLONE_CHILD_SETTID) |
133 | const_iv_clone (CHILD_SETTID) |
127 | # endif |
134 | # endif |
128 | # ifdef CLONE_NEWUSER |
135 | # ifdef CLONE_NEWUSER |
129 | const_iv (CLONE_NEWUSER) |
136 | const_iv_clone (NEWUSER) |
130 | # endif |
137 | # endif |
131 | # ifdef CLONE_NEWPID |
138 | # ifdef CLONE_NEWPID |
132 | const_iv (CLONE_NEWPID) |
139 | const_iv_clone (NEWPID) |
133 | # endif |
140 | # endif |
134 | # ifdef CLONE_IO |
141 | # ifdef CLONE_IO |
135 | const_iv (CLONE_IO) |
142 | const_iv_clone (IO) |
136 | # endif |
143 | # endif |
137 | # ifdef CLONE_NEWCGROUP |
144 | # ifdef CLONE_NEWCGROUP |
138 | const_iv (CLONE_NEWCGROUP) |
145 | const_iv_clone (NEWCGROUP) |
139 | # endif |
146 | # endif |
140 | # ifdef SYS_kcmp |
147 | # ifdef SYS_kcmp |
141 | const_iv (KCMP_FILE) |
148 | const_iv (KCMP_FILE) |
142 | const_iv (KCMP_VM) |
149 | const_iv (KCMP_VM) |
143 | const_iv (KCMP_FILES) |
150 | const_iv (KCMP_FILES) |