--- arch/ppc/kernel/time.c.orig Sun Jul 6 02:35:18 2003 +++ arch/ppc/kernel/time.c Sun Jul 6 02:20:27 2003 @@ -277,6 +277,18 @@ xtime.tv_nsec = new_nsec; xtime.tv_sec = new_sec; + wall_to_monotonic.tv_sec += xtime.tv_sec - tv->tv_sec; + wall_to_monotonic.tv_nsec += xtime.tv_nsec - tv->tv_nsec; + + if (wall_to_monotonic.tv_nsec > NSEC_PER_SEC) { + wall_to_monotonic.tv_nsec -= NSEC_PER_SEC; + wall_to_monotonic.tv_sec++; + } + if (wall_to_monotonic.tv_nsec < 0) { + wall_to_monotonic.tv_nsec += NSEC_PER_SEC; + wall_to_monotonic.tv_sec--; + } + /* In case of a large backwards jump in time with NTP, we want the * clock to be updated as soon as the PLL is again in lock. */ @@ -347,6 +359,8 @@ sys_tz.tz_dsttime = 0; xtime.tv_sec -= time_offset; } + wall_to_monotonic.tv_sec = -xtime.tv_sec; + wall_to_monotonic.tv_nsec = -xtime.tv_nsec; } #define FEBRUARY 2 @@ -427,4 +441,14 @@ if (err <= inscale/2) mlt++; return mlt; } + +/* monotonic_clock(): returns # of nanoseconds passed since time_init() + * Note: This function is required to return accurate + * time even in the absence of multiple timer ticks. + */ +unsigned long long monotonic_clock(void) +{ + return xtime.tv_sec * NSEC_PER_SEC + xtime.tv_nsec; +} +EXPORT_SYMBOL(monotonic_clock);