summaryrefslogtreecommitdiffstats
path: root/sys/sys
diff options
context:
space:
mode:
authorlstewart <lstewart@FreeBSD.org>2011-11-29 07:59:45 +0000
committerlstewart <lstewart@FreeBSD.org>2011-11-29 07:59:45 +0000
commit930bf9596b2b4f8a8de3c29afcb01ad820dbd1d6 (patch)
tree0e96d8c5f4d36ce8f86067eb3fbbb10607a4e26c /sys/sys
parentd76140d56b49a0146cbcc625f37cbd69ddb014c9 (diff)
downloadFreeBSD-src-930bf9596b2b4f8a8de3c29afcb01ad820dbd1d6.zip
FreeBSD-src-930bf9596b2b4f8a8de3c29afcb01ad820dbd1d6.tar.gz
Introduce the new "fromclock" public wrapper API which allows consumers to
select which system clock to obtain time from, independent of the current default system clock. In the brave new multi sysclock world, both feedback and feed-forward system clocks can be maintained and used concurrently, so this API provides a minimalist first step for interested consumers to exercise control over their choice of system clock. Committed on behalf of Julien Ridoux and Darryl Veitch from the University of Melbourne, Australia, as part of the FreeBSD Foundation funded "Feed-Forward Clock Synchronization Algorithms" project. For more information, see http://www.synclab.org/radclock/ Discussed with: Julien Ridoux (jridoux at unimelb edu au) Submitted by: Julien Ridoux (jridoux at unimelb edu au)
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/timeffc.h126
1 files changed, 126 insertions, 0 deletions
diff --git a/sys/sys/timeffc.h b/sys/sys/timeffc.h
index fcf41ed..58fa9a9a 100644
--- a/sys/sys/timeffc.h
+++ b/sys/sys/timeffc.h
@@ -186,6 +186,132 @@ void fbclock_getbinuptime(struct bintime *bt);
void fbclock_getnanouptime(struct timespec *tsp);
void fbclock_getmicrouptime(struct timeval *tvp);
+/*
+ * Public system clock wrapper API which allows consumers to select which clock
+ * to obtain time from, independent of the current default system clock. These
+ * wrappers should be used instead of directly calling the underlying fbclock_
+ * or ffclock_ functions.
+ */
+static inline void
+bintime_fromclock(struct bintime *bt, int whichclock)
+{
+
+ if (whichclock == SYSCLOCK_FFWD)
+ ffclock_bintime(bt);
+ else
+ fbclock_bintime(bt);
+}
+
+static inline void
+nanotime_fromclock(struct timespec *tsp, int whichclock)
+{
+
+ if (whichclock == SYSCLOCK_FFWD)
+ ffclock_nanotime(tsp);
+ else
+ fbclock_nanotime(tsp);
+}
+
+static inline void
+microtime_fromclock(struct timeval *tvp, int whichclock)
+{
+
+ if (whichclock == SYSCLOCK_FFWD)
+ ffclock_microtime(tvp);
+ else
+ fbclock_microtime(tvp);
+}
+
+static inline void
+getbintime_fromclock(struct bintime *bt, int whichclock)
+{
+
+ if (whichclock == SYSCLOCK_FFWD)
+ ffclock_getbintime(bt);
+ else
+ fbclock_getbintime(bt);
+}
+
+static inline void
+getnanotime_fromclock(struct timespec *tsp, int whichclock)
+{
+
+ if (whichclock == SYSCLOCK_FFWD)
+ ffclock_getnanotime(tsp);
+ else
+ fbclock_getnanotime(tsp);
+}
+
+static inline void
+getmicrotime_fromclock(struct timeval *tvp, int whichclock)
+{
+
+ if (whichclock == SYSCLOCK_FFWD)
+ ffclock_getmicrotime(tvp);
+ else
+ fbclock_getmicrotime(tvp);
+}
+
+static inline void
+binuptime_fromclock(struct bintime *bt, int whichclock)
+{
+
+ if (whichclock == SYSCLOCK_FFWD)
+ ffclock_binuptime(bt);
+ else
+ fbclock_binuptime(bt);
+}
+
+static inline void
+nanouptime_fromclock(struct timespec *tsp, int whichclock)
+{
+
+ if (whichclock == SYSCLOCK_FFWD)
+ ffclock_nanouptime(tsp);
+ else
+ fbclock_nanouptime(tsp);
+}
+
+static inline void
+microuptime_fromclock(struct timeval *tvp, int whichclock)
+{
+
+ if (whichclock == SYSCLOCK_FFWD)
+ ffclock_microuptime(tvp);
+ else
+ fbclock_microuptime(tvp);
+}
+
+static inline void
+getbinuptime_fromclock(struct bintime *bt, int whichclock)
+{
+
+ if (whichclock == SYSCLOCK_FFWD)
+ ffclock_getbinuptime(bt);
+ else
+ fbclock_getbinuptime(bt);
+}
+
+static inline void
+getnanouptime_fromclock(struct timespec *tsp, int whichclock)
+{
+
+ if (whichclock == SYSCLOCK_FFWD)
+ ffclock_getnanouptime(tsp);
+ else
+ fbclock_getnanouptime(tsp);
+}
+
+static inline void
+getmicrouptime_fromclock(struct timeval *tvp, int whichclock)
+{
+
+ if (whichclock == SYSCLOCK_FFWD)
+ ffclock_getmicrouptime(tvp);
+ else
+ fbclock_getmicrouptime(tvp);
+}
+
#else /* !_KERNEL */
/* Feed-Forward Clock system calls. */
OpenPOWER on IntegriCloud