svn commit: r224721 - head/sys/sys
Jonathan Anderson
jonathan at FreeBSD.org
Mon Aug 8 20:36:53 UTC 2011
Author: jonathan
Date: Mon Aug 8 20:36:52 2011
New Revision: 224721
URL: http://svn.freebsd.org/changeset/base/224721
Log:
Create timeval2timespec() and timespec2timeval().
These functions will be used by process descriptors to convert process
creation time into process descriptor [acm]time.
Approved by: re (kib), mentor (rwatson)
Suggested by: jhb
Sponsored by: Google Inc
Modified:
head/sys/sys/time.h
Modified: head/sys/sys/time.h
==============================================================================
--- head/sys/sys/time.h Mon Aug 8 19:03:26 2011 (r224720)
+++ head/sys/sys/time.h Mon Aug 8 20:36:52 2011 (r224721)
@@ -195,6 +195,24 @@ timeval2bintime(const struct timeval *tv
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
((tvp)->tv_sec cmp (uvp)->tv_sec))
+/* Conversion between timespec and timeval. */
+
+static __inline void
+timeval2timespec(const struct timeval *tv, struct timespec *ts)
+{
+
+ ts->tv_sec = tv->tv_sec;
+ ts->tv_nsec = 1000 * tv->tv_usec;
+}
+
+static __inline void
+timespec2timeval(const struct timespec *ts, struct timeval *tv)
+{
+
+ tv->tv_sec = ts->tv_sec;
+ tv->tv_usec = ts->tv_nsec / 1000;
+}
+
/* timevaladd and timevalsub are not inlined */
#endif /* _KERNEL */
More information about the svn-src-head
mailing list