Mercurial > hg > octave-lojdl > gnulib-hg
diff lib/pwrite.c @ 14069:081ce9a593c4
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 01 Jan 2011 02:25:00 +0100 |
parents | 8a0b8adde2be |
children | 97fc9a21a8fb |
line wrap: on
line diff
--- 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 @@ return result; } + +#endif