Make the clock_now interface const
This commit is contained in:
@@ -26,7 +26,7 @@ struct UCoreClock {
|
||||
* Wrapper for getting the current time.
|
||||
* @param tv timeval that will be filled in
|
||||
*/
|
||||
void (*now)(struct UCoreClock *clock, struct timeval *tv);
|
||||
void (*now)(const struct UCoreClock *clock, struct timeval *tv);
|
||||
};
|
||||
|
||||
/** Convenience macro for geting the time from a UCoreClock
|
||||
|
||||
+8
-8
@@ -7,12 +7,12 @@
|
||||
#define UNUSED
|
||||
#endif
|
||||
|
||||
static void uc_timeofday_now(struct UCoreClock *uclock UNUSED, struct timeval *tv)
|
||||
static void uc_timeofday_now(const struct UCoreClock *uclock UNUSED, struct timeval *tv)
|
||||
{
|
||||
gettimeofday(tv, NULL);
|
||||
}
|
||||
|
||||
static void uc_time_now(struct UCoreClock *uclock UNUSED, struct timeval *tv)
|
||||
static void uc_time_now(const struct UCoreClock *uclock UNUSED, struct timeval *tv)
|
||||
{
|
||||
tv->tv_sec = time(NULL);
|
||||
tv->tv_usec = 0;
|
||||
@@ -28,11 +28,11 @@ struct UCoreClock uc_time_clock = {
|
||||
.now = uc_time_now,
|
||||
};
|
||||
|
||||
static void uc_cached_clock_now(struct UCoreClock *uclock,
|
||||
static void uc_cached_clock_now(const struct UCoreClock *uclock,
|
||||
struct timeval *tv)
|
||||
{
|
||||
struct UCoreCachedClock *cached_clock;
|
||||
cached_clock = UC_CONTAINER_OF(uclock, struct UCoreCachedClock, clock),
|
||||
const struct UCoreCachedClock *cached_clock;
|
||||
cached_clock = UC_CONST_CONTAINER_OF(uclock, const struct UCoreCachedClock, clock),
|
||||
|
||||
*tv = cached_clock->cache;
|
||||
}
|
||||
@@ -52,10 +52,10 @@ void uc_cached_clock_update(struct UCoreCachedClock *uclock)
|
||||
uclock->real_clock->now(&uclock->clock, &uclock->cache);
|
||||
}
|
||||
|
||||
static void uc_settable_clock_now(struct UCoreClock *uclock, struct timeval *tv)
|
||||
static void uc_settable_clock_now(const struct UCoreClock *uclock, struct timeval *tv)
|
||||
{
|
||||
struct UCoreSettableClock *cached_clock;
|
||||
cached_clock = UC_CONTAINER_OF(uclock, struct UCoreSettableClock, clock),
|
||||
const struct UCoreSettableClock *cached_clock;
|
||||
cached_clock = UC_CONST_CONTAINER_OF(uclock, const struct UCoreSettableClock, clock),
|
||||
|
||||
*tv = cached_clock->now;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user