Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / unix / sysv / linux / wordsize-64 / pwritev.c
blob960c8c0f5d3db041435a2fad977d5f29009939dc
1 /* 64-bit pwritev.
2 Copyright (C) 2012-2015 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
19 #include <errno.h>
20 #include <stddef.h>
21 #include <sys/param.h>
22 /* Hide the pwritev64 declaration. */
23 #define pwritev64 __redirect_pwritev64
24 #include <sys/uio.h>
26 #include <sysdep-cancel.h>
27 #include <sys/syscall.h>
28 #include <kernel-features.h>
30 #ifndef __ASSUME_PWRITEV
31 static ssize_t __atomic_pwritev_replacement (int, const struct iovec *,
32 int, off_t) internal_function;
33 #endif
35 ssize_t
36 pwritev (int fd, const struct iovec *vector, int count, off_t offset)
38 #ifdef __NR_pwritev
39 ssize_t result;
41 if (SINGLE_THREAD_P)
42 result = INLINE_SYSCALL (pwritev, 4, fd, vector, count, offset);
43 else
45 int oldtype = LIBC_CANCEL_ASYNC ();
47 result = INLINE_SYSCALL (pwritev, 4, fd, vector, count, offset);
49 LIBC_CANCEL_RESET (oldtype);
51 # ifdef __ASSUME_PWRITEV
52 return result;
53 # endif
54 #endif
56 #ifndef __ASSUME_PWRITEV
57 # ifdef __NR_pwritev
58 if (result >= 0 || errno != ENOSYS)
59 return result;
60 # endif
62 return __atomic_pwritev_replacement (fd, vector, count, offset);
63 #endif
65 #undef pwritev64
66 strong_alias (pwritev, pwritev64)
68 #ifndef __ASSUME_PWRITEV
69 # define PWRITE __pwrite
70 # define PWRITEV static internal_function __atomic_pwritev_replacement
71 # define OFF_T off_t
72 # include <sysdeps/posix/pwritev.c>
73 #endif