summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Makefile.in2
-rw-r--r--aclocal.m41
-rwxr-xr-xconfigure96
-rw-r--r--configure.in1
-rw-r--r--lib/Makefile.in19
-rw-r--r--lib/gnulib.mk2
-rw-r--r--m4/gl-comp.m44
-rw-r--r--m4/socklen.m477
-rw-r--r--src/ChangeLog8
-rw-r--r--src/config.in6
-rw-r--r--src/process.c13
12 files changed, 205 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index fdde50669b5..8928b2aceeb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-03-17 Paul Eggert <eggert@cs.ucla.edu>
+
+ * Makefile.in (GNULIB_MODULES): Add socklen.
+ * configure.in: Do not check for sys/socket.h, since socklen does that.
+ * m4/socklen.m4: New automatically-generated file, from gnulib.
+
2011-03-13 Paul Eggert <eggert@cs.ucla.edu>
Update for gnulib.
diff --git a/Makefile.in b/Makefile.in
index 19267f82121..bc8ae5a9589 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -332,7 +332,7 @@ DOS_gnulib_comp.m4 = gl-comp.m4
# as per $(gnulib_srcdir)/DEPENDENCIES.
GNULIB_MODULES = \
crypto/md5 dtoastr filemode getloadavg getopt-gnu \
- ignore-value intprops lstat mktime readlink strftime symlink sys_stat
+ ignore-value intprops lstat mktime readlink socklen strftime symlink sys_stat
GNULIB_TOOL_FLAGS = \
--import --no-changelog --no-vc-files --makefile-name=gnulib.mk
sync-from-gnulib: $(gnulib_srcdir)
diff --git a/aclocal.m4 b/aclocal.m4
index 1536f3b48b5..9bd85a88bbe 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -999,6 +999,7 @@ m4_include([m4/md5.m4])
m4_include([m4/mktime.m4])
m4_include([m4/multiarch.m4])
m4_include([m4/readlink.m4])
+m4_include([m4/socklen.m4])
m4_include([m4/st_dm_mode.m4])
m4_include([m4/stat.m4])
m4_include([m4/stdbool.m4])
diff --git a/configure b/configure
index 57ecd9d52eb..e51bb0c1a57 100755
--- a/configure
+++ b/configure
@@ -2960,6 +2960,7 @@ as_fn_append ac_header_list " getopt.h"
as_fn_append ac_func_list " lstat"
as_fn_append ac_func_list " alarm"
as_fn_append ac_func_list " readlink"
+as_fn_append ac_header_list " sys/socket.h"
as_fn_append ac_header_list " wchar.h"
as_fn_append ac_header_list " stdint.h"
as_fn_append ac_func_list " tzset"
@@ -6141,6 +6142,7 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
# Code from module mktime:
# Code from module multiarch:
# Code from module readlink:
+ # Code from module socklen:
# Code from module stat:
# Code from module stdbool:
# Code from module stddef:
@@ -7966,18 +7968,6 @@ $as_echo "#define NO_MATHERR 1" >>confdefs.h
fi
-for ac_header in sys/socket.h
-do :
- ac_fn_c_check_header_mongrel "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_socket_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_SYS_SOCKET_H 1
-_ACEOF
-
-fi
-
-done
-
for ac_header in net/if.h
do :
ac_fn_c_check_header_compile "$LINENO" "net/if.h" "ac_cv_header_net_if_h" "$ac_includes_default
@@ -14784,6 +14774,24 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+
+ if test $ac_cv_header_sys_socket_h = no; then
+ for ac_header in ws2tcpip.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "ws2tcpip.h" "ac_cv_header_ws2tcpip_h" "$ac_includes_default"
+if test "x$ac_cv_header_ws2tcpip_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_WS2TCPIP_H 1
+_ACEOF
+
+fi
+
+done
+
+ fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5
$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; }
if ${ac_cv_header_stdbool_h+:} false; then :
@@ -16356,6 +16364,70 @@ $as_echo "#define READLINK_TRAILING_SLASH_BUG 1" >>confdefs.h
+ # Code from module socklen:
+ ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "
+/* <sys/types.h> is not needed according to POSIX, but the
+ <sys/socket.h> in i386-unknown-freebsd4.10 and
+ powerpc-apple-darwin5.5 required it. */
+#include <sys/types.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#elif HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+#endif
+
+"
+if test "x$ac_cv_type_socklen_t" = xyes; then :
+
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socklen_t equivalent" >&5
+$as_echo_n "checking for socklen_t equivalent... " >&6; }
+ if ${gl_cv_socklen_t_equiv+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # Systems have either "struct sockaddr *" or
+ # "void *" as the second argument to getpeername
+ gl_cv_socklen_t_equiv=
+ for arg2 in "struct sockaddr" void; do
+ for t in int size_t "unsigned int" "long int" "unsigned long int"; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/types.h>
+ #include <sys/socket.h>
+
+ int getpeername (int, $arg2 *, $t *);
+int
+main ()
+{
+$t len;
+ getpeername (0, 0, &len);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ gl_cv_socklen_t_equiv="$t"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ test "$gl_cv_socklen_t_equiv" != "" && break
+ done
+ test "$gl_cv_socklen_t_equiv" != "" && break
+ done
+
+fi
+
+ if test "$gl_cv_socklen_t_equiv" = ""; then
+ as_fn_error $? "Cannot find a type to use in place of socklen_t" "$LINENO" 5
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_socklen_t_equiv" >&5
+$as_echo "$gl_cv_socklen_t_equiv" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define socklen_t $gl_cv_socklen_t_equiv
+_ACEOF
+
+fi
+
# Code from module stat:
diff --git a/configure.in b/configure.in
index 086a7e12d67..11b7ad4db05 100644
--- a/configure.in
+++ b/configure.in
@@ -1265,7 +1265,6 @@ if test $emacs_cv_struct_exception != yes; then
AC_DEFINE(NO_MATHERR, 1, [Define to 1 if you don't have struct exception in math.h.])
fi
-AC_CHECK_HEADERS(sys/socket.h)
AC_CHECK_HEADERS(net/if.h, , , [AC_INCLUDES_DEFAULT
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 502b3dbb927..8be57520014 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -24,7 +24,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink strftime symlink sys_stat
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink socklen strftime symlink sys_stat
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
@@ -57,14 +57,15 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
$(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/longlong.m4 \
$(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/md5.m4 \
$(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/multiarch.m4 \
- $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/st_dm_mode.m4 \
- $(top_srcdir)/m4/stat.m4 $(top_srcdir)/m4/stdbool.m4 \
- $(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/stdint.m4 \
- $(top_srcdir)/m4/stdlib_h.m4 $(top_srcdir)/m4/strftime.m4 \
- $(top_srcdir)/m4/symlink.m4 $(top_srcdir)/m4/sys_stat_h.m4 \
- $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \
- $(top_srcdir)/m4/tm_gmtoff.m4 $(top_srcdir)/m4/unistd_h.m4 \
- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/configure.in
+ $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/socklen.m4 \
+ $(top_srcdir)/m4/st_dm_mode.m4 $(top_srcdir)/m4/stat.m4 \
+ $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \
+ $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdlib_h.m4 \
+ $(top_srcdir)/m4/strftime.m4 $(top_srcdir)/m4/symlink.m4 \
+ $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/time_h.m4 \
+ $(top_srcdir)/m4/time_r.m4 $(top_srcdir)/m4/tm_gmtoff.m4 \
+ $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/wchar_t.m4 \
+ $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index cd6a1d00c15..369b7a48732 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -9,7 +9,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink strftime symlink sys_stat
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink socklen strftime symlink sys_stat
MOSTLYCLEANFILES += core *.stackdump
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],
# Code from module mktime:
# Code from module multiarch:
# Code from module readlink:
+ # Code from module socklen:
# Code from module stat:
# Code from module stdbool:
# Code from module stddef:
@@ -111,6 +112,8 @@ AC_DEFUN([gl_INIT],
# Code from module readlink:
gl_FUNC_READLINK
gl_UNISTD_MODULE_INDICATOR([readlink])
+ # Code from module socklen:
+ gl_TYPE_SOCKLEN_T
# Code from module stat:
gl_FUNC_STAT
gl_SYS_STAT_MODULE_INDICATOR([stat])
@@ -327,6 +330,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/mktime.m4
m4/multiarch.m4
m4/readlink.m4
+ m4/socklen.m4
m4/st_dm_mode.m4
m4/stat.m4
m4/stdbool.m4
diff --git a/m4/socklen.m4 b/m4/socklen.m4
new file mode 100644
index 00000000000..44751544485
--- /dev/null
+++ b/m4/socklen.m4
@@ -0,0 +1,77 @@
+# socklen.m4 serial 10
+dnl Copyright (C) 2005-2007, 2009-2011 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Albert Chin, Windows fixes from Simon Josefsson.
+
+dnl Check for socklen_t: historically on BSD it is an int, and in
+dnl POSIX 1g it is a type of its own, but some platforms use different
+dnl types for the argument to getsockopt, getpeername, etc.:
+dnl HP-UX 10.20, IRIX 6.5, OSF/1 4.0, Interix 3.5, BeOS.
+dnl So we have to test to find something that will work.
+
+AC_DEFUN([gl_TYPE_SOCKLEN_T],
+ [AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])dnl
+ AC_CHECK_TYPE([socklen_t], ,
+ [AC_MSG_CHECKING([for socklen_t equivalent])
+ AC_CACHE_VAL([gl_cv_socklen_t_equiv],
+ [# Systems have either "struct sockaddr *" or
+ # "void *" as the second argument to getpeername
+ gl_cv_socklen_t_equiv=
+ for arg2 in "struct sockaddr" void; do
+ for t in int size_t "unsigned int" "long int" "unsigned long int"; do
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+ [[#include <sys/types.h>
+ #include <sys/socket.h>
+
+ int getpeername (int, $arg2 *, $t *);]],
+ [[$t len;
+ getpeername (0, 0, &len);]])],
+ [gl_cv_socklen_t_equiv="$t"])
+ test "$gl_cv_socklen_t_equiv" != "" && break
+ done
+ test "$gl_cv_socklen_t_equiv" != "" && break
+ done
+ ])
+ if test "$gl_cv_socklen_t_equiv" = ""; then
+ AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
+ fi
+ AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
+ AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
+ [type to use in place of socklen_t if not defined])],
+ [gl_SOCKET_HEADERS])])
+
+dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find
+dnl it there too. But on Cygwin, wc2tcpip.h must not be included. Users
+dnl of this module should use the same include pattern as gl_SOCKET_HEADERS.
+dnl When you change this macro, keep also in sync:
+dnl - gl_CHECK_SOCKET_HEADERS,
+dnl - the Include section of modules/socklen.
+AC_DEFUN([gl_SOCKET_HEADERS],
+[
+/* <sys/types.h> is not needed according to POSIX, but the
+ <sys/socket.h> in i386-unknown-freebsd4.10 and
+ powerpc-apple-darwin5.5 required it. */
+#include <sys/types.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#elif HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+#endif
+])
+
+dnl Tests for the existence of the header for socket facilities.
+dnl Defines the C macros HAVE_SYS_SOCKET_H, HAVE_WS2TCPIP_H.
+dnl This macro must match gl_SOCKET_HEADERS.
+AC_DEFUN([gl_CHECK_SOCKET_HEADERS],
+ [AC_CHECK_HEADERS_ONCE([sys/socket.h])
+ if test $ac_cv_header_sys_socket_h = no; then
+ dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
+ dnl the check for those headers unconditional; yet cygwin reports
+ dnl that the headers are present but cannot be compiled (since on
+ dnl cygwin, all socket information should come from sys/socket.h).
+ AC_CHECK_HEADERS([ws2tcpip.h])
+ fi
+ ])
diff --git a/src/ChangeLog b/src/ChangeLog
index 744d3ef53f0..0b2a0d44c5f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,13 @@
2011-03-20 Paul Eggert <eggert@cs.ucla.edu>
+ * process.c (Fmake_network_process): Use socklen_t, not int,
+ where POSIX says socklen_t is required in portable programs.
+ This fixes a porting bug on hosts like 64-bit HP-UX, where
+ socklen_t is wider than int (Bug#8277).
+ (Fmake_network_process, server_accept_connection):
+ (wait_reading_process_output, read_process_output):
+ Likewise.
+
* process.c: Rename or move locals to avoid shadowing.
(list_processes_1, Fmake_network_process):
(read_process_output_error_handler, exec_sentinel_error_handler):
diff --git a/src/config.in b/src/config.in
index fbd3ee9338d..b24aacd4e54 100644
--- a/src/config.in
+++ b/src/config.in
@@ -833,6 +833,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if `vfork' works. */
#undef HAVE_WORKING_VFORK
+/* Define to 1 if you have the <ws2tcpip.h> header file. */
+#undef HAVE_WS2TCPIP_H
+
/* Define to 1 if you want to use version 11 of X windows. Otherwise, Emacs
expects to use version 10. */
#undef HAVE_X11
@@ -1209,6 +1212,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
+/* type to use in place of socklen_t if not defined */
+#undef socklen_t
+
/* Define to any substitute for sys_siglist. */
#undef sys_siglist
diff --git a/src/process.c b/src/process.c
index 5ee731a5bd3..4a7202388bf 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3461,7 +3461,7 @@ usage: (make-network-process &rest ARGS) */)
if (EQ (service, Qt))
{
struct sockaddr_in sa1;
- int len1 = sizeof (sa1);
+ socklen_t len1 = sizeof (sa1);
if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0)
{
((struct sockaddr_in *)(lres->ai_addr))->sin_port = sa1.sin_port;
@@ -3508,7 +3508,8 @@ usage: (make-network-process &rest ARGS) */)
/* Unlike most other syscalls connect() cannot be called
again. (That would return EALREADY.) The proper way to
wait for completion is select(). */
- int sc, len;
+ int sc;
+ socklen_t len;
SELECT_TYPE fdset;
retry_select:
FD_ZERO (&fdset);
@@ -3581,7 +3582,7 @@ usage: (make-network-process &rest ARGS) */)
if (!is_server)
{
struct sockaddr_in sa1;
- int len1 = sizeof (sa1);
+ socklen_t len1 = sizeof (sa1);
if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0)
contact = Fplist_put (contact, QClocal,
conv_sockaddr_to_lisp ((struct sockaddr *)&sa1, len1));
@@ -4186,7 +4187,7 @@ server_accept_connection (Lisp_Object server, int channel)
struct sockaddr_un un;
#endif
} saddr;
- int len = sizeof saddr;
+ socklen_t len = sizeof saddr;
s = accept (channel, &saddr.sa, &len);
@@ -5051,7 +5052,7 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
/* getsockopt(,,SO_ERROR,,) is said to hang on some systems.
So only use it on systems where it is known to work. */
{
- int xlen = sizeof (xerrno);
+ socklen_t xlen = sizeof (xerrno);
if (getsockopt (channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen))
xerrno = errno;
}
@@ -5163,7 +5164,7 @@ read_process_output (Lisp_Object proc, register int channel)
/* We have a working select, so proc_buffered_char is always -1. */
if (DATAGRAM_CHAN_P (channel))
{
- int len = datagram_address[channel].len;
+ socklen_t len = datagram_address[channel].len;
nbytes = recvfrom (channel, chars + carryover, readmax,
0, datagram_address[channel].sa, &len);
}