X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fpwrite.m4;h=b6aecce700dbee4607874f026281adae895b5da7;hb=c140b280d2ce855161817b9a79cfe821b05312b8;hp=7fdd874c0ae3d7eed12d18f5127bc2864e3b2bf3;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/m4/pwrite.m4 b/m4/pwrite.m4 index 7fdd874c0..b6aecce70 100644 --- 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_DEFUN([gl_FUNC_PWRITE], 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 @@ changequote([,])dnl CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64" rm -f conftest.out AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ + [AC_LANG_PROGRAM([[ #include #include #include @@ -47,6 +48,43 @@ changequote([,])dnl 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],