Better socklen_t test for 2.9.9p2

openssh-unix-dev at thewrittenword.com openssh-unix-dev at thewrittenword.com
Sat Sep 29 14:31:44 EST 2001


On Fri, Sep 28, 2001 at 11:09:48PM -0500, mouring at etoh.eviladmin.org wrote:
> This is not directly cURL code, but cURL is under MIT/X or MPL licenses
> which are both semi-conflict with BSD license.  We really should get
> someone at the project to give an ok to put the fragment under BSD.

TYPE_SOCKLEN_T originally came from the rsync project (sorry). I
contributed it so own the copyright. The original patch can be found
at:
  http://lists.samba.org/pipermail/rsync/2001-August/004690.html

You have my permission to use it under the same license as OpenSSH.
Let me know if there is anything else that needs to be done to get
TYPE_SOCKLEN_T included. It is part of Rsync and cURL and has been
tested successfully on:
  Solaris 2.5.1, 2.6, 7, 8/SPARC, HP-UX 10.20, 11.00,
  Tru64 UNIX 4.0D, 5.0A, 5.1, IRIX 6.2, 6.5, AIX 4.3.2.

> - Ben
> 
> On Fri, 28 Sep 2001 openssh-unix-dev at thewrittenword.com wrote:
> 
> > 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
> >

-- 
albert chin (china at thewrittenword.com)



More information about the openssh-unix-dev mailing list