xref: /linux/tools/perf/perf-sys.h (revision 74ce1896c6c65b2f8cccbf59162d542988835835)
1 #ifndef _PERF_SYS_H
2 #define _PERF_SYS_H
3 
4 #include <unistd.h>
5 #include <sys/types.h>
6 #include <sys/syscall.h>
7 #include <linux/types.h>
8 #include <linux/compiler.h>
9 #include <linux/perf_event.h>
10 #include <asm/barrier.h>
11 
12 #ifdef __powerpc__
13 #define CPUINFO_PROC	{"cpu"}
14 #endif
15 
16 #ifdef __s390__
17 #define CPUINFO_PROC	{"vendor_id"}
18 #endif
19 
20 #ifdef __sh__
21 #define CPUINFO_PROC	{"cpu type"}
22 #endif
23 
24 #ifdef __hppa__
25 #define CPUINFO_PROC	{"cpu"}
26 #endif
27 
28 #ifdef __sparc__
29 #define CPUINFO_PROC	{"cpu"}
30 #endif
31 
32 #ifdef __alpha__
33 #define CPUINFO_PROC	{"cpu model"}
34 #endif
35 
36 #ifdef __arm__
37 #define CPUINFO_PROC	{"model name", "Processor"}
38 #endif
39 
40 #ifdef __mips__
41 #define CPUINFO_PROC	{"cpu model"}
42 #endif
43 
44 #ifdef __arc__
45 #define CPUINFO_PROC	{"Processor"}
46 #endif
47 
48 #ifdef __metag__
49 #define CPUINFO_PROC	{"CPU"}
50 #endif
51 
52 #ifdef __xtensa__
53 #define CPUINFO_PROC	{"core ID"}
54 #endif
55 
56 #ifndef CPUINFO_PROC
57 #define CPUINFO_PROC	{ "model name", }
58 #endif
59 
60 static inline int
61 sys_perf_event_open(struct perf_event_attr *attr,
62 		      pid_t pid, int cpu, int group_fd,
63 		      unsigned long flags)
64 {
65 	int fd;
66 
67 	fd = syscall(__NR_perf_event_open, attr, pid, cpu,
68 		     group_fd, flags);
69 
70 #ifdef HAVE_ATTR_TEST
71 	if (unlikely(test_attr__enabled))
72 		test_attr__open(attr, pid, cpu, fd, group_fd, flags);
73 #endif
74 	return fd;
75 }
76 
77 #endif /* _PERF_SYS_H */
78