2 #define SPRN_TBRL 0x10C // Time Base Read Lower Register (user & sup R/O)
3 #define SPRN_TBRU 0x10D // Time Base Read Upper Register (user & sup R/O)
5 #define _bgp_mfspr( SPRN )\
9 asm volatile ("mfspr %0,%1" : "=&r" (tmp) : "i" (SPRN) : "memory" );\
15 unsigned long long timebase(
void )
19 unsigned long long ull;
25 utmp = _bgp_mfspr( SPRN_TBRU );
26 hack.ul[1] = _bgp_mfspr( SPRN_TBRL );
27 hack.ul[0] = _bgp_mfspr( SPRN_TBRU );
29 while( utmp != hack.ul[0] );
34 double getTime(
void )
38 unsigned long long ull;
44 utmp = _bgp_mfspr( SPRN_TBRU );
45 hack.ul[1] = _bgp_mfspr( SPRN_TBRL );
46 hack.ul[0] = _bgp_mfspr( SPRN_TBRU );
48 while( utmp != hack.ul[0] );
50 return( (1.0/850000000.0) * ((
double) hack.ull) );