|
|
|
@@ -1,5 +1,5 @@
|
|
|
|
|
#ifndef UCORE_CLOCK_H_
|
|
|
|
|
#define UCORE_CLOCK_H_
|
|
|
|
|
#ifndef uc_CLOCK_H_
|
|
|
|
|
#define uc_CLOCK_H_
|
|
|
|
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
@@ -26,7 +26,7 @@ struct UCoreClock {
|
|
|
|
|
|
|
|
|
|
/** A cached clock where clock.now() returns
|
|
|
|
|
* the cached value. The cache is updated
|
|
|
|
|
* from the real_clock whenever ucore_cached_clock_update()
|
|
|
|
|
* from the real_clock whenever uc_cached_clock_update()
|
|
|
|
|
* is called.
|
|
|
|
|
*/
|
|
|
|
|
struct UCoreCachedClock {
|
|
|
|
@@ -40,7 +40,7 @@ struct UCoreCachedClock {
|
|
|
|
|
|
|
|
|
|
/** A settable clock where clock.now() returns
|
|
|
|
|
* the user settable value. The user updates the clock
|
|
|
|
|
* with ucore_settable_clock_set().
|
|
|
|
|
* with uc_settable_clock_set().
|
|
|
|
|
*/
|
|
|
|
|
struct UCoreSettableClock {
|
|
|
|
|
/** The clock*/
|
|
|
|
@@ -53,25 +53,25 @@ struct UCoreSettableClock {
|
|
|
|
|
|
|
|
|
|
/** A clock where now() calls gettimeofday()
|
|
|
|
|
*/
|
|
|
|
|
extern struct UCoreClock ucore_timeofday_clock;
|
|
|
|
|
extern struct UCoreClock uc_timeofday_clock;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A clock where now() calls time().
|
|
|
|
|
* This clock will just have seconds resolution.
|
|
|
|
|
*/
|
|
|
|
|
extern struct UCoreClock ucore_time_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
|
|
|
|
|
*/
|
|
|
|
|
void ucore_cached_clock_init(struct UCoreCachedClock *uclock,
|
|
|
|
|
void uc_cached_clock_init(struct UCoreCachedClock *uclock,
|
|
|
|
|
struct UCoreClock *real_clock);
|
|
|
|
|
|
|
|
|
|
/** Update the cached clock from the real_clock
|
|
|
|
|
*/
|
|
|
|
|
void ucore_cached_clock_update(struct UCoreCachedClock *uclock);
|
|
|
|
|
void uc_cached_clock_update(struct UCoreCachedClock *uclock);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -79,12 +79,12 @@ void ucore_cached_clock_update(struct UCoreCachedClock *uclock);
|
|
|
|
|
* This clock will this just have seconds resolution.
|
|
|
|
|
* @param clock clock to initialize
|
|
|
|
|
*/
|
|
|
|
|
void ucore_settable_clock_init(struct UCoreSettableClock *uclock);
|
|
|
|
|
void uc_settable_clock_init(struct UCoreSettableClock *uclock);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the new timeval this clock will return
|
|
|
|
|
**/
|
|
|
|
|
void ucore_settable_clock_set_tv(struct UCoreSettableClock *uclock,
|
|
|
|
|
void uc_settable_clock_set_tv(struct UCoreSettableClock *uclock,
|
|
|
|
|
const struct timeval *tv);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -92,7 +92,7 @@ void ucore_settable_clock_set_tv(struct UCoreSettableClock *uclock,
|
|
|
|
|
* Convenience function that takes seconds/microseconds as arguments
|
|
|
|
|
* instead of a struct timeval.
|
|
|
|
|
**/
|
|
|
|
|
void ucore_settable_clock_set(struct UCoreSettableClock *uclock,
|
|
|
|
|
void uc_settable_clock_set(struct UCoreSettableClock *uclock,
|
|
|
|
|
time_t secs, suseconds_t usecs);
|
|
|
|
|
|
|
|
|
|
#endif
|