Don't shadow the global clock function
This commit is contained in:
@@ -66,12 +66,12 @@ extern struct ucore_clock ucore_time_clock;
|
|||||||
* This clock will this just have seconds resolution.
|
* This clock will this just have seconds resolution.
|
||||||
* @param clock clock to initialize
|
* @param clock clock to initialize
|
||||||
*/
|
*/
|
||||||
void ucore_cached_clock_init(struct ucore_cached_clock *clock,
|
void ucore_cached_clock_init(struct ucore_cached_clock *uclock,
|
||||||
struct ucore_clock *real_clock);
|
struct ucore_clock *real_clock);
|
||||||
|
|
||||||
/** Update the cached clock from the real_clock
|
/** Update the cached clock from the real_clock
|
||||||
*/
|
*/
|
||||||
void ucore_cached_clock_update(struct ucore_cached_clock *clock);
|
void ucore_cached_clock_update(struct ucore_cached_clock *uclock);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,12 +79,12 @@ void ucore_cached_clock_update(struct ucore_cached_clock *clock);
|
|||||||
* This clock will this just have seconds resolution.
|
* This clock will this just have seconds resolution.
|
||||||
* @param clock clock to initialize
|
* @param clock clock to initialize
|
||||||
*/
|
*/
|
||||||
void ucore_settable_clock_init(struct ucore_settable_clock *clock);
|
void ucore_settable_clock_init(struct ucore_settable_clock *uclock);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the new timeval this clock will return
|
* Set the new timeval this clock will return
|
||||||
**/
|
**/
|
||||||
void ucore_settable_clock_set_tv(struct ucore_settable_clock *clock,
|
void ucore_settable_clock_set_tv(struct ucore_settable_clock *uclock,
|
||||||
const struct timeval *tv);
|
const struct timeval *tv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,7 +92,7 @@ void ucore_settable_clock_set_tv(struct ucore_settable_clock *clock,
|
|||||||
* Convenience function that takes seconds/microseconds as arguments
|
* Convenience function that takes seconds/microseconds as arguments
|
||||||
* instead of a struct timeval.
|
* instead of a struct timeval.
|
||||||
**/
|
**/
|
||||||
void ucore_settable_clock_set(struct ucore_settable_clock *clock,
|
void ucore_settable_clock_set(struct ucore_settable_clock *uclock,
|
||||||
time_t secs, suseconds_t usecs);
|
time_t secs, suseconds_t usecs);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+21
-21
@@ -28,54 +28,54 @@ struct ucore_clock ucore_time_clock = {
|
|||||||
.now = ucore_time_now,
|
.now = ucore_time_now,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void ucore_cached_clock_now(struct ucore_clock *clock UNUSED,
|
static void ucore_cached_clock_now(struct ucore_clock *uclock UNUSED,
|
||||||
struct timeval *tv)
|
struct timeval *tv)
|
||||||
{
|
{
|
||||||
struct ucore_cached_clock *cached_clock;
|
struct ucore_cached_clock *cached_clock;
|
||||||
cached_clock = CONTAINER_OF(clock, struct ucore_cached_clock, clock),
|
cached_clock = CONTAINER_OF(uclock, struct ucore_cached_clock, clock),
|
||||||
|
|
||||||
*tv = cached_clock->cache;
|
*tv = cached_clock->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ucore_cached_clock_init(struct ucore_cached_clock *clock, struct ucore_clock *real_clock)
|
void ucore_cached_clock_init(struct ucore_cached_clock *uclock, struct ucore_clock *real_clock)
|
||||||
{
|
{
|
||||||
clock->clock.name = "cached clock";
|
uclock->clock.name = "cached clock";
|
||||||
clock->clock.now = ucore_cached_clock_now;
|
uclock->clock.now = ucore_cached_clock_now;
|
||||||
|
|
||||||
clock->real_clock = real_clock;
|
uclock->real_clock = real_clock;
|
||||||
|
|
||||||
ucore_cached_clock_update(clock);
|
ucore_cached_clock_update(uclock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ucore_cached_clock_update(struct ucore_cached_clock *clock)
|
void ucore_cached_clock_update(struct ucore_cached_clock *uclock)
|
||||||
{
|
{
|
||||||
clock->real_clock->now(&clock->clock, &clock->cache);
|
uclock->real_clock->now(&uclock->clock, &uclock->cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ucore_settable_clock_now(struct ucore_clock *clock, struct timeval *tv)
|
static void ucore_settable_clock_now(struct ucore_clock *uclock, struct timeval *tv)
|
||||||
{
|
{
|
||||||
struct ucore_settable_clock *cached_clock;
|
struct ucore_settable_clock *cached_clock;
|
||||||
cached_clock = CONTAINER_OF(clock, struct ucore_settable_clock, clock),
|
cached_clock = CONTAINER_OF(uclock, struct ucore_settable_clock, clock),
|
||||||
|
|
||||||
*tv = cached_clock->now;
|
*tv = cached_clock->now;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ucore_settable_clock_init(struct ucore_settable_clock *clock)
|
void ucore_settable_clock_init(struct ucore_settable_clock *uclock)
|
||||||
{
|
{
|
||||||
clock->clock.name = "settable clock";
|
uclock->clock.name = "settable clock";
|
||||||
clock->clock.now = ucore_settable_clock_now;
|
uclock->clock.now = ucore_settable_clock_now;
|
||||||
|
|
||||||
clock->now.tv_sec = 0;
|
uclock->now.tv_sec = 0;
|
||||||
clock->now.tv_usec = 0;
|
uclock->now.tv_usec = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ucore_settable_clock_set_tv(struct ucore_settable_clock *clock, const struct timeval *tv)
|
void ucore_settable_clock_set_tv(struct ucore_settable_clock *uclock, const struct timeval *tv)
|
||||||
{
|
{
|
||||||
clock->now = *tv;
|
uclock->now = *tv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ucore_settable_clock_set(struct ucore_settable_clock *clock, time_t secs, suseconds_t usecs)
|
void ucore_settable_clock_set(struct ucore_settable_clock *uclock, time_t secs, suseconds_t usecs)
|
||||||
{
|
{
|
||||||
clock->now.tv_sec = secs;
|
uclock->now.tv_sec = secs;
|
||||||
clock->now.tv_usec = usecs;
|
uclock->now.tv_usec = usecs;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user