[Asterisk-cvs] asterisk/include/asterisk sched.h, 1.7, 1.8 time.h,
1.3, 1.4
kpfleming at lists.digium.com
kpfleming at lists.digium.com
Fri Jul 15 18:52:58 CDT 2005
- Previous message: [Asterisk-cvs] asterisk/funcs func_strings.c,1.5,1.6
- Next message: [Asterisk-cvs] asterisk/channels chan_agent.c, 1.144,
1.145 chan_iax2.c, 1.319, 1.320 chan_phone.c, 1.54,
1.55 chan_sip.c, 1.780, 1.781 chan_vpb.c, 1.89,
1.90 chan_zap.c, 1.476, 1.477
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /usr/cvsroot/asterisk/include/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv13236/include/asterisk
Modified Files:
sched.h time.h
Log Message:
add a library of timeval manipulation functions, and change a large number of usses to use the new functions (bug #4504)
Index: sched.h
===================================================================
RCS file: /usr/cvsroot/asterisk/include/asterisk/sched.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- sched.h 3 May 2005 02:21:57 -0000 1.7
+++ sched.h 15 Jul 2005 23:00:47 -0000 1.8
@@ -100,7 +100,7 @@
* \param con Context to dump
* Debugging: Dump the contents of the scheduler to stderr
*/
-extern void ast_sched_dump(struct sched_context *con);
+extern void ast_sched_dump(const struct sched_context *con);
/*!Returns the number of seconds before an event takes place */
/*!
Index: time.h
===================================================================
RCS file: /usr/cvsroot/asterisk/include/asterisk/time.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- time.h 11 Jul 2005 23:25:31 -0000 1.3
+++ time.h 15 Jul 2005 23:00:47 -0000 1.4
@@ -23,9 +23,105 @@
* \return the difference in milliseconds
*/
AST_INLINE_API(
-int ast_tvdiff_ms(const struct timeval *end, const struct timeval *start),
+int ast_tvdiff_ms(struct timeval end, struct timeval start),
{
- return ((end->tv_sec - start->tv_sec) * 1000) + ((end->tv_usec - start->tv_usec) / 1000);
+ return ((end.tv_sec - start.tv_sec) * 1000) + ((end.tv_usec - start.tv_usec) / 1000);
+}
+)
+
+/*!
+ * \brief Returns true if the argument is 0,0
+ */
+AST_INLINE_API(
+int ast_tvzero(const struct timeval t),
+{
+ return (t.tv_sec == 0 && t.tv_usec == 0);
+}
+)
+
+/*!
+ * \brief Compres two \c struct \c timeval instances returning
+ * -1, 0, 1 if the first arg is smaller, equal or greater to the second.
+ */
+AST_INLINE_API(
+int ast_tvcmp(struct timeval _a, struct timeval _b),
+{
+ if (_a.tv_sec < _b.tv_sec)
+ return -1;
+ if (_a.tv_sec > _b.tv_sec)
+ return 1;
+ /* now seconds are equal */
+ if (_a.tv_usec < _b.tv_usec)
+ return -1;
+ if (_a.tv_usec > _b.tv_usec)
+ return 1;
+ return 0;
+}
+)
+
+/*!
+ * \brief Returns true if the two \c struct \c timeval arguments are equal.
+ */
+AST_INLINE_API(
+int ast_tveq(struct timeval _a, struct timeval _b),
+{
+ return (_a.tv_sec == _b.tv_sec && _a.tv_usec == _b.tv_usec);
+}
+)
+
+/*!
+ * \brief Returns current timeval. Meant to replace calls to gettimeofday().
+ */
+AST_INLINE_API(
+struct timeval ast_tvnow(void),
+{
+ struct timeval t;
+ gettimeofday(&t, NULL);
+ return t;
+}
+)
+
+/*!
+ * \brief Returns the sum of two timevals a + b
+ */
+struct timeval ast_tvadd(struct timeval a, struct timeval b);
+
+/*!
+ * \brief Returns the difference of two timevals a - b
+ */
+struct timeval ast_tvsub(struct timeval a, struct timeval b);
+
+/*!
+ * \brief Returns a timeval from sec, usec
+ */
+#if 0
+AST_INLINE_API(
+struct timeval ast_tv(int sec, int usec),
+{
+ struct timeval t = { sec, usec};
+ return t;
+}
+)
+#endif
+AST_INLINE_API(
+struct timeval ast_tv(int sec, int usec),
+{
+ struct timeval t;
+ t.tv_sec = sec;
+ t.tv_usec = usec;
+ return t;
+}
+)
+
+/*!
+ * \brief Returns a timeval corresponding to the duration of n samples at rate r.
+ * Useful to convert samples to timevals, or even milliseconds to timevals
+ * in the form ast_samp2tv(milliseconds, 1000)
+ */
+AST_INLINE_API(
+struct timeval ast_samp2tv(long _nsamp, long _rate),
+{
+ return ast_tv(_nsamp / _rate, (_nsamp % _rate) * (1000000 / _rate));
}
)
- Previous message: [Asterisk-cvs] asterisk/funcs func_strings.c,1.5,1.6
- Next message: [Asterisk-cvs] asterisk/channels chan_agent.c, 1.144,
1.145 chan_iax2.c, 1.319, 1.320 chan_phone.c, 1.54,
1.55 chan_sip.c, 1.780, 1.781 chan_vpb.c, 1.89,
1.90 chan_zap.c, 1.476, 1.477
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the svn-commits
mailing list