perf: select objdump instead of the full binutils package
[openwrt/staging/mkresin.git] / package / devel / perf / musl-compat.h
1 #ifndef __PERF_MUSL_COMPAT_H
2 #define __PERF_MUSL_COMPAT_H
3
4 #include <sys/ioctl.h>
5 #include <string.h>
6 #include <unistd.h>
7 #include <stdio.h>
8 #include <syscall.h>
9 #include <sched.h>
10
11 #undef _IOWR
12 #undef _IOR
13 #undef _IOW
14 #undef _IOC
15 #undef _IO
16
17 /* Change XSI compliant version into GNU extension hackery */
18 #define strerror_r(err, buf, buflen) \
19 (strerror_r(err, buf, buflen) ? NULL : buf)
20
21 #define _SC_LEVEL1_DCACHE_LINESIZE -1
22
23 static inline long sysconf_wrap(int name)
24 {
25 FILE *f;
26 int val;
27
28 switch (name) {
29 case _SC_LEVEL1_DCACHE_LINESIZE:
30 f = fopen("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size", "r");
31 if (!f)
32 return 0;
33
34 if (fscanf(f, "%d", &val) != 1)
35 return 0;
36
37 fclose(f);
38 return val;
39 default:
40 return sysconf(name);
41 }
42 }
43
44 #define sysconf(_n) sysconf_wrap(_n)
45
46 static inline int compat_sched_getcpu(void)
47 {
48 #ifdef __NR_getcpu
49 unsigned int val;
50
51 if (syscall(__NR_getcpu, &val))
52 return -1;
53
54 return val;
55 #else
56 return -1;
57 #endif
58 }
59
60 #define sched_getcpu compat_sched_getcpu
61
62 #endif