From 12458878c26f738a76883c67b02a89c617036d9b Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Wed, 8 Aug 2001 08:11:50 +0000 Subject: [PATCH] Try various different types as replacements for socklen_t until we find one that works. This helps on platforms like HP/UX and UNICOS where the argument to getsockopt is neither socklen_t nor int. --- aclocal.m4 | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 6 +++--- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 96c4ebb1..e35b9a71 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -96,3 +96,58 @@ AC_DEFUN([AC_SYS_LARGEFILE], [#include ], [return !ftello;]) fi ]) + +dnl Check for socklen_t: historically on BSD it is an int, and in +dnl POSIX 1g it is a type of its own, but some platforms use different +dnl types for the argument to getsockopt, getpeername, etc. So we +dnl have to test to find something that will work. + +dnl This test originally comes from lftp, by way of Albert Chin at The +dnl Written Word. Thanks! + +AC_DEFUN([TYPE_SOCKLEN_T], +[ + AC_MSG_CHECKING([for socklen_t]) + AC_CACHE_VAL([lftp_cv_socklen_t], + [ + lftp_cv_socklen_t=no + AC_TRY_COMPILE([ + #include + #include + ], + [ + socklen_t len; + getpeername(0,0,&len); + ], + [ + lftp_cv_socklen_t=yes + ]) + ]) + AC_MSG_RESULT($lftp_cv_socklen_t) + if test $lftp_cv_socklen_t = no; then + AC_MSG_CHECKING([for socklen_t equivalent]) + AC_CACHE_VAL([lftp_cv_socklen_t_equiv], + [ + lftp_cv_socklen_t_equiv=int + AC_LANG_SAVE + for t in int size_t unsigned long "unsigned long"; do + AC_TRY_COMPILE([ + #include + #include + ], + [ + $t len; + getpeername(0,0,&len); + ], + [ + lftp_cv_socklen_t_equiv="$t" + break + ]) + done + ]) + AC_MSG_RESULT($lftp_cv_socklen_t_equiv) + AC_DEFINE_UNQUOTED(socklen_t, $lftp_cv_socklen_t_equiv, + [type to use in place of socklen_t if not defined]) + fi +]) + diff --git a/configure.in b/configure.in index 95b47b42..d5c626d3 100644 --- a/configure.in +++ b/configure.in @@ -77,7 +77,7 @@ AC_TYPE_PID_T AC_TYPE_GETGROUPS AC_STRUCT_ST_RDEV AC_CHECK_TYPE([ino_t], [unsigned]) -AC_CHECK_TYPE([socklen_t], [int]) +TYPE_SOCKLEN_T AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [ AC_TRY_COMPILE([#include ],[int i = errno], @@ -163,10 +163,10 @@ then AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes]) fi -AC_MSG_CHECKING("whether to use included libpopt") +AC_MSG_CHECKING([whether to use included libpopt]) if test x"$with_included_popt" = x"yes" then - AC_MSG_RESULT("$srcdir/popt") + AC_MSG_RESULT($srcdir/popt) BUILD_POPT='$(popt_OBJS)' CFLAGS="$CFLAGS -I$srcdir/popt" else -- 2.34.1