staticlong sys_kcmp(int pid1, int pid2, int type, unsignedlong fd1, unsignedlong fd2)
{ return syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2);
}
staticconstunsignedint duped_num = 64;
int main(int argc, char **argv)
{ constchar kpath[] = "kcmp-test-file"; struct kcmp_epoll_slot epoll_slot; struct epoll_event ev; int pid1, pid2; int pipefd[2]; int fd1, fd2; int epollfd; int status; int fddup;
/* This one should fail */
sys_kcmp(pid1, pid2, KCMP_TYPES + 1, 0, 0));
/* This one should return same fd */
ret = sys_kcmp(pid1, pid2, KCMP_FILE, fd1, fd1); if (ret) {
printf("FAIL: 0 expected but %d returned (%s)\n",
ret, strerror(errno));
ksft_inc_fail_cnt();
ret = -1;
} else {
printf("PASS: 0 returned as expected\n");
ksft_inc_pass_cnt();
}
/* Compare with self */
ret = sys_kcmp(pid1, pid1, KCMP_VM, 0, 0); if (ret) {
printf("FAIL: 0 expected but %d returned (%s)\n",
ret, strerror(errno));
ksft_inc_fail_cnt();
ret = -1;
} else {
printf("PASS: 0 returned as expected\n");
ksft_inc_pass_cnt();
}
/* Compare epoll target */
epoll_slot = (struct kcmp_epoll_slot) {
.efd = epollfd,
.tfd = duped_num,
.toff = 0,
};
ret = sys_kcmp(pid1, pid1, KCMP_EPOLL_TFD, pipefd[1],
(unsignedlong)(void *)&epoll_slot); if (ret) {
printf("FAIL: 0 expected but %d returned (%s)\n",
ret, strerror(errno));
ksft_inc_fail_cnt();
ret = -1;
} else {
printf("PASS: 0 returned as expected\n");
ksft_inc_pass_cnt();
}
if (ret)
ksft_exit_fail(); else
ksft_exit_pass();
}
waitpid(pid2, &status, P_ALL);
return 0;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.