Mercurial > hg > octave-nkf > gnulib-hg
changeset 14086:b3fb554bb012
pwrite: Fix test whether it works and make it work on HP-UX 11.11.
* m4/pwrite.m4 (gl_FUNC_PWRITE): Use AC_LANG_PROGRAM, not
AC_LANG_SOURCE. Extend the test program to catch another HP-UX 11.11
bug.
* lib/pwrite.c: Undo 2010-12-31 patch.
* doc/posix-functions/pwrite.texi: Document another HP-UX 11.11 bug.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 02 Jan 2011 18:40:29 +0100 |
parents | 64c43f976cf4 |
children | 5400154288e5 |
files | ChangeLog doc/posix-functions/pwrite.texi lib/pwrite.c m4/pwrite.m4 |
diffstat | 4 files changed, 57 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-01-02 Bruno Haible <bruno@clisp.org> + + pwrite: Fix test whether it works and make it work on HP-UX 11.11. + * m4/pwrite.m4 (gl_FUNC_PWRITE): Use AC_LANG_PROGRAM, not + AC_LANG_SOURCE. Extend the test program to catch another HP-UX 11.11 + bug. + * lib/pwrite.c: Undo 2010-12-31 patch. + * doc/posix-functions/pwrite.texi: Document another HP-UX 11.11 bug. + 2011-01-02 Bruno Haible <bruno@clisp.org> pread: Fix test whether it works.
--- a/doc/posix-functions/pwrite.texi +++ b/doc/posix-functions/pwrite.texi @@ -15,6 +15,10 @@ This function does not fail when an invalid (negative) offset is passed when large file support is enabled on some platforms: HP-UX 11.11. +@item +This function uses an arbitrary offset instead of the @code{off_t} argument +when large file support is enabled on some platforms: +HP-UX 11.11. @end itemize Portability problems not fixed by Gnulib:
--- a/lib/pwrite.c +++ b/lib/pwrite.c @@ -24,25 +24,9 @@ #include <errno.h> -#if HAVE_PWRITE - -ssize_t -pwrite (int fd, const void *buf, size_t nbyte, off_t offset) -# undef pwrite -{ - if (offset < 0) - { - errno = EINVAL; - return -1; - } - return pwrite (fd, buf, nbyte, offset); -} - -#else - -# define __libc_lseek(f,o,w) lseek (f, o, w) -# define __set_errno(Val) errno = (Val) -# define __libc_write(f,b,n) write (f, b, n) +#define __libc_lseek(f,o,w) lseek (f, o, w) +#define __set_errno(Val) errno = (Val) +#define __libc_write(f,b,n) write (f, b, n) /* Note: This implementation of pwrite is not multithread-safe. */ @@ -78,5 +62,3 @@ return result; } - -#endif
--- a/m4/pwrite.m4 +++ b/m4/pwrite.m4 @@ -1,4 +1,4 @@ -# pwrite.m4 serial 2 +# pwrite.m4 serial 3 dnl Copyright (C) 2010-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, @@ -15,7 +15,8 @@ AC_CHECK_FUNCS_ONCE([pwrite]) if test $ac_cv_func_pwrite = yes; then dnl On HP-UX 11.11 with _FILE_OFFSET_BITS=64, pwrite() on a file does not - dnl fail when an invalid (negative) offset is passed. + dnl fail when an invalid (negative) offset is passed and uses an arbitrary + dnl offset instead of the argument. AC_CACHE_CHECK([whether pwrite works], [gl_cv_func_pwrite_works], [ @@ -32,7 +33,7 @@ CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64" rm -f conftest.out AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ + [AC_LANG_PROGRAM([[ #include <sys/types.h> #include <unistd.h> #include <fcntl.h> @@ -47,6 +48,43 @@ if (pwrite (fd, "b", 1, (off_t) -1) >= 0) return 2; } + /* This test fails on HP-UX 11.00..11.11. */ + { + int fd; + char buf[] = "01"; + + fd = open ("conftest.out", O_WRONLY | O_CREAT | O_TRUNC, 0600); + if (fd < 0) + return 3; + if (write (fd, buf, 2) < 2) + return 4; + if (close (fd) < 0) + return 5; + + fd = open ("conftest.out", O_WRONLY, 0600); + if (fd < 0) + return 6; + if (pwrite (fd, "W", 1, (off_t) 0) != 1) + return 7; + if (close (fd) < 0) + return 8; + + fd = open ("conftest.out", O_RDONLY); + if (fd < 0) + return 9; + if (read (fd, buf, 2) < 2) + return 10; + if (close (fd) < 0) + return 11; + if (buf[0] != 'W') + return 12; + if (buf[1] != '1') + return 13; + } + return 0; +} + + return 0; }]])], [gl_cv_func_pwrite_works=yes],