From: Ben Pfaff Date: Thu, 11 Jul 2013 23:50:15 +0000 (-0700) Subject: timeval: New function xclock_gettime(). X-Git-Tag: sliver-openvswitch-2.0.90-1~36^2~47 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=bc7ad7d4740b10d08249b2e8017c766396ff53ce;p=sliver-openvswitch.git timeval: New function xclock_gettime(). Signed-off-by: Ben Pfaff Acked-by: Ed Maste --- diff --git a/lib/timeval.c b/lib/timeval.c index 0ccfa42a3..65c85a0ce 100644 --- a/lib/timeval.c +++ b/lib/timeval.c @@ -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; } @@ -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; @@ -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) { diff --git a/lib/timeval.h b/lib/timeval.h index eff28e229..7bf8d1f77 100644 --- a/lib/timeval.h +++ b/lib/timeval.h @@ -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);