diff options
author | Bruno Haible <bruno@clisp.org> | 2011-01-01 02:25:00 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2011-01-01 02:25:00 +0100 |
commit | 872abb203f6a4ddde61e37912d97e622b89a2f7a (patch) | |
tree | bc573fca1bafa124c032881046249743a45937a7 /lib/pwrite.c | |
parent | e86df7d62b265b41297f1afb0795efab89a5884e (diff) | |
download | gnulib-872abb203f6a4ddde61e37912d97e622b89a2f7a.tar.gz |
pwrite: Work around HP-UX 11.11 bug.
* m4/pwrite.m4 (gl_FUNC_PWRITE): When pwrite exists, test whether it
works and set REPLACE_PWRITE if not.
* lib/pwrite.c (pwrite): Add an implementation that uses the system
function.
* doc/posix-functions/pwrite.texi: Document the HP-UX 11 bug.
Diffstat (limited to 'lib/pwrite.c')
-rw-r--r-- | lib/pwrite.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/pwrite.c b/lib/pwrite.c index 00714791c3..4a913571de 100644 --- a/lib/pwrite.c +++ b/lib/pwrite.c @@ -24,9 +24,25 @@ #include <errno.h> -#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) +#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) /* Note: This implementation of pwrite is not multithread-safe. */ @@ -62,3 +78,5 @@ pwrite (int fd, const void *buf, size_t nbyte, off_t offset) return result; } + +#endif |