1
0

hppapstat.c 546 B

1234567891011121314151617181920212223242526
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <sys/types.h>
  4. #include <sys/param.h>
  5. #include <sys/pstat.h>
  6. #include <machine/inline.h>
  7. long long cpucycles_hppapstat(void)
  8. {
  9. register long long result;
  10. _MFCTL(16,result);
  11. return result;
  12. }
  13. long long cpucycles_hppapstat_persecond(void)
  14. {
  15. struct pst_processor pst;
  16. union pstun pu;
  17. double result;
  18. pu.pst_processor = &pst;
  19. if (pstat(PSTAT_PROCESSOR,pu,sizeof(pst),1,0) < 0) return 0;
  20. result = pst.psp_iticksperclktick;
  21. result *= (double) sysconf(_SC_CLK_TCK);
  22. return result;
  23. }