X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/76d4988d0623e9d85d6b8cbe76b4e4dce4531e3f..fab9a9c54729984199d20b637ea8cc163c73d2e2:/aclocal.m4 diff --git a/aclocal.m4 b/aclocal.m4 index 96c4ebb1..a1256ae8 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -96,3 +96,62 @@ 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 is no good, because passing the wrong pointer on C compilers is +dnl likely to only generate a warning, not an error. We don't call this at +dnl the moment. + +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 + ], + [ + AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) + ]) + 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 +]) +