From 40f34b2bcd81cfe83dbda90a77d9a9065366f14e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Thu, 7 Mar 2013 21:38:07 +0100 Subject: [PATCH] Fix comments. add convenience macro --- include/ucore/clock.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/include/ucore/clock.h b/include/ucore/clock.h index 45adf32..1ec4c0d 100644 --- a/include/ucore/clock.h +++ b/include/ucore/clock.h @@ -23,6 +23,12 @@ struct UCoreClock { void (*now)(struct UCoreClock *clock, struct timeval *tv); }; +/** Convenience macro for geting the time from a UCoreClock + * @param uclock pointer to the clock + * @param tv struct timeval pointer that will be filled in. + */ +#define UCORE_CLOCK_NOW(uclock, tv) (uclock)->now((uclock), (tv)) + /** A cached clock where clock.now() returns * the cached value. The cache is updated @@ -34,7 +40,7 @@ struct UCoreCachedClock { struct UCoreClock clock; /** The underlying real clock*/ struct UCoreClock *real_clock; - /** cached value */ + /** Cached value */ struct timeval cache; }; @@ -45,7 +51,6 @@ struct UCoreCachedClock { struct UCoreSettableClock { /** The clock*/ struct UCoreClock clock; - /** The underlying real clock*/ /** Current value */ struct timeval now; }; @@ -62,9 +67,13 @@ extern struct UCoreClock uc_timeofday_clock; extern struct UCoreClock uc_time_clock; /** - * Initialize a cached clock where now() calls time(). - * This clock will this just have seconds resolution. - * @param clock clock to initialize + * Initialize a cached clock whose now() is a cached + * value of the real_clock. + * + * @param uclock clock to initialize + * @param real_clock underlying clock that updates + * the cache. + * */ void uc_cached_clock_init(struct UCoreCachedClock *uclock, struct UCoreClock *real_clock); @@ -75,9 +84,10 @@ void uc_cached_clock_update(struct UCoreCachedClock *uclock); /** - * Initialize a user settable where now() calls time(). - * This clock will this just have seconds resolution. - * @param clock clock to initialize + * Initialize a user settable clock, where now() + * returns the user set time. + * + * @param clock uclock to initialize */ void uc_settable_clock_init(struct UCoreSettableClock *uclock); @@ -88,7 +98,7 @@ void uc_settable_clock_set_tv(struct UCoreSettableClock *uclock, const struct timeval *tv); /** - * Set the new timeval this clock will return + * Set the new time this clock will return * Convenience function that takes seconds/microseconds as arguments * instead of a struct timeval. **/