Better socklen_t test for 2.9.9p2
openssh-unix-dev at thewrittenword.com
openssh-unix-dev at thewrittenword.com
Sat Sep 29 13:54:46 EST 2001
Better test for socklen_t equivalent (stolen from cURL). It requires
autoconf 2.50. Against 2.9.9p2.
--
albert chin (china at thewrittenword.com)
-- snip snip
--- aclocal.m4.orig Fri Sep 28 22:50:42 2001
+++ aclocal.m4 Thu Sep 27 01:53:23 2001
@@ -43,3 +43,43 @@
AC_SUBST($1)
])
+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.
+AC_DEFUN([TYPE_SOCKLEN_T],
+[
+ AC_CHECK_TYPE([socklen_t], ,[
+ AC_MSG_CHECKING([for socklen_t equivalent])
+ AC_CACHE_VAL([curl_cv_socklen_t_equiv],
+ [
+ # Systems have either "struct sockaddr *" or
+ # "void *" as the second argument to getpeername
+ curl_cv_socklen_t_equiv=
+ for arg2 in "struct sockaddr" void; do
+ for t in int size_t unsigned long "unsigned long"; do
+ AC_TRY_COMPILE([
+ #include <sys/types.h>
+ #include <sys/socket.h>
+
+ int getpeername (int, $arg2 *, $t *);
+ ],[
+ $t len;
+ getpeername(0,0,&len);
+ ],[
+ curl_cv_socklen_t_equiv="$t"
+ break
+ ])
+ done
+ done
+
+ if test "x$curl_cv_socklen_t_equiv" = x; then
+ AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
+ fi
+ ])
+ AC_MSG_RESULT($curl_cv_socklen_t_equiv)
+ AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
+ [type to use in place of socklen_t if not defined])],
+ [#include <sys/types.h>
+#include <sys/socket.h>])
+])
--- configure.in.orig Thu Sep 27 01:16:56 2001
+++ configure.in Thu Sep 27 10:11:04 2001
@@ -929,20 +993,7 @@
AC_DEFINE(HAVE_U_CHAR)
fi
-AC_CACHE_CHECK([for socklen_t], ac_cv_have_socklen_t, [
- AC_TRY_COMPILE(
- [
-#include <sys/types.h>
-#include <sys/socket.h>
- ],
- [socklen_t foo; foo = 1235;],
- [ ac_cv_have_socklen_t="yes" ],
- [ ac_cv_have_socklen_t="no" ]
- )
-])
-if test "x$ac_cv_have_socklen_t" = "xyes" ; then
- AC_DEFINE(HAVE_SOCKLEN_T)
-fi
+TYPE_SOCKLEN_T
AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
AC_TRY_COMPILE(
--- defines.h.orig Thu Sep 27 01:54:38 2001
+++ defines.h Thu Sep 27 01:54:44 2001
@@ -243,11 +243,6 @@
# define HAVE_U_CHAR
#endif /* HAVE_U_CHAR */
-#ifndef HAVE_SOCKLEN_T
-typedef unsigned int socklen_t;
-# define HAVE_SOCKLEN_T
-#endif /* HAVE_SOCKLEN_T */
-
#ifndef HAVE_SIZE_T
typedef unsigned int size_t;
# define HAVE_SIZE_T
--- acconfig.h.orig Thu Sep 27 01:30:35 2001
+++ acconfig.h Thu Sep 27 01:54:33 2001
@@ -251,7 +251,6 @@
#undef HAVE_INT64_T
#undef HAVE_U_INT64_T
#undef HAVE_U_CHAR
-#undef HAVE_SOCKLEN_T
#undef HAVE_SIZE_T
#undef HAVE_SSIZE_T
#undef HAVE_CLOCK_T
More information about the openssh-unix-dev
mailing list