Skip to content

Commit

Permalink
timeval: New function xclock_gettime().
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Ed Maste <[email protected]>
  • Loading branch information
blp committed Jul 11, 2013
1 parent 9eba675 commit bc7ad7d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/timeval.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static void
refresh_wall(void)
{
time_init();
clock_gettime(CLOCK_REALTIME, &wall_time);
xclock_gettime(CLOCK_REALTIME, &wall_time);
wall_tick = false;
}

Expand All @@ -218,7 +218,7 @@ refresh_monotonic(void)

if (!time_stopped) {
if (monotonic_clock == CLOCK_MONOTONIC) {
clock_gettime(monotonic_clock, &monotonic_time);
xclock_gettime(monotonic_clock, &monotonic_time);
} else {
refresh_wall_if_ticked();
monotonic_time = wall_time;
Expand Down Expand Up @@ -460,6 +460,16 @@ xgettimeofday(struct timeval *tv)
}
}

void
xclock_gettime(clock_t id, struct timespec *ts)
{
if (clock_gettime(id, ts) == -1) {
/* It seems like a bad idea to try to use vlog here because it is
* likely to try to check the current time. */
ovs_abort(errno, "xclock_gettime() failed");
}
}

static long long int
timeval_diff_msec(const struct timeval *a, const struct timeval *b)
{
Expand Down
1 change: 1 addition & 0 deletions lib/timeval.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ long long int timespec_to_msec(const struct timespec *);
long long int timeval_to_msec(const struct timeval *);

void xgettimeofday(struct timeval *);
void xclock_gettime(clock_t, struct timespec *);

int get_cpu_usage(void);
void format_backtraces(struct ds *, size_t min_count);
Expand Down

0 comments on commit bc7ad7d

Please sign in to comment.