Try various different types as replacements for socklen_t until we
authorMartin Pool <mbp@samba.org>
Wed, 8 Aug 2001 08:11:50 +0000 (08:11 +0000)
committerMartin Pool <mbp@samba.org>
Wed, 8 Aug 2001 08:11:50 +0000 (08:11 +0000)
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
configure.in

index 96c4ebb..e35b9a7 100644 (file)
@@ -96,3 +96,58 @@ AC_DEFUN([AC_SYS_LARGEFILE],
        [#include <stdio.h>], [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 <sys/types.h>
+         #include <sys/socket.h>
+      ],
+      [
+         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 <sys/types.h>
+               #include <sys/socket.h>
+            ],
+            [
+               $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
+])
+
index 95b47b4..d5c626d 100644 (file)
@@ -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 <errno.h>],[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