From 6915f50dd3cba100d23a2afedcbc2aa1368bdc0d Mon Sep 17 00:00:00 2001 From: Jason Parker Date: Thu, 22 Apr 2010 22:02:22 +0000 Subject: 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 --- utils/Makefile | 16 ++++++++++------ utils/extconf.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 6 deletions(-) (limited to 'utils') diff --git a/utils/Makefile b/utils/Makefile index 355954906..24fb97403 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -86,7 +86,7 @@ clean: rm -f *.o $(ALL_UTILS) check_expr rm -f .*.d rm -f *.s *.i - rm -f md5.c strcompat.c ast_expr2.c ast_expr2.h ast_expr2f.c pbx_ael.c pval.c hashtab.c + rm -f md5.c strcompat.c ast_expr2.c ast_expr2.h ast_expr2f.c pbx_ael.c pval.c hashtab.c lock.c rm -f aelparse.c aelbison.c conf2ael rm -f utils.c strings.c threadstorage.c sha1.c astobj2.c hashtest2 hashtest refcounter @@ -105,6 +105,10 @@ hashtab.c: $(ASTTOPDIR)/main/hashtab.c $(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@" $(CMD_PREFIX) cp "$<" "$@" +lock.c: $(ASTTOPDIR)/main/lock.c + $(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@" + $(CMD_PREFIX) cp "$<" "$@" + strcompat.c: $(ASTTOPDIR)/main/strcompat.c $(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@" $(CMD_PREFIX) cp "$<" "$@" @@ -143,7 +147,7 @@ aelparse.c: $(ASTTOPDIR)/res/ael/ael_lex.c aelparse.o: _ASTCFLAGS+=-I$(ASTTOPDIR)/res -Wno-unused aelparse: LIBS+=-lm -aelparse: aelparse.o aelbison.o pbx_ael.o hashtab.o ael_main.o ast_expr2f.o ast_expr2.o strcompat.o pval.o extconf.o +aelparse: aelparse.o aelbison.o pbx_ael.o hashtab.o lock.o utils.o ael_main.o ast_expr2f.o ast_expr2.o strcompat.o pval.o extconf.o astobj2.c: $(ASTTOPDIR)/main/astobj2.c $(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@" @@ -170,17 +174,17 @@ threadstorage.c: $(ASTTOPDIR)/main/threadstorage.c $(CMD_PREFIX) cp "$<" "$@" hashtest2.o: _ASTCFLAGS+=-O0 -hashtest2: hashtest2.o md5.o utils.o strings.o astobj2.o sha1.o strcompat.o threadstorage.o clicompat.o poll.o +hashtest2: hashtest2.o md5.o lock.o utils.o strings.o astobj2.o sha1.o strcompat.o threadstorage.o clicompat.o poll.o -hashtest: hashtest.o md5.o hashtab.o utils.o strings.o sha1.o strcompat.o threadstorage.o clicompat.o poll.o +hashtest: hashtest.o md5.o hashtab.o lock.o utils.o strings.o sha1.o strcompat.o threadstorage.o clicompat.o poll.o hashtest.o: _ASTCFLAGS+=-O0 -refcounter: refcounter.o md5.o hashtab.o utils.o strings.o sha1.o strcompat.o threadstorage.o clicompat.o poll.o +refcounter: refcounter.o md5.o hashtab.o lock.o utils.o strings.o sha1.o strcompat.o threadstorage.o clicompat.o poll.o refcounter.o: _ASTCFLAGS+=-O0 extconf.o: extconf.c -conf2ael: conf2ael.o ast_expr2f.o ast_expr2.o hashtab.o aelbison.o aelparse.o pbx_ael.o pval.o extconf.o strcompat.o +conf2ael: conf2ael.o ast_expr2f.o ast_expr2.o hashtab.o lock.o aelbison.o aelparse.o pbx_ael.o pval.o extconf.o strcompat.o check_expr2: $(ASTTOPDIR)/main/ast_expr2f.c $(ASTTOPDIR)/main/ast_expr2.c $(ASTTOPDIR)/main/ast_expr2.h $(ECHO_PREFIX) echo " [CC] ast_expr2f.c -> ast_expr2fz.o" 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 -- cgit v1.2.3