X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/546434f8671d3137a7bb9347395111a8043d1f59..12458878c26f738a76883c67b02a89c617036d9b:/aclocal.m4 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 +]) +