[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] socklen: do not depend on sys_socket
From: |
Paul Eggert |
Subject: |
[PATCH] socklen: do not depend on sys_socket |
Date: |
Thu, 17 Mar 2011 19:09:42 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 |
Here's another Emacs-related patch I'm proposing for gnulib
to break an unnecessary dependency, in this case a circular one.
----
While trying to modify Emacs to use gnulib's socklen module,
I discovered a circular dependency: socklen depends on sys_socket
and vice versa. Emacs can use socklen, but it does not need
sys_socket because Emacs is not intended to be portable to
MingW and Cygwin.
* m4/socklen.m4 (gl_PREREQ_TYPE_SOCKLEN_T): New macro, taken from
parts of gl_PREREQ_SYS_H_SOCKET.
(gl_TYPE_SOCKLEN_T): Require it instead of requiring
gl_PREREQ_SYS_H_SOCKET. Check for ws2tcpip.h only if
sys_socket is also used.
* m4/sys_socket_h.m4 (gl_PREREQ_SYS_H_SOCKET): Require
gl_PREREQ_TYPE_SOCKLEN_T instead of doing its work ourselves.
* modules/inet_ntop (Depends-on): Remove socklen, since
sys_socket is supposed to provide socklen_t and we already
depend on sys_socket.
* modules/inet_pton, modules/netdb: Likewise.
* modules/socklen: Do not depend on sys_socket.
---
ChangeLog | 21 +++++++++++++++++++++
m4/socklen.m4 | 26 +++++++++++++++++++-------
m4/sys_socket_h.m4 | 9 ++-------
modules/inet_ntop | 1 -
modules/inet_pton | 1 -
modules/netdb | 1 -
modules/socklen | 1 -
7 files changed, 42 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 917e834..199db7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2011-03-16 Paul Eggert <address@hidden>
+
+ socklen: do not depend on sys_socket
+ While trying to modify Emacs to use gnulib's socklen module,
+ I discovered a circular dependency: socklen depends on sys_socket
+ and vice versa. Emacs can use socklen, but it does not need
+ sys_socket because Emacs is not intended to be portable to
+ MingW and Cygwin.
+ * m4/socklen.m4 (gl_PREREQ_TYPE_SOCKLEN_T): New macro, taken from
+ parts of gl_PREREQ_SYS_H_SOCKET.
+ (gl_TYPE_SOCKLEN_T): Require it instead of requiring
+ gl_PREREQ_SYS_H_SOCKET. Check for ws2tcpip.h only if
+ sys_socket is also used.
+ * m4/sys_socket_h.m4 (gl_PREREQ_SYS_H_SOCKET): Require
+ gl_PREREQ_TYPE_SOCKLEN_T instead of doing its work ourselves.
+ * modules/inet_ntop (Depends-on): Remove socklen, since
+ sys_socket is supposed to provide socklen_t and we already
+ depend on sys_socket.
+ * modules/inet_pton, modules/netdb: Likewise.
+ * modules/socklen: Do not depend on sys_socket.
+
2011-03-16 Jim Meyering <address@hidden>
maint.mk: allow fine-grained syntax-check exclusion via Make variables
diff --git a/m4/socklen.m4 b/m4/socklen.m4
index 5e4c69e..28dcf07 100644
--- a/m4/socklen.m4
+++ b/m4/socklen.m4
@@ -1,4 +1,4 @@
-# socklen.m4 serial 8
+# socklen.m4 serial 9
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,
@@ -14,10 +14,10 @@ dnl So we have to test to find something that will work.
dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find
dnl it there first. That file is included by gnulib's sys_socket.in.h, which
-dnl all users of this module should include. Cygwin must not include
-dnl ws2tcpip.h.
+dnl all users of this module should include if they want to be portable to
+dnl mingw32. Cygwin must not include ws2tcpip.h.
AC_DEFUN([gl_TYPE_SOCKLEN_T],
- [AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl
+ [AC_REQUIRE([gl_PREREQ_TYPE_SOCKLEN_T])dnl
AC_CHECK_TYPE([socklen_t], ,
[AC_MSG_CHECKING([for socklen_t equivalent])
AC_CACHE_VAL([gl_cv_socklen_t_equiv],
@@ -48,6 +48,18 @@ AC_DEFUN([gl_TYPE_SOCKLEN_T],
[#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
- #elif HAVE_WS2TCPIP_H
- # include <ws2tcpip.h>
- #endif])])
+ ]m4_ifdef([gl_SYS_SOCKET_H_DEFAULTS],
+ [#elif HAVE_WS2TCPIP_H
+ # include <ws2tcpip.h>]
+ )[#endif])])
+
+AC_DEFUN([gl_PREREQ_TYPE_SOCKLEN_T],
+ [AC_CHECK_HEADERS_ONCE([sys/socket.h])
+ m4_ifdef([gl_SYS_SOCKET_H_DEFAULTS],
+ [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/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4
index 12dc05d..0ba6109 100644
--- a/m4/sys_socket_h.m4
+++ b/m4/sys_socket_h.m4
@@ -1,4 +1,4 @@
-# sys_socket_h.m4 serial 21
+# sys_socket_h.m4 serial 22
dnl Copyright (C) 2005-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,
@@ -101,17 +101,12 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
AC_DEFUN([gl_PREREQ_SYS_H_SOCKET],
[
dnl Check prerequisites of the <sys/socket.h> replacement.
- gl_CHECK_NEXT_HEADERS([sys/socket.h])
+ AC_REQUIRE([gl_PREREQ_TYPE_SOCKLEN_T])
if test $ac_cv_header_sys_socket_h = yes; then
HAVE_SYS_SOCKET_H=1
HAVE_WS2TCPIP_H=0
else
HAVE_SYS_SOCKET_H=0
- 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])
if test $ac_cv_header_ws2tcpip_h = yes; then
HAVE_WS2TCPIP_H=1
else
diff --git a/modules/inet_ntop b/modules/inet_ntop
index c6a1b80..3b00b62 100644
--- a/modules/inet_ntop
+++ b/modules/inet_ntop
@@ -6,7 +6,6 @@ lib/inet_ntop.c
m4/inet_ntop.m4
Depends-on:
-socklen
sys_socket
arpa_inet
errno
diff --git a/modules/inet_pton b/modules/inet_pton
index 271d778..44c50b8 100644
--- a/modules/inet_pton
+++ b/modules/inet_pton
@@ -7,7 +7,6 @@ m4/inet_pton.m4
Depends-on:
c-ctype
-socklen
sys_socket
arpa_inet
errno
diff --git a/modules/netdb b/modules/netdb
index ea7dc63..9b95a6e 100644
--- a/modules/netdb
+++ b/modules/netdb
@@ -10,7 +10,6 @@ include_next
arg-nonnull
warn-on-use
sys_socket
-socklen
configure.ac:
gl_HEADER_NETDB
diff --git a/modules/socklen b/modules/socklen
index 4986f10..bc1236f 100644
--- a/modules/socklen
+++ b/modules/socklen
@@ -5,7 +5,6 @@ Files:
m4/socklen.m4
Depends-on:
-sys_socket
configure.ac:
gl_TYPE_SOCKLEN_T
--
1.7.4
- [PATCH] socklen: do not depend on sys_socket,
Paul Eggert <=