1/* 64-bit preadv.
2 Copyright (C) 2012-2016 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <errno.h>
20#include <stddef.h>
21#include <sys/param.h>
22/* Hide the preadv64 declaration. */
23#define preadv64 __redirect_preadv64
24#include <sys/uio.h>
25
26#include <sysdep-cancel.h>
27#include <sys/syscall.h>
28#include <kernel-features.h>
29
30#ifndef __ASSUME_PREADV
31static ssize_t __atomic_preadv_replacement (int, const struct iovec *,
32 int, off_t) internal_function;
33#endif
34
35ssize_t
36preadv (int fd, const struct iovec *vector, int count, off_t offset)
37{
38#ifdef __NR_preadv
39 ssize_t result;
40
41 result = SYSCALL_CANCEL (preadv, fd, vector, count, offset);
42# ifdef __ASSUME_PREADV
43 return result;
44# endif
45#endif
46
47#ifndef __ASSUME_PREADV
48# ifdef __NR_preadv
49 if (result >= 0 || errno != ENOSYS)
50 return result;
51# endif
52
53 return __atomic_preadv_replacement (fd, vector, count, offset);
54#endif
55}
56#undef preadv64
57strong_alias (preadv, preadv64)
58
59#ifndef __ASSUME_PREADV
60# define PREADV static internal_function __atomic_preadv_replacement
61# define PREAD __pread
62# define OFF_T off_t
63# include <sysdeps/posix/preadv.c>
64#endif
65