1 dnl Check for socklen_t: historically on BSD it is an int, and in
2 dnl POSIX 1g it is a type of its own, but some platforms use different
3 dnl types for the argument to getsockopt, getpeername, etc. So we
4 dnl have to test to find something that will work.
5 AC_DEFUN([TYPE_SOCKLEN_T],
7 AC_CHECK_TYPE([socklen_t], ,[
8 AC_MSG_CHECKING([for socklen_t equivalent])
9 AC_CACHE_VAL([git_cv_socklen_t_equiv],
11 # Systems have either "struct sockaddr *" or
12 # "void *" as the second argument to getpeername
13 git_cv_socklen_t_equiv=
14 for arg2 in "struct sockaddr" void; do
15 for t in int size_t unsigned long "unsigned long"; do
16 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
17 #include <sys/types.h>
18 #include <sys/socket.h>
20 int getpeername (int, $arg2 *, $t *);
23 getpeername(0,0,&len);
25 git_cv_socklen_t_equiv="$t"
31 if test "x$git_cv_socklen_t_equiv" = x; then
32 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
35 AC_MSG_RESULT($git_cv_socklen_t_equiv)
36 AC_DEFINE_UNQUOTED(socklen_t, $git_cv_socklen_t_equiv,
37 [type to use in place of socklen_t if not defined])],
38 [#include <sys/types.h>
39 #include <sys/socket.h>])