From: Donald Sharp Date: Thu, 27 Oct 2016 16:26:00 +0000 (-0400) Subject: pimd: Add the ability to get time in usec X-Git-Tag: frr-3.0-branchpoint~64^2~10^2~164 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=8a9bd91cd9ebcecf3c9492ba1865d908448338da;p=mirror%2Ffrr.git pimd: Add the ability to get time in usec Add ability to return a int64_t time in usec. Signed-off-by: Donald Sharp --- diff --git a/pimd/pim_time.c b/pimd/pim_time.c index ab3ac7340a..9bae661ba9 100644 --- a/pimd/pim_time.c +++ b/pimd/pim_time.c @@ -83,6 +83,25 @@ int64_t pim_time_monotonic_dsec() return now_dsec; } +int64_t +pim_time_monotonic_usec (void) +{ + struct timeval now_tv; + int64_t now_dsec; + + if (gettime_monotonic(&now_tv)) { + zlog_err("%s: gettime_monotonic() failure: errno=%d: %s", + __PRETTY_FUNCTION__, + errno, safe_strerror(errno)); + return -1; + } + + now_dsec = ((int64_t) now_tv.tv_sec) * 1000000 + ((int64_t) now_tv.tv_usec); + + return now_dsec; + +} + int pim_time_mmss(char *buf, int buf_size, long sec) { long mm; diff --git a/pimd/pim_time.h b/pimd/pim_time.h index 0081b21bbb..9f811f1b94 100644 --- a/pimd/pim_time.h +++ b/pimd/pim_time.h @@ -29,6 +29,7 @@ int64_t pim_time_monotonic_sec(void); int64_t pim_time_monotonic_dsec(void); +int64_t pim_time_monotonic_usec(void); int pim_time_mmss(char *buf, int buf_size, long sec); void pim_time_timer_to_mmss(char *buf, int buf_size, struct thread *t); void pim_time_timer_to_hhmmss(char *buf, int buf_size, struct thread *t);