Make the clock_now interface const

This commit is contained in:
Nils O. Selåsdal
2015-02-10 11:03:44 +01:00
parent f0c829a6c9
commit 617ba23c39
2 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ struct UCoreClock {
* Wrapper for getting the current time. * Wrapper for getting the current time.
* @param tv timeval that will be filled in * @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 /** Convenience macro for geting the time from a UCoreClock
+8 -8
View File
@@ -7,12 +7,12 @@
#define UNUSED #define UNUSED
#endif #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); 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_sec = time(NULL);
tv->tv_usec = 0; tv->tv_usec = 0;
@@ -28,11 +28,11 @@ struct UCoreClock uc_time_clock = {
.now = uc_time_now, .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 timeval *tv)
{ {
struct UCoreCachedClock *cached_clock; const struct UCoreCachedClock *cached_clock;
cached_clock = UC_CONTAINER_OF(uclock, struct UCoreCachedClock, clock), cached_clock = UC_CONST_CONTAINER_OF(uclock, const struct UCoreCachedClock, clock),
*tv = cached_clock->cache; *tv = cached_clock->cache;
} }
@@ -52,10 +52,10 @@ void uc_cached_clock_update(struct UCoreCachedClock *uclock)
uclock->real_clock->now(&uclock->clock, &uclock->cache); 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; const struct UCoreSettableClock *cached_clock;
cached_clock = UC_CONTAINER_OF(uclock, struct UCoreSettableClock, clock), cached_clock = UC_CONST_CONTAINER_OF(uclock, const struct UCoreSettableClock, clock),
*tv = cached_clock->now; *tv = cached_clock->now;
} }