From e18a7471729855f1b5aee3fe4aa279da1297d48f Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Thu, 9 Jun 2005 14:39:34 +0000 Subject: move timeval-diff function into utils.h from app_alarmreceiver.c git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5882 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- include/asterisk/utils.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index 5b2001a6d..9fb0b83cd 100755 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -247,4 +247,17 @@ void ast_copy_string(char *dst, const char *src, size_t size); */ int ast_build_string(char **buffer, size_t *space, const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); +/* functions for working with 'struct timeval' instances */ + +/*! + * \brief Computes the difference (in milliseconds) between two \c struct \c timeval instances. + * \param start the beginning of the time period + * \param end the end of the time period + * \return the difference in milliseconds + */ +static inline int ast_tvdiff_ms(struct timeval *start, struct timeval *end) +{ + return ((end->tv_sec - start->tv_sec) * 1000) + ((end->tv_usec - start->tv_usec) / 1000); +} + #endif /* _ASTERISK_UTILS_H */ -- cgit v1.2.3