blob: fce396d5f402b5c13d2459cfd45e50b97fda92c1 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* vi: set sw=4 ts=4: */
2/*
3 * readv() for uClibc
4 *
5 * Copyright (C) 2006 by Steven J. Hill <sjhill@realitydiluted.com>
6 * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
7 *
8 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
9 */
10
11#include <sys/syscall.h>
12#include <sys/uio.h>
13
14#ifdef __UCLIBC_HAS_THREADS_NATIVE__
15#include <sysdep-cancel.h>
16
17/* We should deal with kernel which have a smaller UIO_FASTIOV as well
18 as a very big count. */
19static ssize_t __readv (int fd, const struct iovec *vector, int count)
20{
21 ssize_t bytes_read;
22
23 bytes_read = INLINE_SYSCALL (readv, 3, fd, vector, count);
24
25 if (bytes_read >= 0 || errno != EINVAL || count <= UIO_FASTIOV)
26 return bytes_read;
27
28 /* glibc tries again, but we do not. */
29 //return __atomic_readv_replacement (fd, vector, count);
30
31 return -1;
32}
33
34ssize_t readv (int fd, const struct iovec *vector, int count)
35{
36 if (SINGLE_THREAD_P)
37 return __readv (fd, vector, count);
38
39 int oldtype = LIBC_CANCEL_ASYNC ();
40
41 int result = __readv (fd, vector, count);
42
43 LIBC_CANCEL_RESET (oldtype);
44
45 return result;
46}
47#else
48_syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector,
49 int, count)
50#endif