]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/time.h
clocksource: introduce CLOCK_MONOTONIC_RAW
[linux-2.6-omap-h63xx.git] / include / linux / time.h
index d32ef0ad4c0aaf8964d94abe215c5dbf4dde8aaf..205f974b9ebf1677e5fd269a5c17fdd7acdeacd0 100644 (file)
@@ -6,6 +6,7 @@
 #ifdef __KERNEL__
 # include <linux/cache.h>
 # include <linux/seqlock.h>
+# include <linux/math64.h>
 #endif
 
 #ifndef _STRUCT_TIMESPEC
@@ -116,6 +117,7 @@ extern int do_setitimer(int which, struct itimerval *value,
 extern unsigned int alarm_setitimer(unsigned int seconds);
 extern int do_getitimer(int which, struct itimerval *value);
 extern void getnstimeofday(struct timespec *tv);
+extern void getrawmonotonic(struct timespec *ts);
 extern void getboottime(struct timespec *ts);
 extern void monotonic_to_bootbased(struct timespec *ts);
 
@@ -169,18 +171,13 @@ extern struct timeval ns_to_timeval(const s64 nsec);
  * timespec_add_ns - Adds nanoseconds to a timespec
  * @a:         pointer to timespec to be incremented
  * @ns:                unsigned nanoseconds value to be added
+ *
+ * This must always be inlined because its used from the x86-64 vdso,
+ * which cannot call other kernel functions.
  */
-static inline void timespec_add_ns(struct timespec *a, u64 ns)
+static __always_inline void timespec_add_ns(struct timespec *a, u64 ns)
 {
-       ns += a->tv_nsec;
-       while(unlikely(ns >= NSEC_PER_SEC)) {
-               /* The following asm() prevents the compiler from
-                * optimising this loop into a modulo operation.  */
-               asm("" : "+r"(ns));
-
-               ns -= NSEC_PER_SEC;
-               a->tv_sec++;
-       }
+       a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
        a->tv_nsec = ns;
 }
 #endif /* __KERNEL__ */
@@ -218,6 +215,7 @@ struct itimerval {
 #define CLOCK_MONOTONIC                        1
 #define CLOCK_PROCESS_CPUTIME_ID       2
 #define CLOCK_THREAD_CPUTIME_ID                3
+#define CLOCK_MONOTONIC_RAW            4
 
 /*
  * The IDs of various hardware clocks: