|
Packit |
0680ba |
# socklen.m4 serial 4
|
|
Packit |
0680ba |
dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
|
Packit |
0680ba |
dnl This file is free software; the Free Software Foundation
|
|
Packit |
0680ba |
dnl gives unlimited permission to copy and/or distribute it,
|
|
Packit |
0680ba |
dnl with or without modifications, as long as this notice is preserved.
|
|
Packit |
0680ba |
|
|
Packit |
0680ba |
dnl From Albert Chin, Windows fixes from Simon Josefsson.
|
|
Packit |
0680ba |
|
|
Packit |
0680ba |
dnl Check for socklen_t: historically on BSD it is an int, and in
|
|
Packit |
0680ba |
dnl POSIX 1g it is a type of its own, but some platforms use different
|
|
Packit |
0680ba |
dnl types for the argument to getsockopt, getpeername, etc. So we
|
|
Packit |
0680ba |
dnl have to test to find something that will work.
|
|
Packit |
0680ba |
|
|
Packit |
0680ba |
dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find
|
|
Packit |
0680ba |
dnl it there first. That file is included by gnulib's socket_.h, which
|
|
Packit |
0680ba |
dnl all users of this module should include. Cygwin must not include
|
|
Packit |
0680ba |
dnl ws2tcpip.h.
|
|
Packit |
0680ba |
AC_DEFUN([gl_TYPE_SOCKLEN_T],
|
|
Packit |
0680ba |
[AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl
|
|
Packit |
0680ba |
AC_CHECK_TYPE([socklen_t], ,
|
|
Packit |
0680ba |
[AC_MSG_CHECKING([for socklen_t equivalent])
|
|
Packit |
0680ba |
AC_CACHE_VAL([gl_cv_gl_cv_socklen_t_equiv],
|
|
Packit |
0680ba |
[# Systems have either "struct sockaddr *" or
|
|
Packit |
0680ba |
# "void *" as the second argument to getpeername
|
|
Packit |
0680ba |
gl_cv_socklen_t_equiv=
|
|
Packit |
0680ba |
for arg2 in "struct sockaddr" void; do
|
|
Packit |
0680ba |
for t in int size_t "unsigned int" "long int" "unsigned long int"; do
|
|
Packit |
0680ba |
AC_TRY_COMPILE(
|
|
Packit |
0680ba |
[#include <sys/types.h>
|
|
Packit |
0680ba |
#include <sys/socket.h>
|
|
Packit |
0680ba |
|
|
Packit |
0680ba |
int getpeername (int, $arg2 *, $t *);],
|
|
Packit |
0680ba |
[$t len;
|
|
Packit |
0680ba |
getpeername (0, 0, &len;;],
|
|
Packit |
0680ba |
[gl_cv_socklen_t_equiv="$t"])
|
|
Packit |
0680ba |
test "$gl_cv_socklen_t_equiv" != "" && break
|
|
Packit |
0680ba |
done
|
|
Packit |
0680ba |
test "$gl_cv_socklen_t_equiv" != "" && break
|
|
Packit |
0680ba |
done
|
|
Packit |
0680ba |
])
|
|
Packit |
0680ba |
if test "$gl_cv_socklen_t_equiv" = ""; then
|
|
Packit |
0680ba |
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
|
|
Packit |
0680ba |
fi
|
|
Packit |
0680ba |
AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
|
|
Packit |
0680ba |
AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
|
|
Packit |
0680ba |
[type to use in place of socklen_t if not defined])],
|
|
Packit |
0680ba |
[#include <sys/types.h>
|
|
Packit |
0680ba |
#if HAVE_SYS_SOCKET_H
|
|
Packit |
0680ba |
# include <sys/socket.h>
|
|
Packit |
0680ba |
#elif HAVE_WS2TCPIP_H
|
|
Packit |
0680ba |
# include <ws2tcpip.h>
|
|
Packit |
0680ba |
#endif])])
|