glibc/sysdeps/unix/sysv/linux/preadv64.c
Adhemerval Zanella 4751bbe2ad Fix p{readv,writev}{64} consolidation implementation
This patch fixes the p{readv,writev}{64} consolidation implementation
from commits 4e77815 and af5fdf5.  Different from pread/pwrite
implementation, preadv/pwritev implementation does not require
__ALIGNMENT_ARG because kernel syscall prototypes define
the high and low part of the off_t, if it is the case, directly
(different from pread/pwrite where the architecture ABI for passing
64-bit values must be in consideration for passsing the arguments).

It also adds some basic tests for preadv/pwritev.

Tested on x86_64, i686, and armhf.

	* misc/Makefile (tests): Add tst-preadvwritev and tst-preadvwritev64.
	* misc/tst-preadvwritev.c: New file.
	* misc/tst-preadvwritev64.c: Likewise.
	* sysdeps/unix/sysv/linux/preadv.c (preadv): Remove SYSCALL_LL{64}
	usage.
	* sysdeps/unix/sysv/linux/preadv64.c (preadv64): Likewise.
	* sysdeps/unix/sysv/linux/pwritev.c (pwritev): Likewise.
	* sysdeps/unix/sysv/linux/pwritev64.c (pwritev64): Likewise.
	* sysdeps/unix/sysv/linux/sysdep.h (LO_HI_LONG): New macro.
2016-06-21 11:29:18 -03:00

55 lines
1.8 KiB
C

/* Copyright (C) 2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <sys/uio.h>
#include <sysdep-cancel.h>
#ifdef __ASSUME_PREADV
# ifndef __NR_preadv64
# define __NR_preadv64 __NR_preadv
# endif
ssize_t
preadv64 (int fd, const struct iovec *vector, int count, off64_t offset)
{
return SYSCALL_CANCEL (preadv64, fd, vector, count, LO_HI_LONG (offset));
}
#else
static ssize_t __atomic_preadv64_replacement (int, const struct iovec *,
int, off64_t) internal_function;
ssize_t
preadv64 (int fd, const struct iovec *vector, int count, off64_t offset)
{
#ifdef __NR_preadv64
ssize_t result = SYSCALL_CANCEL (preadv64, fd, vector, count,
LO_HI_LONG (offset));
if (result >= 0 || errno != ENOSYS)
return result;
#endif
return __atomic_preadv64_replacement (fd, vector, count, offset);
}
# define PREADV static internal_function __atomic_preadv64_replacement
# define PREAD __pread64
# define OFF_T off64_t
# include <sysdeps/posix/preadv.c>
#endif
#if __WORDSIZE == 64 && !defined (__ASSUME_OFF_DIFF_OFF64)
strong_alias (preadv64, preadv)
#endif