[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: socklen_t
From: |
Albert Chin |
Subject: |
Re: socklen_t |
Date: |
Thu, 1 Sep 2005 04:43:30 -0500 |
User-agent: |
Mutt/1.5.6i |
On Wed, Aug 31, 2005 at 04:18:20PM +0200, Simon Josefsson wrote:
> +AC_DEFUN([gl_SOCKLEN_T],
> +[
> + AC_CHECK_HEADERS_ONCE(sys/types.h sys/socket.h netdb.h)
> + AC_CHECK_TYPE([socklen_t],, [AC_DEFINE([socklen_t], [int],
> + [Map `socklen_t' to `int' if it is missing.])], [
> +#ifdef HAVE_SYS_TYPES_H
> +# include <sys/types.h>
> +#endif
> +#ifdef HAVE_SYS_SOCKET_H
> +# include <sys/socket.h>
> +#endif
> +#ifdef HAVE_NETDB_H
> +# include <netdb.h>
> +#endif])
> +])
We created the following macro for curl. It's been tested on the
following systems:
AIX 4.3.3, 5.1, 5.2, 5.3
HP-UX 10.20, 11.00, 11i
IRIX 6.5
Redhat Linux 7.1, 9
RHEL 2.1, 3, 4
Solaris 2.5.1, 2.6, 7, 8, 9, 10/SPARC
Tru64 UNIX 4.0D, 5.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([socklen_t_equiv],
[
# Systems have either "struct sockaddr *" or
# "void *" as the second argument to getpeername
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);
],[
socklen_t_equiv="$t"
break
])
done
done
if test "x$socklen_t_equiv" = x; then
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
fi
])
AC_MSG_RESULT($socklen_t_equiv)
AC_DEFINE_UNQUOTED(socklen_t, $socklen_t_equiv,
[type to use in place of socklen_t if not defined])],
[#include <sys/types.h>
#include <sys/socket.h>])
])
--
albert chin (address@hidden)
- Re: socklen_t,
Albert Chin <=
Re: socklen_t, Stepan Kasal, 2005/09/12