diff --git a/include/villas/timing.h b/include/villas/timing.h index de25e3d9c..b04dfdab4 100644 --- a/include/villas/timing.h +++ b/include/villas/timing.h @@ -47,22 +47,22 @@ uint64_t timerfd_wait(int fd); * @retval 0 An error occured. Maybe the timer was stopped. * @retval >0 The nummer of runs this timer already fired. */ -uint64_t timerfd_wait_until(int fd, struct timespec *until); +uint64_t timerfd_wait_until(int fd, const struct timespec *until); /** Get delta between two timespec structs */ -struct timespec time_diff(struct timespec *start, struct timespec *end); +struct timespec time_diff(const struct timespec *start, const struct timespec *end); /** Get sum of two timespec structs */ -struct timespec time_add(struct timespec *start, struct timespec *end); +struct timespec time_add(const struct timespec *start, const struct timespec *end); /** Return current time as a struct timespec. */ struct timespec time_now(); /** Return the diffrence off two timestamps as double value in seconds. */ -double time_delta(struct timespec *start, struct timespec *end); +double time_delta(const struct timespec *start, const struct timespec *end); /** Convert timespec to double value representing seconds */ -double time_to_double(struct timespec *ts); +double time_to_double(const struct timespec *ts); /** Convert double containing seconds after 1970 to timespec. */ struct timespec time_from_double(double secs); \ No newline at end of file diff --git a/lib/timing.c b/lib/timing.c index 9f34bffb2..c2cb1e1ac 100644 --- a/lib/timing.c +++ b/lib/timing.c @@ -54,7 +54,7 @@ uint64_t timerfd_wait(int fd) return read(fd, &runs, sizeof(runs)) < 0 ? 0 : runs; } -uint64_t timerfd_wait_until(int fd, struct timespec *until) +uint64_t timerfd_wait_until(int fd, const struct timespec *until) { int ret; struct itimerspec its = { @@ -78,7 +78,7 @@ struct timespec time_now() return ts; } -struct timespec time_add(struct timespec *start, struct timespec *end) +struct timespec time_add(const struct timespec *start, const struct timespec *end) { struct timespec sum = { .tv_sec = end->tv_sec + start->tv_sec, @@ -93,7 +93,7 @@ struct timespec time_add(struct timespec *start, struct timespec *end) return sum; } -struct timespec time_diff(struct timespec *start, struct timespec *end) +struct timespec time_diff(const struct timespec *start, const struct timespec *end) { struct timespec diff = { .tv_sec = end->tv_sec - start->tv_sec, @@ -118,12 +118,12 @@ struct timespec time_from_double(double secs) return ts; } -double time_to_double(struct timespec *ts) +double time_to_double(const struct timespec *ts) { return ts->tv_sec + ts->tv_nsec * 1e-9; } -double time_delta(struct timespec *start, struct timespec *end) +double time_delta(const struct timespec *start, const struct timespec *end) { struct timespec diff = time_diff(start, end);