summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2011-04-21 08:51:12 -0600
committerEric Blake <eblake@redhat.com>2011-04-21 10:43:09 -0600
commit753425d56eedab92c361cae9d6baa701d893fbc9 (patch)
treed7934c92274da17e85477212387ef07cb7e50be1
parent67ce653056298965788199437efe1e0f6c06eec5 (diff)
downloadgnulib-753425d56eedab92c361cae9d6baa701d893fbc9.tar.gz
sys_uio: new module
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>
-rw-r--r--ChangeLog11
-rwxr-xr-xMODULES.html.sh1
-rw-r--r--doc/posix-headers/sys_uio.texi8
-rw-r--r--lib/sys_uio.in.h49
-rw-r--r--m4/sys_uio_h.m431
-rw-r--r--modules/sys_uio42
-rw-r--r--modules/sys_uio-tests10
-rw-r--r--tests/test-sys_uio.c32
8 files changed, 180 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 5081b45943..4f8321a1e7 100644
--- 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
diff --git a/MODULES.html.sh b/MODULES.html.sh
index 708f3cccfc..8d32a21258 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -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
diff --git a/doc/posix-headers/sys_uio.texi b/doc/posix-headers/sys_uio.texi
index 44282f22f6..bc4825400d 100644
--- a/doc/posix-headers/sys_uio.texi
+++ b/doc/posix-headers/sys_uio.texi
@@ -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
index 0000000000..175ee0fb6d
--- /dev/null
+++ b/lib/sys_uio.in.h
@@ -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
index 0000000000..bafa0ac457
--- /dev/null
+++ b/m4/sys_uio_h.m4
@@ -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
index 0000000000..2152718cca
--- /dev/null
+++ b/modules/sys_uio
@@ -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
index 0000000000..0258579530
--- /dev/null
+++ b/modules/sys_uio-tests
@@ -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
index 0000000000..7855a6bc43
--- /dev/null
+++ b/tests/test-sys_uio.c
@@ -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;
+}