aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/time.h
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2012-09-15 09:45:41 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-15 09:45:41 -0400
commitaa15f47714e0e98ae78c1516c2fc989fd375fe3b (patch)
tree40029561aee1f6e2a8f6cd49fab59416ba911c2c /include/linux/time.h
parentdb32d74a0e5fa2b25b6bdbd1cb3f69045538c956 (diff)
parent55d512e245bc7699a8800e23df1a24195dd08217 (diff)
Merge tag 'v3.6-rc5' into staging/for_v3.7
Linux 3.6-rc5 * tag 'v3.6-rc5': (334 commits) Linux 3.6-rc5 HID: tpkbd: work even if the new Lenovo Keyboard driver is not configured Remove user-triggerable BUG from mpol_to_str xen/pciback: Fix proper FLR steps. uml: fix compile error in deliver_alarm() dj: memory scribble in logi_dj Fix order of arguments to compat_put_time[spec|val] xen: Use correct masking in xen_swiotlb_alloc_coherent. xen: fix logical error in tlb flushing xen/p2m: Fix one-off error in checking the P2M tree directory. powerpc: Don't use __put_user() in patch_instruction powerpc: Make sure IPI handlers see data written by IPI senders powerpc: Restore correct DSCR in context switch powerpc: Fix DSCR inheritance in copy_thread() powerpc: Keep thread.dscr and thread.dscr_inherit in sync powerpc: Update DSCR on all CPUs when writing sysfs dscr_default powerpc/powernv: Always go into nap mode when CPU is offline powerpc: Give hypervisor decrementer interrupts their own handler powerpc/vphn: Fix arch_update_cpu_topology() return value ARM: gemini: fix the gemini build ...
Diffstat (limited to 'include/linux/time.h')
-rw-r--r--include/linux/time.h29
1 files changed, 27 insertions, 2 deletions
diff --git a/include/linux/time.h b/include/linux/time.h
index c81c5e40fcb5..b51e664c83e7 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -107,11 +107,36 @@ 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 return true;
129}
130
131static inline bool timespec_valid_strict(const struct timespec *ts)
132{
133 if (!timespec_valid(ts))
134 return false;
135 /* Disallow values that could overflow ktime_t */
136 if ((unsigned long long)ts->tv_sec >= KTIME_SEC_MAX)
137 return false;
138 return true;
139}
115 140
116extern void read_persistent_clock(struct timespec *ts); 141extern void read_persistent_clock(struct timespec *ts);
117extern void read_boot_clock(struct timespec *ts); 142extern void read_boot_clock(struct timespec *ts);