sys_uio: new module
authorEric Blake <eblake@redhat.com>
Thu, 21 Apr 2011 14:51:12 +0000 (08:51 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 21 Apr 2011 16:43:09 +0000 (10:43 -0600)
For now, just provide the types used by sys/socket.  We could
add readv() and writev() later, if desired.

* modules/sys_uio: New module.
* modules/sys_uio-tests: Likewise.
* lib/sys_uio.in.h: New file.
* m4/sys_uio_h.m4: Likewise.
* tests/test-sys_uio.c: Likewise.
* doc/posix-headers/sys_uio.texi (sys/uio.h): Document it.
* MODULES.html.sh (systems lacking POSIX:2008): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
MODULES.html.sh
doc/posix-headers/sys_uio.texi
lib/sys_uio.in.h [new file with mode: 0644]
m4/sys_uio_h.m4 [new file with mode: 0644]
modules/sys_uio [new file with mode: 0644]
modules/sys_uio-tests [new file with mode: 0644]
tests/test-sys_uio.c [new file with mode: 0644]

index 5081b459432989a257949881ff50b66de6bfceb4..4f8321a1e77e81b4f68bc39e4b0c6ae3b3589108 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-04-21  Eric Blake  <eblake@redhat.com>
+
+       sys_uio: new module
+       * modules/sys_uio: New module.
+       * modules/sys_uio-tests: Likewise.
+       * lib/sys_uio.in.h: New file.
+       * m4/sys_uio_h.m4: Likewise.
+       * tests/test-sys_uio.c: Likewise.
+       * doc/posix-headers/sys_uio.texi (sys/uio.h): Document it.
+       * MODULES.html.sh (systems lacking POSIX:2008): Likewise.
+
 2011-04-20  Jim Meyering  <meyering@redhat.com>
 
        useless-if-before-free: avoid false-positive
index 708f3cccfcbce314ccd728116551d11d6fd4a20e..8d32a212588ad8718087b77fd6529c0c114cb8a4 100755 (executable)
@@ -2464,6 +2464,7 @@ func_all_modules ()
   func_module sys_stat
   func_module sys_time
   func_module sys_times
+  func_module sys_uio
   func_module sys_utsname
   func_module sys_wait
   func_module tsearch
index 44282f22f6c1ec8c3de6abe111e147e6be1c95a2..bc4825400dffac26e846196f66d752070f24bc25 100644 (file)
@@ -3,15 +3,15 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/basedefs/sys_uio.h.html}
 
-Gnulib module: ---
+Gnulib module: sys_uio
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This header file is missing on some platforms:
+mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This header file is missing on some platforms:
-mingw.
 @end itemize
diff --git a/lib/sys_uio.in.h b/lib/sys_uio.in.h
new file mode 100644 (file)
index 0000000..175ee0f
--- /dev/null
@@ -0,0 +1,49 @@
+/* Substitute for <sys/uio.h>.
+   Copyright (C) 2011 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
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+# if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+# endif
+@PRAGMA_COLUMNS@
+
+#ifndef _GL_SYS_UIO_H
+
+#if @HAVE_SYS_UIO_H@
+
+/* The include_next requires a split double-inclusion guard.  */
+# @INCLUDE_NEXT@ @NEXT_SYS_UIO_H@
+
+#endif
+
+#ifndef _GL_SYS_UIO_H
+#define _GL_SYS_UIO_H
+
+#if !@HAVE_SYS_UIO_H@
+/* A platform that lacks <sys/uio.h>.  */
+/* Get 'ssize_t'.  */
+# include <sys/types.h>
+
+/* All known platforms that lack <sys/uio.h> also lack any declaration
+   of struct iovec in any other header.  */
+struct iovec {
+  void *iov_base;
+  size_t iov_len;
+};
+#endif
+
+#endif /* _GL_SYS_UIO_H */
+#endif /* _GL_SYS_UIO_H */
diff --git a/m4/sys_uio_h.m4 b/m4/sys_uio_h.m4
new file mode 100644 (file)
index 0000000..bafa0ac
--- /dev/null
@@ -0,0 +1,31 @@
+# sys_uio_h.m4 serial 1
+dnl Copyright (C) 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.
+
+AC_DEFUN([gl_HEADER_SYS_UIO],
+[
+  AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS])
+  dnl <sys/uio.h> is always overridden, because of GNULIB_POSIXCHECK.
+  gl_CHECK_NEXT_HEADERS([sys/uio.h])
+  if test $ac_cv_header_sys_uio_h = yes; then
+    HAVE_SYS_UIO_H=1
+  else
+    HAVE_SYS_UIO_H=0
+  fi
+  AC_SUBST([HAVE_SYS_UIO_H])
+])
+
+AC_DEFUN([gl_SYS_UIO_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS])
+  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+  dnl Define it also as a C macro, for the benefit of the unit tests.
+  gl_MODULE_INDICATOR_FOR_TESTS([$1])
+])
+
+AC_DEFUN([gl_SYS_UIO_H_DEFAULTS],
+[
+])
diff --git a/modules/sys_uio b/modules/sys_uio
new file mode 100644 (file)
index 0000000..2152718
--- /dev/null
@@ -0,0 +1,42 @@
+Description:
+A POSIX-like <sys/uio.h>.
+
+Files:
+lib/sys_uio.in.h
+m4/sys_uio_h.m4
+
+Depends-on:
+include_next
+
+configure.ac:
+gl_HEADER_SYS_UIO
+AC_PROG_MKDIR_P
+
+Makefile.am:
+BUILT_SOURCES += sys/uio.h
+
+# We need the following in order to create <sys/uio.h> when the system
+# doesn't have one that works with the given compiler.
+sys/uio.h: sys_uio.in.h $(top_builddir)/config.status
+       $(AM_V_at)$(MKDIR_P) sys
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_SYS_UIO_H''@|$(NEXT_SYS_UIO_H)|g' \
+             -e 's|@''HAVE_SYS_UIO_H''@|$(HAVE_SYS_UIO_H)|g' \
+             < $(srcdir)/sys_uio.in.h; \
+       } > $@-t && \
+       mv -f $@-t $@
+MOSTLYCLEANFILES += sys/uio.h sys/uio.h-t
+MOSTLYCLEANDIRS += sys
+
+Include:
+<sys/uio.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Eric Blake
diff --git a/modules/sys_uio-tests b/modules/sys_uio-tests
new file mode 100644 (file)
index 0000000..0258579
--- /dev/null
@@ -0,0 +1,10 @@
+Files:
+tests/test-sys_uio.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-sys_uio
+check_PROGRAMS += test-sys_uio
diff --git a/tests/test-sys_uio.c b/tests/test-sys_uio.c
new file mode 100644 (file)
index 0000000..7855a6b
--- /dev/null
@@ -0,0 +1,32 @@
+/* Test of <sys/uio.h> substitute.
+   Copyright (C) 2011 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
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Eric Blake <eblake@redhat.com>, 2011.  */
+
+#include <config.h>
+
+#include <sys/uio.h>
+
+/* Check that necessary types are defined.  */
+size_t a;
+ssize_t b;
+struct iovec c;
+
+int
+main (void)
+{
+  return a + b + !!c.iov_base + c.iov_len;
+}