move shm code out of trinity.c into own file
[trinity.git] / perf.c
blobf8219c61390e68ed201bdee8b9a74b522a03a4b4
1 #include <errno.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <unistd.h>
6 //#include <sys/syscall.h> /* For SYS_xxx definitions */
7 #include <asm/unistd.h>
9 #include "perf.h"
10 #include "shm.h"
11 #include "log.h"
12 #include "sanitise.h"
14 void open_perf_fds(void)
16 int fd;
17 unsigned int i = 0;
19 while (i < MAX_PERF_FDS) {
20 sanitise_perf_event_open(0);
21 fd = syscall(__NR_perf_event_open, shm->a1[0], shm->a2[0], shm->a3[0], shm->a4[0], shm->a5[0]);
22 if (fd != -1) {
23 shm->perf_fds[i] = fd;
24 output(2, "fd[%d] = perf\n", shm->perf_fds[i]);
25 i++;
26 } else {
27 if (errno == ENOSYS)
28 return;