From ebf441cb8883407196255114d8e81abbb8f1efeb Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sat, 28 Aug 2010 10:16:34 +0200
Subject: [PATCH] sys_socket, netdb: Ensure socklen_t gets defined.

---
 ChangeLog               | 13 +++++++++++++
 m4/socklen.m4           |  7 ++++---
 modules/getaddrinfo     |  1 -
 modules/getsockopt      |  1 -
 modules/netdb           |  1 +
 modules/setsockopt      |  1 -
 modules/sys_socket      |  1 +
 tests/test-netdb.c      |  5 ++++-
 tests/test-sys_socket.c |  5 ++++-
 9 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c866e5010d..35e3989f50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2010-08-28  Bruno Haible  <bruno@clisp.org>
+
+	sys_socket, netdb: Ensure socklen_t gets defined.
+	* modules/sys_socket (Depends-on): Add socklen.
+	* modules/netdb (Depends-on): Likewise.
+	* modules/getaddrinfo (Depends-on): Remove socklen.
+	* modules/getsockopt (Depends-on): Likewise.
+	* modules/setsockopt (Depends-on): Likewise.
+	* tests/test-sys_socket.c: Check that socklen_t is defined.
+	* tests/test-netdb.c: Likewise.
+	* m4/socklen.m4: Update comments.
+	Reported by Ralf Wildenhues <Ralf.Wildenhues@gmx.de>.
+
 2010-08-27  Eric Blake  <eblake@redhat.com>
 
 	login_tty: add missing dependency
diff --git a/m4/socklen.m4 b/m4/socklen.m4
index 2933d4b890..d0d6baab55 100644
--- a/m4/socklen.m4
+++ b/m4/socklen.m4
@@ -1,4 +1,4 @@
-# socklen.m4 serial 7
+# socklen.m4 serial 8
 dnl Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,8 +8,9 @@ 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.  So we
-dnl have to test to find something that will work.
+dnl types for the argument to getsockopt, getpeername, etc.:
+dnl HP-UX 10.20, IRIX 6.5, Interix 3.5, BeOS.
+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
diff --git a/modules/getaddrinfo b/modules/getaddrinfo
index c8c602449b..f51365223d 100644
--- a/modules/getaddrinfo
+++ b/modules/getaddrinfo
@@ -11,7 +11,6 @@ extensions
 gettext-h
 inet_ntop
 snprintf
-socklen
 stdbool
 sys_socket
 netdb
diff --git a/modules/getsockopt b/modules/getsockopt
index 85b04c0427..40ff649817 100644
--- a/modules/getsockopt
+++ b/modules/getsockopt
@@ -8,7 +8,6 @@ lib/w32sock.h
 Depends-on:
 sys_socket
 sys_time
-socklen
 errno
 
 configure.ac:
diff --git a/modules/netdb b/modules/netdb
index dbdfc8cfc9..b35fda174e 100644
--- a/modules/netdb
+++ b/modules/netdb
@@ -10,6 +10,7 @@ include_next
 arg-nonnull
 warn-on-use
 sys_socket
+socklen
 
 configure.ac:
 gl_HEADER_NETDB
diff --git a/modules/setsockopt b/modules/setsockopt
index 5702aaeb69..b429510a01 100644
--- a/modules/setsockopt
+++ b/modules/setsockopt
@@ -8,7 +8,6 @@ lib/w32sock.h
 Depends-on:
 sys_socket
 sys_time
-socklen
 errno
 
 configure.ac:
diff --git a/modules/sys_socket b/modules/sys_socket
index 8c4735232f..08c90b2a44 100644
--- a/modules/sys_socket
+++ b/modules/sys_socket
@@ -12,6 +12,7 @@ arg-nonnull
 c++defs
 errno
 include_next
+socklen
 warn-on-use
 
 configure.ac:
diff --git a/tests/test-netdb.c b/tests/test-netdb.c
index 5f2bcd4e52..697bbc8dbf 100644
--- a/tests/test-netdb.c
+++ b/tests/test-netdb.c
@@ -1,5 +1,5 @@
 /* Test of <netdb.h> substitute.
-   Copyright (C) 2007-2010 Free Software Foundation, Inc.
+   Copyright (C) 2007-2008, 2010 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -22,6 +22,9 @@
 /* Check that the 'struct hostent' type is defined.  */
 struct hostent t1;
 
+/* Check that the 'socklen_t' type is defined.  */
+socklen_t t2;
+
 int
 main (void)
 {
diff --git a/tests/test-sys_socket.c b/tests/test-sys_socket.c
index 1c3b5607cd..e976ff6a7b 100644
--- a/tests/test-sys_socket.c
+++ b/tests/test-sys_socket.c
@@ -1,5 +1,5 @@
 /* Test of <sys/socket.h> substitute.
-   Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -27,6 +27,9 @@
 int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR };
 #endif
 
+/* Check that the 'socklen_t' type is defined.  */
+socklen_t t1;
+
 int
 main (void)
 {
-- 
2.30.2