2
0

musl-compat.h 659 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef __PERF_MUSL_COMPAT_H
  2. #define __PERF_MUSL_COMPAT_H
  3. #ifndef __ASSEMBLER__
  4. #include <sys/ioctl.h>
  5. #include <asm/unistd.h>
  6. #include <unistd.h>
  7. #include <stdio.h>
  8. #undef _IOWR
  9. #undef _IOR
  10. #undef _IOW
  11. #undef _IOC
  12. #undef _IO
  13. #define _SC_LEVEL1_DCACHE_LINESIZE -1
  14. static inline long sysconf_wrap(int name)
  15. {
  16. FILE *f;
  17. int val;
  18. switch (name) {
  19. case _SC_LEVEL1_DCACHE_LINESIZE:
  20. f = fopen("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size", "r");
  21. if (!f)
  22. return 0;
  23. if (fscanf(f, "%d", &val) != 1)
  24. return 0;
  25. fclose(f);
  26. return val;
  27. default:
  28. return sysconf(name);
  29. }
  30. }
  31. #define sysconf(_n) sysconf_wrap(_n)
  32. #endif
  33. #endif