Use autoconf logic to determine whether the system has timersub or not. Do not blindly assume Solaris does not.

(closes issue #13838)
Reported by: ano


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@164343 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2008-12-15 17:43:59 +00:00
parent dfa5f7c4b4
commit b80ffd6d26
4 changed files with 72 additions and 6 deletions

64
configure vendored
View File

@@ -1,5 +1,5 @@
#! /bin/sh
# From configure.ac Revision: 159025 .
# From configure.ac Revision: 159808 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for asterisk 1.4.
#
@@ -14572,6 +14572,60 @@ fi
done
{ echo "$as_me:$LINENO: checking for timersub in time.h" >&5
echo $ECHO_N "checking for timersub in time.h... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <sys/time.h>
int
main ()
{
struct timeval *zombies; timersub(zombies, zombies, zombies);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
cat >>confdefs.h <<\_ACEOF
#define HAVE_TIMERSUB 1
_ACEOF
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
# some systems already have gethostbyname_r so we don't need to build ours in main/utils.c
{ echo "$as_me:$LINENO: checking for library containing gethostbyname_r" >&5
echo $ECHO_N "checking for library containing gethostbyname_r... $ECHO_C" >&6; }
@@ -15378,9 +15432,9 @@ if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/nu
echo "${ECHO_T}yes" >&6; }
AST_DECLARATION_AFTER_STATEMENT=-Wdeclaration-after-statement
else
{ echo "$as_me:$LINENO: result: no" >&5
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
AST_DECLARATION_AFTER_STATEMENT=
AST_DECLARATION_AFTER_STATEMENT=
fi
@@ -15404,9 +15458,9 @@ if $(${CC} -O2 -fno-strict-overflow -S -o /dev/null -xc /dev/null > /dev/null 2>
echo "${ECHO_T}yes" >&6; }
AST_NO_STRICT_OVERFLOW=-fno-strict-overflow
else
{ echo "$as_me:$LINENO: result: no" >&5
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
AST_NO_STRICT_OVERFLOW=
AST_NO_STRICT_OVERFLOW=
fi

View File

@@ -267,6 +267,15 @@ AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([asprintf atexit bzero dup2 endpwent floor ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap pow putenv re_comp regcomp rint select setenv socket sqrt strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf ioperm])
AC_MSG_CHECKING(for timersub in time.h)
AC_LINK_IFELSE(
AC_LANG_PROGRAM([#include <sys/time.h>],
[struct timeval *zombies; timersub(zombies, zombies, zombies);]),
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_TIMERSUB], 1, [Define to 1 if your system has timersub in time.h]),
AC_MSG_RESULT(no)
)
# some systems already have gethostbyname_r so we don't need to build ours in main/utils.c
AC_SEARCH_LIBS(gethostbyname_r, [socket nsl])

View File

@@ -498,6 +498,9 @@
/* Define to 1 if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H
/* Define to 1 if your system has timersub in time.h */
#undef HAVE_TIMERSUB
/* Define to indicate the ${TINFO_DESCRIP} library */
#undef HAVE_TINFO

View File

@@ -1315,7 +1315,7 @@ static inline int ast_fdisset(struct pollfd *pfds, int fd, int max, int *start)
return 0;
}
#ifdef SOLARIS
#ifndef HAVE_TIMERSUB
static inline void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff)
{
tvdiff->tv_sec = tvend->tv_sec - tvstart->tv_sec;