diff options
author | Jason Parker <jparker@digium.com> | 2010-04-22 22:02:22 +0000 |
---|---|---|
committer | Jason Parker <jparker@digium.com> | 2010-04-22 22:02:22 +0000 |
commit | 6915f50dd3cba100d23a2afedcbc2aa1368bdc0d (patch) | |
tree | 4dcd75ab296baa5800043eb7a3bf9a86d23f2b3c /utils/extconf.c | |
parent | 8c41f2db8290ffc31d1bb35d00098a97288fe869 (diff) |
Let utils/ dir compile when DEBUG_THREADS is not enabled.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@258673 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'utils/extconf.c')
-rw-r--r-- | utils/extconf.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/utils/extconf.c b/utils/extconf.c index 25d7b137f..f1f92fdd4 100644 --- a/utils/extconf.c +++ b/utils/extconf.c @@ -2801,6 +2801,55 @@ static int ast_true(const char *s) return 0; } +#define ONE_MILLION 1000000 +/* + * put timeval in a valid range. usec is 0..999999 + * negative values are not allowed and truncated. + */ +static struct timeval tvfix(struct timeval a) +{ + if (a.tv_usec >= ONE_MILLION) { + ast_log(LOG_WARNING, "warning too large timestamp %ld.%ld\n", + (long)a.tv_sec, (long int) a.tv_usec); + a.tv_sec += a.tv_usec / ONE_MILLION; + a.tv_usec %= ONE_MILLION; + } else if (a.tv_usec < 0) { + ast_log(LOG_WARNING, "warning negative timestamp %ld.%ld\n", + (long)a.tv_sec, (long int) a.tv_usec); + a.tv_usec = 0; + } + return a; +} + +struct timeval ast_tvadd(struct timeval a, struct timeval b) +{ + /* consistency checks to guarantee usec in 0..999999 */ + a = tvfix(a); + b = tvfix(b); + a.tv_sec += b.tv_sec; + a.tv_usec += b.tv_usec; + if (a.tv_usec >= ONE_MILLION) { + a.tv_sec++; + a.tv_usec -= ONE_MILLION; + } + return a; +} + +struct timeval ast_tvsub(struct timeval a, struct timeval b) +{ + /* consistency checks to guarantee usec in 0..999999 */ + a = tvfix(a); + b = tvfix(b); + a.tv_sec -= b.tv_sec; + a.tv_usec -= b.tv_usec; + if (a.tv_usec < 0) { + a.tv_sec-- ; + a.tv_usec += ONE_MILLION; + } + return a; +} +#undef ONE_MILLION + /* stolen from pbx.c */ #define VAR_BUF_SIZE 4096 |