From 75dd1320fc506c0898c4380d98bfb6def5f16c61 Mon Sep 17 00:00:00 2001 From: Kalle Wallin Date: Tue, 6 Apr 2004 19:31:05 +0000 Subject: [PATCH] Added a new test for socklen_t. git-svn-id: https://svn.musicpd.org/ncmpc/trunk@615 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- configure.ac | 11 ++++++--- m4/socklen_t.m4 | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 m4/socklen_t.m4 diff --git a/configure.ac b/configure.ac index b799344..28961b1 100644 --- a/configure.ac +++ b/configure.ac @@ -20,9 +20,14 @@ CFLAGS="-Wall $CFLAGS" dnl dnl Check for types dnl -AC_CHECK_TYPE(socklen_t, - AC_DEFINE(HAVE_SOCKLEN_T, 1, socklen_t defined in sys/socket.h), -) +dnl AC_CHECK_TYPE(socklen_t, +dnl AC_DEFINE(HAVE_SOCKLEN_T, 1, socklen_t defined in sys/socket.h), +dnl ) + +AC_SOCKLEN_T + + + dnl diff --git a/m4/socklen_t.m4 b/m4/socklen_t.m4 new file mode 100644 index 0000000..dc90667 --- /dev/null +++ b/m4/socklen_t.m4 @@ -0,0 +1,66 @@ + +dnl Like AC_TRY_EVAL but also errors out if the compiler generates +dnl _any_ output. Some compilers might issue warnings which we want +dnl to catch. +AC_DEFUN([AC_TRY_EVAL2], +[{ (eval echo configure:__oline__: \"[$]$1\") 1>&AC_FD_CC; dnl +(eval [$]$1) 2>&AC_FD_CC; _out=`eval [$]$1 2>&1` && test "x$_out" = x; }]) + + +dnl Like AC_TRY_COMPILE but calls AC_TRY_EVAL2 instead of AC_TRY_EVAL +AC_DEFUN([AC_TRY_COMPILE2], +[cat > conftest.$ac_ext <&AC_FD_CC + cat conftest.$ac_ext >&AC_FD_CC +ifelse([$4], , , [ rm -rf conftest* + $4 +])dnl +fi +rm -f conftest*]) + +dnl Determine what socket length (socklen_t) data type is +AC_DEFUN([AC_SOCKLEN_T], +[ +AC_MSG_CHECKING([for type of socket length (socklen_t)]) +AC_TRY_COMPILE2([ +#include +#include +#include ],[ +(void)getsockopt (1, 1, 1, NULL, (socklen_t *)NULL)],[ + AC_MSG_RESULT(socklen_t *) + SOCKLEN_T=socklen_t],[ + AC_TRY_COMPILE2([ +#include +#include +#include ],[ +(void)getsockopt (1, 1, 1, NULL, (size_t *)NULL)],[ + AC_MSG_RESULT(size_t *) + SOCKLEN_T=size_t],[ + AC_TRY_COMPILE2([ +#include +#include +#include ],[ +(void)getsockopt (1, 1, 1, NULL, (int *)NULL)],[ + AC_MSG_RESULT(int *) + SOCKLEN_T=int],[ + AC_MSG_WARN(could not determine) + SOCKLEN_T="unsigned int"])])]) + +if test "$SOCKLEN_T" = socklen_t; then + AC_DEFINE(HAVE_SOCKLEN_T, 1, socklen_t defined in sys/socket.h) +fi + +AC_DEFINE_UNQUOTED(SOCKLEN_T, $SOCKLEN_T, [Determine what socket length (socklen_t) data type is]) + +]) -- 2.30.2