From faaa0db717917bd09a3c21baf71af40a2cc52738 Mon Sep 17 00:00:00 2001 From: jistone Date: Wed, 20 Sep 2006 21:01:56 +0000 Subject: 2006-09-20 Josh Stone PR 3233 ./ * stapfuncs.5.in: Document new gettimeofday_ns. runtime/ * time.c (stp_time_t): Use ns for the base time, and freq is now kHz. (__stp_estimate_cpufreq): Compute kHz instead of MHz. (__stp_time_timer_callback, __stp_init_time): Compute base in ns. (__stp_time_cpufreq_callback): Record kHz instead of MHz. (_stp_init_time): Record kHz, and disable preemption to avoid a race in the cpufreq notifier. (_stp_gettimeofday_ns): Converted from _stp_gettimeofday_us. tapset/ * timestamp.stp (gettimeofday_ns): New function (gettimeofday_us, gettimeofday_ms, gettimeofday_s): Use gettimeofday_ns as the base unit. testsuite/ * buildok/timestamp.stp: add gettimeofday_ns test. --- tapset/timestamp.stp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'tapset/timestamp.stp') diff --git a/tapset/timestamp.stp b/tapset/timestamp.stp index d0c89df8..8db0faef 100644 --- a/tapset/timestamp.stp +++ b/tapset/timestamp.stp @@ -20,21 +20,26 @@ function get_cycles:long () %{ /* pure */ %} -// return in microseconds since epoch -function gettimeofday_us:long () %{ /* pure */ +// return in nanoseconds since epoch +function gettimeofday_ns:long () %{ /* pure */ /* NOTE: we can't use do_gettimeofday because we could be called from a * context where xtime_lock is already held. See bug #2525. */ - THIS->__retvalue = _stp_gettimeofday_us(); + THIS->__retvalue = _stp_gettimeofday_ns(); %} +// return in microseconds since epoch +function gettimeofday_us:long () { + return gettimeofday_ns() / 1000; +} + // return in milliseconds since epoch function gettimeofday_ms:long () { - return gettimeofday_us() / 1000; + return gettimeofday_ns() / 1000000; } // return in seconds since epoch function gettimeofday_s:long () { - return gettimeofday_us() / 1000000; + return gettimeofday_ns() / 1000000000; } // likewise jiffies, monotonic_clock ... -- cgit