Update for 1.4.18
[xapian.git] / xapian-core / m4 / xapian_type_socklen_t.m4
blob030611e75319d9f37c3deada2ddb74ca94ab197e
1 dnl @synopsis XAPIAN_TYPE_SOCKLEN_T
2 dnl
3 dnl Check to see what type we should pass where some systems want socklen_t.
4 dnl Note that some versions of HP-UX define socklen_t yet want int, so just
5 dnl checking if socklen_t is defined isn't good enough.
6 dnl
7 dnl Loosely based on:
8 dnl http://mail.gnome.org/archives/xml/2001-August/msg00061.html
9 dnl
10 dnl Original author: Albert Chin
11 AC_DEFUN([XAPIAN_TYPE_SOCKLEN_T],
13   AC_MSG_CHECKING([for type to use for 5th parameter to getsockopt])
14   AC_CACHE_VAL([xo_cv_socklen_t_equiv],
15   [
16     for t in socklen_t int size_t unsigned long "unsigned long"; do
17       AC_TRY_COMPILE([
18         #include <sys/types.h>
19         #if defined __WIN32__ || defined _WIN32
20         # include <winsock2.h>
21         #else
22         # include <sys/socket.h>
23         #endif
24       ],[
25         $t len;
26         getsockopt(0, 0, 0, 0, &len);
27       ],[
28         xo_cv_socklen_t_equiv="$t"
29         break
30       ])
31     done
32     if test -z "$xo_cv_socklen_t_equiv"; then
33       AC_MSG_RESULT([not found])
34       AC_MSG_ERROR([Failed to find type for 5th parameter to getsockopt])
35     fi
36   ])
37   AC_MSG_RESULT([$xo_cv_socklen_t_equiv])
38   AC_DEFINE_UNQUOTED(SOCKLEN_T, [$xo_cv_socklen_t_equiv],
39                      [type to use for 5th parameter to getsockopt])