aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-08-24 00:46:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-08-24 00:46:57 -0400
commitb5bc0c7054725e238d1be6965fec452b0f0e5213 (patch)
treec92a6c31fb6eaec9ba5834a21a35e072b5d40db6 /include
parentd37e44969e60dc652fdbaf4397d5436e07c967af (diff)
parentbf2ac312195155511a0f79325515cbb61929898a (diff)
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer fixes from Thomas Gleixner: "Mostly small fixes for the fallout of the timekeeping overhaul in 3.6 along with stable fixes to address an accumulation problem and missing sanity checks for RTC readouts and user space provided values." * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: time: Avoid making adjustments if we haven't accumulated anything time: Avoid potential shift overflow with large shift values time: Fix casting issue in timekeeping_forward_now time: Ensure we normalize the timekeeper in tk_xtime_add time: Improve sanity checking of timekeeping inputs
Diffstat (limited to 'include')
-rw-r--r--include/linux/ktime.h7
-rw-r--r--include/linux/time.h22
2 files changed, 20 insertions, 9 deletions
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 603bec2913b..06177ba10a1 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -58,13 +58,6 @@ union ktime {
58 58
59typedef union ktime ktime_t; /* Kill this */ 59typedef union ktime ktime_t; /* Kill this */
60 60
61#define KTIME_MAX ((s64)~((u64)1 << 63))
62#if (BITS_PER_LONG == 64)
63# define KTIME_SEC_MAX (KTIME_MAX / NSEC_PER_SEC)
64#else
65# define KTIME_SEC_MAX LONG_MAX
66#endif
67
68/* 61/*
69 * ktime_t definitions when using the 64-bit scalar representation: 62 * ktime_t definitions when using the 64-bit scalar representation:
70 */ 63 */
diff --git a/include/linux/time.h b/include/linux/time.h
index c81c5e40fcb..b0bbd8f0130 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -107,11 +107,29 @@ static inline struct timespec timespec_sub(struct timespec lhs,
107 return ts_delta; 107 return ts_delta;
108} 108}
109 109
110#define KTIME_MAX ((s64)~((u64)1 << 63))
111#if (BITS_PER_LONG == 64)
112# define KTIME_SEC_MAX (KTIME_MAX / NSEC_PER_SEC)
113#else
114# define KTIME_SEC_MAX LONG_MAX
115#endif
116
110/* 117/*
111 * Returns true if the timespec is norm, false if denorm: 118 * Returns true if the timespec is norm, false if denorm:
112 */ 119 */
113#define timespec_valid(ts) \ 120static inline bool timespec_valid(const struct timespec *ts)
114 (((ts)->tv_sec >= 0) && (((unsigned long) (ts)->tv_nsec) < NSEC_PER_SEC)) 121{
122 /* Dates before 1970 are bogus */
123 if (ts->tv_sec < 0)
124 return false;
125 /* Can't have more nanoseconds then a second */
126 if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC)
127 return false;
128 /* Disallow values that could overflow ktime_t */
129 if ((unsigned long long)ts->tv_sec >= KTIME_SEC_MAX)
130 return false;
131 return true;
132}
115 133
116extern void read_persistent_clock(struct timespec *ts); 134extern void read_persistent_clock(struct timespec *ts);
117extern void read_boot_clock(struct timespec *ts); 135extern void read_boot_clock(struct timespec *ts);