]>
Commit | Line | Data |
---|---|---|
e61abf83 | 1 | /* writev supports all Linux kernels >= 2.0. |
739d440d | 2 | Copyright (C) 1997, 1998, 2000, 2002 Free Software Foundation, Inc. |
e61abf83 UD |
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 | |
41bdb6e2 AJ |
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. | |
e61abf83 UD |
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 | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
e61abf83 | 14 | |
41bdb6e2 AJ |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, write to the Free | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. */ | |
e61abf83 UD |
19 | |
20 | #include <errno.h> | |
21 | #include <stddef.h> | |
22 | #include <sys/param.h> | |
23 | #include <sys/uio.h> | |
24 | ||
0dee6738 UD |
25 | #include <sysdep.h> |
26 | #include <sys/syscall.h> | |
4bbb61e4 | 27 | #include <bp-checks.h> |
0dee6738 | 28 | |
4bbb61e4 | 29 | extern ssize_t __syscall_writev (int, const struct iovec *__unbounded, int); |
bcaad6ee AJ |
30 | static ssize_t __atomic_writev_replacement (int, const struct iovec *, |
31 | int) internal_function; | |
5ae9d168 | 32 | |
e61abf83 UD |
33 | |
34 | /* Not all versions of the kernel support the large number of records. */ | |
c57abfa7 UD |
35 | #ifndef UIO_FASTIOV |
36 | # define UIO_FASTIOV 8 /* 8 is a safe number. */ | |
e61abf83 UD |
37 | #endif |
38 | ||
39 | ||
c57abfa7 | 40 | /* We should deal with kernel which have a smaller UIO_FASTIOV as well |
e61abf83 UD |
41 | as a very big count. */ |
42 | ssize_t | |
5ae9d168 | 43 | __writev (fd, vector, count) |
e61abf83 UD |
44 | int fd; |
45 | const struct iovec *vector; | |
46 | int count; | |
47 | { | |
e61abf83 UD |
48 | ssize_t bytes_written; |
49 | ||
4bbb61e4 | 50 | bytes_written = INLINE_SYSCALL (writev, 3, fd, CHECK_N (vector, count), count); |
e61abf83 | 51 | |
5ae9d168 UD |
52 | if (bytes_written >= 0 || errno != EINVAL || count <= UIO_FASTIOV) |
53 | return bytes_written; | |
e61abf83 | 54 | |
5ae9d168 | 55 | return __atomic_writev_replacement (fd, vector, count); |
e61abf83 | 56 | } |
5ae9d168 UD |
57 | weak_alias (__writev, writev) |
58 | ||
dfd2257a | 59 | #define __writev static internal_function __atomic_writev_replacement |
5ae9d168 | 60 | #include <sysdeps/posix/writev.c> |