aboutsummaryrefslogtreecommitdiffstats
path: root/m4
diff options
context:
space:
mode:
authorPaul Eggert2011-03-17 20:30:24 -0700
committerPaul Eggert2011-03-17 20:30:24 -0700
commit401bf9b4708c19d3c86c888ce482014ca559a5b8 (patch)
treed69e75d88c70f4c5d3da2501b4afec51cf51d563 /m4
parenta3a6c54ec72118e8d22d2ecd608df5193c8926a3 (diff)
downloademacs-401bf9b4708c19d3c86c888ce482014ca559a5b8.tar.gz
emacs-401bf9b4708c19d3c86c888ce482014ca559a5b8.zip
process.c: Use socklen_t, not int, for socket lengths.
Diffstat (limited to 'm4')
-rw-r--r--m4/gl-comp.m44
-rw-r--r--m4/socklen.m465
2 files changed, 69 insertions, 0 deletions
diff --git a/m4/gl-comp.m4 b/m4/gl-comp.m4
index 8bf5a64a5f9..7f8b5a79070 100644
--- a/m4/gl-comp.m4
+++ b/m4/gl-comp.m4
@@ -45,6 +45,7 @@ AC_DEFUN([gl_EARLY],
45 # Code from module mktime: 45 # Code from module mktime:
46 # Code from module multiarch: 46 # Code from module multiarch:
47 # Code from module readlink: 47 # Code from module readlink:
48 # Code from module socklen:
48 # Code from module stat: 49 # Code from module stat:
49 # Code from module stdbool: 50 # Code from module stdbool:
50 # Code from module stddef: 51 # Code from module stddef:
@@ -111,6 +112,8 @@ AC_DEFUN([gl_INIT],
111 # Code from module readlink: 112 # Code from module readlink:
112 gl_FUNC_READLINK 113 gl_FUNC_READLINK
113 gl_UNISTD_MODULE_INDICATOR([readlink]) 114 gl_UNISTD_MODULE_INDICATOR([readlink])
115 # Code from module socklen:
116 gl_TYPE_SOCKLEN_T
114 # Code from module stat: 117 # Code from module stat:
115 gl_FUNC_STAT 118 gl_FUNC_STAT
116 gl_SYS_STAT_MODULE_INDICATOR([stat]) 119 gl_SYS_STAT_MODULE_INDICATOR([stat])
@@ -327,6 +330,7 @@ AC_DEFUN([gl_FILE_LIST], [
327 m4/mktime.m4 330 m4/mktime.m4
328 m4/multiarch.m4 331 m4/multiarch.m4
329 m4/readlink.m4 332 m4/readlink.m4
333 m4/socklen.m4
330 m4/st_dm_mode.m4 334 m4/st_dm_mode.m4
331 m4/stat.m4 335 m4/stat.m4
332 m4/stdbool.m4 336 m4/stdbool.m4
diff --git a/m4/socklen.m4 b/m4/socklen.m4
new file mode 100644
index 00000000000..28dcf070463
--- /dev/null
+++ b/m4/socklen.m4
@@ -0,0 +1,65 @@
1# socklen.m4 serial 9
2dnl Copyright (C) 2005-2007, 2009-2011 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Albert Chin, Windows fixes from Simon Josefsson.
8
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
11dnl types for the argument to getsockopt, getpeername, etc.:
12dnl HP-UX 10.20, IRIX 6.5, Interix 3.5, BeOS.
13dnl So we have to test to find something that will work.
14
15dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find
16dnl it there first. That file is included by gnulib's sys_socket.in.h, which
17dnl all users of this module should include if they want to be portable to
18dnl mingw32. Cygwin must not include ws2tcpip.h.
19AC_DEFUN([gl_TYPE_SOCKLEN_T],
20 [AC_REQUIRE([gl_PREREQ_TYPE_SOCKLEN_T])dnl
21 AC_CHECK_TYPE([socklen_t], ,
22 [AC_MSG_CHECKING([for socklen_t equivalent])
23 AC_CACHE_VAL([gl_cv_socklen_t_equiv],
24 [# Systems have either "struct sockaddr *" or
25 # "void *" as the second argument to getpeername
26 gl_cv_socklen_t_equiv=
27 for arg2 in "struct sockaddr" void; do
28 for t in int size_t "unsigned int" "long int" "unsigned long int"; do
29 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
30 [[#include <sys/types.h>
31 #include <sys/socket.h>
32
33 int getpeername (int, $arg2 *, $t *);]],
34 [[$t len;
35 getpeername (0, 0, &len);]])],
36 [gl_cv_socklen_t_equiv="$t"])
37 test "$gl_cv_socklen_t_equiv" != "" && break
38 done
39 test "$gl_cv_socklen_t_equiv" != "" && break
40 done
41 ])
42 if test "$gl_cv_socklen_t_equiv" = ""; then
43 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
44 fi
45 AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
46 AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
47 [type to use in place of socklen_t if not defined])],
48 [#include <sys/types.h>
49 #if HAVE_SYS_SOCKET_H
50 # include <sys/socket.h>
51 ]m4_ifdef([gl_SYS_SOCKET_H_DEFAULTS],
52 [#elif HAVE_WS2TCPIP_H
53 # include <ws2tcpip.h>]
54 )[#endif])])
55
56AC_DEFUN([gl_PREREQ_TYPE_SOCKLEN_T],
57 [AC_CHECK_HEADERS_ONCE([sys/socket.h])
58 m4_ifdef([gl_SYS_SOCKET_H_DEFAULTS],
59 [if test $ac_cv_header_sys_socket_h = no; then
60 dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
61 dnl the check for those headers unconditional; yet cygwin reports
62 dnl that the headers are present but cannot be compiled (since on
63 dnl cygwin, all socket information should come from sys/socket.h).
64 AC_CHECK_HEADERS([ws2tcpip.h])
65 fi])])