* stdio-common/vfprintf.c (vfprintf): Slightly more compact code.
[glibc.git] / sysdeps / unix / sysv / linux / preadv.c
blob0d4a6c380348a667c399c75c4d12cba2eb4fa101
1 /* Copyright (C) 2009 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #include <errno.h>
20 #include <stddef.h>
21 #include <sys/param.h>
22 #if __WORDSIZE == 64
23 /* Hide the preadv64 declaration. */
24 # define preadv64 __redirect_preadv64
25 #endif
26 #include <sys/uio.h>
28 #include <sysdep-cancel.h>
29 #include <sys/syscall.h>
30 #include <kernel-features.h>
33 #ifndef PREADV
34 # define PREADV preadv
35 # define PREADV_REPLACEMENT __atomic_preadv_replacement
36 # define PREAD __pread
37 # define OFF_T off_t
38 #endif
40 #ifndef __ASSUME_PREADV
41 static ssize_t PREADV_REPLACEMENT (int, __const struct iovec *,
42 int, OFF_T) internal_function;
43 #endif
46 ssize_t
47 PREADV (fd, vector, count, offset)
48 int fd;
49 const struct iovec *vector;
50 int count;
51 OFF_T offset;
53 #ifdef __NR_preadv
54 ssize_t result;
56 if (SINGLE_THREAD_P)
57 result = INLINE_SYSCALL (preadv, 5, fd, vector, count,
58 (off_t) ((off64_t) offset >> 32),
59 (off_t) (offset & 0xffffffff));
60 else
62 int oldtype = LIBC_CANCEL_ASYNC ();
64 result = INLINE_SYSCALL (preadv, 5, fd, vector, count,
65 (off_t) ((off64_t) offset >> 32),
66 (off_t) (offset & 0xffffffff));
68 LIBC_CANCEL_RESET (oldtype);
70 # ifdef __ASSUME_PREADV
71 return result;
72 # endif
73 #endif
75 #ifndef __ASSUME_PREADV
76 # ifdef __NR_preadv
77 if (result >= 0 || errno != ENOSYS)
78 return result;
79 # endif
81 return PREADV_REPLACEMENT (fd, vector, count, offset);
82 #endif
84 #if __WORDSIZE == 64
85 # undef preadv64
86 strong_alias (preadv, preadv64)
87 #endif
89 #ifndef __ASSUME_PREADV
90 # undef PREADV
91 # define PREADV static internal_function PREADV_REPLACEMENT
92 # include <sysdeps/posix/preadv.c>
93 #endif