aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk/utils.h
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-06-09 14:39:34 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-06-09 14:39:34 +0000
commit54c8bb2a71a8115d4076d94f54ce0d5dba02603e (patch)
tree63859a8a4348b4a0ac78e2f5e78deac39117daf5 /include/asterisk/utils.h
parentec67bfa81ece4d0111d53887f8d69d45cd771d49 (diff)
move timeval-diff function into utils.h from app_alarmreceiver.c
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5882 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include/asterisk/utils.h')
-rwxr-xr-xinclude/asterisk/utils.h13
1 files changed, 13 insertions, 0 deletions
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 */