split up constants.h some
[trinity.git] / fd-perf.c
blobd656256dfdf7d3d68f340c7f9de5f07b54392981
1 #include <errno.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <unistd.h>
6 #include <asm/unistd.h>
8 #include "perf.h"
9 #include "shm.h"
10 #include "log.h"
11 #include "sanitise.h"
13 void open_perf_fds(void)
15 struct syscallrecord* sc;
16 unsigned int i = 0;
18 while (i < MAX_PERF_FDS) {
19 int fd;
21 sanitise_perf_event_open(0);
22 sc = &shm->syscall[0];
23 fd = syscall(__NR_perf_event_open, sc->a1, sc->a2, sc->a3, sc->a4, sc->a5);
24 if (fd != -1) {
25 shm->perf_fds[i] = fd;
26 output(2, "fd[%d] = perf\n", shm->perf_fds[i]);
27 i++;
28 } else {
29 if (errno == ENOSYS)
30 return;
35 int rand_perf_fd(void)
37 return shm->perf_fds[rand() % MAX_PERF_FDS];