diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-12-12 22:03:53 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-12-12 22:03:53 -0500 |
commit | 9da305eb089c94c535d1790fd2dec16f44c1689f (patch) | |
tree | f37f07f148fd7a793233c7f15c0fa9f46212049d /kernel/time.c | |
parent | d96212ed87d032d2d830e265aae14038dc1f8ad8 (diff) | |
parent | 14ee0a1414536d27bc29373bf23c106b8ef8ce0b (diff) |
Merge branch 'master'
Diffstat (limited to 'kernel/time.c')
-rw-r--r-- | kernel/time.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/kernel/time.c b/kernel/time.c index 245d595a13cb..b94bfa8c03e0 100644 --- a/kernel/time.c +++ b/kernel/time.c @@ -561,6 +561,28 @@ void getnstimeofday(struct timespec *tv) EXPORT_SYMBOL_GPL(getnstimeofday); #endif +void getnstimestamp(struct timespec *ts) +{ + unsigned int seq; + struct timespec wall2mono; + + /* synchronize with settimeofday() changes */ + do { + seq = read_seqbegin(&xtime_lock); + getnstimeofday(ts); + wall2mono = wall_to_monotonic; + } while(unlikely(read_seqretry(&xtime_lock, seq))); + + /* adjust to monotonicaly-increasing values */ + ts->tv_sec += wall2mono.tv_sec; + ts->tv_nsec += wall2mono.tv_nsec; + while (unlikely(ts->tv_nsec >= NSEC_PER_SEC)) { + ts->tv_nsec -= NSEC_PER_SEC; + ts->tv_sec++; + } +} +EXPORT_SYMBOL_GPL(getnstimestamp); + #if (BITS_PER_LONG < 64) u64 get_jiffies_64(void) { |