1 dnl Check for socklen_t: historically on BSD it is an int, and in
2 dnl POSIX 1g it is a type of its own, but some platforms use different
3 dnl types for the argument to getsockopt, getpeername, etc. So we
4 dnl have to test to find something that will work.
6 dnl This is no good, because passing the wrong pointer on C compilers is
7 dnl likely to only generate a warning, not an error. We don't call this at
10 AC_DEFUN([TYPE_SOCKLEN_T],
12 AC_CHECK_TYPE([socklen_t], ,[
13 AC_MSG_CHECKING([for socklen_t equivalent])
14 AC_CACHE_VAL([rsync_cv_socklen_t_equiv],
16 # Systems have either "struct sockaddr *" or
17 # "void *" as the second argument to getpeername
18 rsync_cv_socklen_t_equiv=
19 for arg2 in "struct sockaddr" void; do
20 for t in int size_t unsigned long "unsigned long"; do
21 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
22 #include <sys/types.h>
23 #include <sys/socket.h>
25 int getpeername (int, $arg2 *, $t *);
28 getpeername(0,0,&len);
30 rsync_cv_socklen_t_equiv="$t"
36 if test "x$rsync_cv_socklen_t_equiv" = x; then
37 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
40 AC_MSG_RESULT($rsync_cv_socklen_t_equiv)
41 AC_DEFINE_UNQUOTED(socklen_t, $rsync_cv_socklen_t_equiv,
42 [type to use in place of socklen_t if not defined])],
43 [#include <sys/types.h>
44 #include <sys/socket.h>])