Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Nov 2011 07:59:45 +0000 (UTC)
From:      Lawrence Stewart <lstewart@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r228118 - head/sys/sys
Message-ID:  <201111290759.pAT7xjGe030206@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: lstewart
Date: Tue Nov 29 07:59:45 2011
New Revision: 228118
URL: http://svn.freebsd.org/changeset/base/228118

Log:
  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)

Modified:
  head/sys/sys/timeffc.h

Modified: head/sys/sys/timeffc.h
==============================================================================
--- head/sys/sys/timeffc.h	Tue Nov 29 06:53:36 2011	(r228117)
+++ head/sys/sys/timeffc.h	Tue Nov 29 07:59:45 2011	(r228118)
@@ -186,6 +186,132 @@ void fbclock_getbinuptime(struct bintime
 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. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201111290759.pAT7xjGe030206>