static int do_test (void) { uint64_t t1, t2, f, diff; t1 = __ppc_get_timebase (); printf ("t1 = %"PRIu64"\n", t1); f = __ppc_get_timebase_freq (); printf ("Time Base frequency = %"PRIu64" Hz\n", f); if (f == 0) { printf ("Fail: The time base frequency can't be zero."); return 1; } t2 = __ppc_get_timebase (); printf ("t2 = %"PRIu64"\n", t2); if (t2 > t1) { diff = t2 - t1; } else { diff = (MAX_TB - t2) + t1; } printf ("Elapsed time = %1.2f usecs\n", (double) diff * 1000000 / f ); return 0; }
double ucs_arch_get_clocks_per_sec() { #if HAVE_DECL___PPC_GET_TIMEBASE_FREQ return __ppc_get_timebase_freq(); #else return ucs_get_cpuinfo_clock_freq("timebase"); #endif }