summaryrefslogtreecommitdiffstats
path: root/gl/m4/socklen.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/socklen.m4')
-rw-r--r--gl/m4/socklen.m455
1 files changed, 40 insertions, 15 deletions
diff --git a/gl/m4/socklen.m4 b/gl/m4/socklen.m4
index 2933d4b..e3efd6e 100644
--- a/gl/m4/socklen.m4
+++ b/gl/m4/socklen.m4
@@ -1,5 +1,5 @@
1# socklen.m4 serial 7 1# socklen.m4 serial 10
2dnl Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2007, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,15 +8,12 @@ dnl From Albert Chin, Windows fixes from Simon Josefsson.
8 8
9dnl Check for socklen_t: historically on BSD it is an int, and in 9dnl Check for socklen_t: historically on BSD it is an int, and in
10dnl POSIX 1g it is a type of its own, but some platforms use different 10dnl POSIX 1g it is a type of its own, but some platforms use different
11dnl types for the argument to getsockopt, getpeername, etc. So we 11dnl types for the argument to getsockopt, getpeername, etc.:
12dnl have to test to find something that will work. 12dnl HP-UX 10.20, IRIX 6.5, OSF/1 4.0, Interix 3.5, BeOS.
13dnl So we have to test to find something that will work.
13 14
14dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find
15dnl it there first. That file is included by gnulib's sys_socket.in.h, which
16dnl all users of this module should include. Cygwin must not include
17dnl ws2tcpip.h.
18AC_DEFUN([gl_TYPE_SOCKLEN_T], 15AC_DEFUN([gl_TYPE_SOCKLEN_T],
19 [AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl 16 [AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])dnl
20 AC_CHECK_TYPE([socklen_t], , 17 AC_CHECK_TYPE([socklen_t], ,
21 [AC_MSG_CHECKING([for socklen_t equivalent]) 18 [AC_MSG_CHECKING([for socklen_t equivalent])
22 AC_CACHE_VAL([gl_cv_socklen_t_equiv], 19 AC_CACHE_VAL([gl_cv_socklen_t_equiv],
@@ -44,9 +41,37 @@ AC_DEFUN([gl_TYPE_SOCKLEN_T],
44 AC_MSG_RESULT([$gl_cv_socklen_t_equiv]) 41 AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
45 AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv], 42 AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
46 [type to use in place of socklen_t if not defined])], 43 [type to use in place of socklen_t if not defined])],
47 [#include <sys/types.h> 44 [gl_SOCKET_HEADERS])])
48 #if HAVE_SYS_SOCKET_H 45
49 # include <sys/socket.h> 46dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find
50 #elif HAVE_WS2TCPIP_H 47dnl it there too. But on Cygwin, wc2tcpip.h must not be included. Users
51 # include <ws2tcpip.h> 48dnl of this module should use the same include pattern as gl_SOCKET_HEADERS.
52 #endif])]) 49dnl When you change this macro, keep also in sync:
50dnl - gl_CHECK_SOCKET_HEADERS,
51dnl - the Include section of modules/socklen.
52AC_DEFUN([gl_SOCKET_HEADERS],
53[
54/* <sys/types.h> is not needed according to POSIX, but the
55 <sys/socket.h> in i386-unknown-freebsd4.10 and
56 powerpc-apple-darwin5.5 required it. */
57#include <sys/types.h>
58#if HAVE_SYS_SOCKET_H
59# include <sys/socket.h>
60#elif HAVE_WS2TCPIP_H
61# include <ws2tcpip.h>
62#endif
63])
64
65dnl Tests for the existence of the header for socket facilities.
66dnl Defines the C macros HAVE_SYS_SOCKET_H, HAVE_WS2TCPIP_H.
67dnl This macro must match gl_SOCKET_HEADERS.
68AC_DEFUN([gl_CHECK_SOCKET_HEADERS],
69 [AC_CHECK_HEADERS_ONCE([sys/socket.h])
70 if test $ac_cv_header_sys_socket_h = no; then
71 dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
72 dnl the check for those headers unconditional; yet cygwin reports
73 dnl that the headers are present but cannot be compiled (since on
74 dnl cygwin, all socket information should come from sys/socket.h).
75 AC_CHECK_HEADERS([ws2tcpip.h])
76 fi
77 ])