diff options
Diffstat (limited to 'lib/monotime.h')
| -rw-r--r-- | lib/monotime.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/monotime.h b/lib/monotime.h index 8e50c1874a..6aac966ea1 100644 --- a/lib/monotime.h +++ b/lib/monotime.h @@ -21,6 +21,10 @@ #include <time.h> #include <sys/time.h> +#ifdef __cplusplus +extern "C" { +#endif + #ifndef TIMESPEC_TO_TIMEVAL /* should be in sys/time.h on BSD & Linux libcs */ #define TIMESPEC_TO_TIMEVAL(tv, ts) \ @@ -80,4 +84,19 @@ static inline int64_t monotime_until(const struct timeval *ref, return (int64_t)tv.tv_sec * 1000000LL + tv.tv_usec; } +static inline char *time_to_string(time_t ts) +{ + struct timeval tv; + time_t tbuf; + + monotime(&tv); + tbuf = time(NULL) - (tv.tv_sec - ts); + + return ctime(&tbuf); +} + +#ifdef __cplusplus +} +#endif + #endif /* _FRR_MONOTIME_H */ |
