diff options
-rw-r--r-- | runtime/ChangeLog | 7 | ||||
-rw-r--r-- | runtime/time.c | 19 |
2 files changed, 25 insertions, 1 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 19606072..7341ae33 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,10 @@ +2006-10-09 Josh Stone <joshua.i.stone@intel.com> + + From David Wilder <dwilder@us.ibm.com> + * time.c (__stp_estimate_cpufreq): Short-circuit on s390. + (_stp_gettimeofday_ns): Use a fixed formula on s390 to + convert TOD clocks to nanoseconds. + 2006-09-27 Martin Hunt <hunt@redhat.com> * stack.c (_stp_kta): Rewrite. Use the _stap_symbols diff --git a/runtime/time.c b/runtime/time.c index 058cfe49..8d82f3d1 100644 --- a/runtime/time.c +++ b/runtime/time.c @@ -58,6 +58,12 @@ void *stp_time = NULL; static unsigned int __stp_estimate_cpufreq(void) { +#if defined (__s390__) || defined (__s390x__) + // We don't need to find the cpu freq on s390 as the + // TOD clock is always a fix freq. (see: POO pg 4-36.) + return 0; +#else /* __s390x__ || __s390x__ */ + cycles_t beg, mid, end; beg = get_cycles(); barrier(); udelay(1); barrier(); @@ -65,6 +71,7 @@ __stp_estimate_cpufreq(void) udelay(1001); barrier(); end = get_cycles(); barrier(); return (beg - 2*mid + end); +#endif } static void @@ -230,10 +237,20 @@ _stp_gettimeofday_ns(void) preempt_enable(); +#if defined (__s390__) || defined (__s390x__) + // The TOD clock on the s390 (read by get_cycles() ) + // is converted to a nano-second value using the following: + // (get_cycles() * 125) >> 7; + + delta = (delta * 125) >> 7; + +#else /* __s390__ || __s390x__ */ + // Verify units: // (D cycles) * (1E6 ns/ms) / (F cycles/ms [kHz]) = ns delta *= NSEC_PER_MSEC; do_div(delta, freq); +#endif + return base + delta; } - |