bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/3] sys_uio: new module


From: Eric Blake
Subject: [PATCH 1/3] sys_uio: new module
Date: Thu, 21 Apr 2011 14:26:45 -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 <address@hidden>
---
 ChangeLog                      |   11 +++++++++
 MODULES.html.sh                |    1 +
 doc/posix-headers/sys_uio.texi |    8 +++---
 lib/sys_uio.in.h               |   49 ++++++++++++++++++++++++++++++++++++++++
 m4/sys_uio_h.m4                |   31 +++++++++++++++++++++++++
 modules/sys_uio                |   42 ++++++++++++++++++++++++++++++++++
 modules/sys_uio-tests          |   10 ++++++++
 tests/test-sys_uio.c           |   32 ++++++++++++++++++++++++++
 8 files changed, 180 insertions(+), 4 deletions(-)
 create mode 100644 lib/sys_uio.in.h
 create mode 100644 m4/sys_uio_h.m4
 create mode 100644 modules/sys_uio
 create mode 100644 modules/sys_uio-tests
 create mode 100644 tests/test-sys_uio.c

diff --git a/ChangeLog b/ChangeLog
index 5081b45..4f8321a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-04-21  Eric Blake  <address@hidden>
+
+       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  <address@hidden>

        useless-if-before-free: avoid false-positive
diff --git a/MODULES.html.sh b/MODULES.html.sh
index 708f3cc..8d32a21 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 44282f2..bc48254 100644
--- a/doc/posix-headers/sys_uio.texi
+++ b/doc/posix-headers/sys_uio.texi
@@ -3,15 +3,15 @@ sys/uio.h

 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
address@hidden
+This header file is missing on some platforms:
+mingw.
 @end itemize

 Portability problems not fixed by Gnulib:
 @itemize
address@hidden
-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 0000000..175ee0f
--- /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
address@hidden@
+# endif
address@hidden@
+
+#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 address@hidden@
+/* 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 0000000..bafa0ac
--- /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 0000000..2152718
--- /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 address@hidden $@ && \
+       { 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; \
+       } > address@hidden && \
+       mv -f address@hidden $@
+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 0000000..0258579
--- /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 0000000..7855a6b
--- /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 <address@hidden>, 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;
+}
-- 
1.7.4.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]