Index: include/asterisk/time.h =================================================================== --- include/asterisk/time.h (revision 89277) +++ include/asterisk/time.h (working copy) @@ -1,4 +1,4 @@ -/* +* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. @@ -36,6 +36,20 @@ typedef typeof(tv.tv_usec) ast_suseconds_t; /*! + * \brief Computes the difference (in microseconds) between two \c struct \c timeval instances. + * \param end the beginning of the time period + * \param start the end of the time period + * \return the difference in microseconds + */ +AST_INLINE_API( +int64_t ast_tvdiff_us(struct timeval end, struct timeval start), +{ + return (end.tv_sec - start.tv_sec) * 1000000L + + end.tv_usec - start.tv_usec; +} +) + +/*! * \brief Computes the difference (in milliseconds) between two \c struct \c timeval instances. * \param end the beginning of the time period * \param start the end of the time period