]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/ktime.h
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik...
[linux-2.6-omap-h63xx.git] / include / linux / ktime.h
index 5b9a9eb82baabbf03a6abc7a0087a2d4d9272d8a..f3dec45ef874d2d40ff883380201eb8d1e540f42 100644 (file)
  *
  *  Started by: Thomas Gleixner and Ingo Molnar
  *
+ *  Credits:
+ *
+ *     Roman Zippel provided the ideas and primary code snippets of
+ *     the ktime_t union and further simplifications of the original
+ *     code.
+ *
  *  For licencing details see kernel-base/COPYING
  */
 #ifndef _LINUX_KTIME_H
@@ -90,10 +96,16 @@ static inline ktime_t ktime_set(const long secs, const unsigned long nsecs)
                ({ (ktime_t){ .tv64 = (kt).tv64 + (nsval) }; })
 
 /* convert a timespec to ktime_t format: */
-#define timespec_to_ktime(ts)          ktime_set((ts).tv_sec, (ts).tv_nsec)
+static inline ktime_t timespec_to_ktime(struct timespec ts)
+{
+       return ktime_set(ts.tv_sec, ts.tv_nsec);
+}
 
 /* convert a timeval to ktime_t format: */
-#define timeval_to_ktime(tv)           ktime_set((tv).tv_sec, (tv).tv_usec * 1000)
+static inline ktime_t timeval_to_ktime(struct timeval tv)
+{
+       return ktime_set(tv.tv_sec, tv.tv_usec * NSEC_PER_USEC);
+}
 
 /* Map the ktime_t to timespec conversion to ns_to_timespec function */
 #define ktime_to_timespec(kt)          ns_to_timespec((kt).tv64)
@@ -266,4 +278,19 @@ static inline u64 ktime_to_ns(const ktime_t kt)
 
 #endif
 
+/*
+ * The resolution of the clocks. The resolution value is returned in
+ * the clock_getres() system call to give application programmers an
+ * idea of the (in)accuracy of timers. Timer values are rounded up to
+ * this resolution values.
+ */
+#define KTIME_REALTIME_RES     (ktime_t){ .tv64 = TICK_NSEC }
+#define KTIME_MONOTONIC_RES    (ktime_t){ .tv64 = TICK_NSEC }
+
+/* Get the monotonic time in timespec format: */
+extern void ktime_get_ts(struct timespec *ts);
+
+/* Get the real (wall-) time in timespec format: */
+#define ktime_get_real_ts(ts)  getnstimeofday(ts)
+
 #endif