Date: Mon, 8 Aug 2011 20:36:53 +0000 (UTC) From: Jonathan Anderson <jonathan@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r224721 - head/sys/sys Message-ID: <201108082036.p78KarlR062810@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108082036.p78KarlR062810>