From 95bbafdb715dcfdbe7f629e2411b300ccaa84db4 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sat, 30 Apr 2011 13:38:43 +0200
Subject: [PATCH] sys_socket: Ensure 'struct iovec' definition.

* lib/sys_socket.in.h: Include <sys/uio.h> also on platforms that have
<sys/socket.h>.
* doc/posix-headers/sys_socket.texi: Mention the OpenBSD problem.
---
 ChangeLog                         | 7 +++++++
 doc/posix-headers/sys_socket.texi | 3 +++
 lib/sys_socket.in.h               | 9 ++++++---
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b567940fb7..987b46e681 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-04-30  Bruno Haible  <bruno@clisp.org>
+
+	sys_socket: Ensure 'struct iovec' definition.
+	* lib/sys_socket.in.h: Include <sys/uio.h> also on platforms that have
+	<sys/socket.h>.
+	* doc/posix-headers/sys_socket.texi: Mention the OpenBSD problem.
+
 2011-04-30  Bruno Haible  <bruno@clisp.org>
 
 	sys_uio: Protect definition of 'struct iovec'.
diff --git a/doc/posix-headers/sys_socket.texi b/doc/posix-headers/sys_socket.texi
index f80e542544..72fd688705 100644
--- a/doc/posix-headers/sys_socket.texi
+++ b/doc/posix-headers/sys_socket.texi
@@ -17,6 +17,9 @@ This header file is not self-contained on some platforms: it requires
 This header file does not define the type @code{socklen_t} on some platforms:
 HP-UX 10.20, IRIX 6.5, OSF/1 4.0, Interix 3.5, BeOS.
 @item
+This header file does not define the type @code{struct iovec} on some platforms:
+OpenBSD 4.4.
+@item
 This header file is lacking the @code{SHUT_RD}, @code{SHUT_WR},
 @code{SHUT_RDWR} macros on some platforms, despite having the @code{shutdown}
 functions:
diff --git a/lib/sys_socket.in.h b/lib/sys_socket.in.h
index f9e368b6ca..78026697bd 100644
--- a/lib/sys_socket.in.h
+++ b/lib/sys_socket.in.h
@@ -108,6 +108,12 @@ struct sockaddr_storage
 
 #endif
 
+/* Get struct iovec.  */
+/* But avoid namespace pollution on glibc systems.  */
+#if ! defined __GLIBC__
+# include <sys/uio.h>
+#endif
+
 #if @HAVE_SYS_SOCKET_H@
 
 /* A platform that has <sys/socket.h>.  */
@@ -176,9 +182,6 @@ typedef int socklen_t;
 
 # endif
 
-/* For struct iovec */
-# include <sys/uio.h>
-
 /* Rudimentary 'struct msghdr'; this works as long as you don't try to
    access msg_control or msg_controllen.  */
 struct msghdr {
-- 
2.30.2