summaryrefslogtreecommitdiff
path: root/nacl/cpucycles/hppapstat.c
blob: 5ae1e843d333634fbecbbbcb0f3ffab7e1d393f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/pstat.h>
#include <machine/inline.h>

long long cpucycles_hppapstat(void)
{
  register long long result;
  _MFCTL(16,result);
  return result;
}

long long cpucycles_hppapstat_persecond(void)
{
  struct pst_processor pst;
  union pstun pu;
  double result;

  pu.pst_processor = &pst;
  if (pstat(PSTAT_PROCESSOR,pu,sizeof(pst),1,0) < 0) return 0;
  result = pst.psp_iticksperclktick;
  result *= (double) sysconf(_SC_CLK_TCK);
  return result;
}