| 1 | /* 64-bit pwritev. |
| 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 pwritev64 declaration. */ |
| 23 | #define pwritev64 __redirect_pwritev64 |
| 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_PWRITEV |
| 31 | static ssize_t __atomic_pwritev_replacement (int, const struct iovec *, |
| 32 | int, off_t) internal_function; |
| 33 | #endif |
| 34 | |
| 35 | ssize_t |
| 36 | pwritev (int fd, const struct iovec *vector, int count, off_t offset) |
| 37 | { |
| 38 | #ifdef __NR_pwritev |
| 39 | ssize_t result; |
| 40 | |
| 41 | result = SYSCALL_CANCEL (pwritev, fd, vector, count, offset); |
| 42 | # ifdef __ASSUME_PWRITEV |
| 43 | return result; |
| 44 | # endif |
| 45 | #endif |
| 46 | |
| 47 | #ifndef __ASSUME_PWRITEV |
| 48 | # ifdef __NR_pwritev |
| 49 | if (result >= 0 || errno != ENOSYS) |
| 50 | return result; |
| 51 | # endif |
| 52 | |
| 53 | return __atomic_pwritev_replacement (fd, vector, count, offset); |
| 54 | #endif |
| 55 | } |
| 56 | #undef pwritev64 |
| 57 | strong_alias (pwritev, pwritev64) |
| 58 | |
| 59 | #ifndef __ASSUME_PWRITEV |
| 60 | # define PWRITE __pwrite |
| 61 | # define PWRITEV static internal_function __atomic_pwritev_replacement |
| 62 | # define OFF_T off_t |
| 63 | # include <sysdeps/posix/pwritev.c> |
| 64 | #endif |
| 65 | |