summaryrefslogtreecommitdiff
path: root/libc/sysdeps
diff options
context:
space:
mode:
authorPeter S. Mazinger <ps.m@gmx.net>2011-04-21 22:34:56 +0200
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2012-06-15 14:00:41 +0200
commit0500402162dd3b32b88238a039f544a386a5c86b (patch)
tree84bbdab31c7f2f43678b6678e78c581ab9fd5f71 /libc/sysdeps
parent08b258aeb96a6970b950eedc2dc2ab00b04011ee (diff)
readv, writev: rewrite to use cancel.h
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/sysdeps')
-rw-r--r--libc/sysdeps/linux/common/readv.c40
-rw-r--r--libc/sysdeps/linux/common/writev.c40
2 files changed, 19 insertions, 61 deletions
diff --git a/libc/sysdeps/linux/common/readv.c b/libc/sysdeps/linux/common/readv.c
index fce396d5f..9418ea430 100644
--- a/libc/sysdeps/linux/common/readv.c
+++ b/libc/sysdeps/linux/common/readv.c
@@ -10,41 +10,21 @@
#include <sys/syscall.h>
#include <sys/uio.h>
-
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-#include <sysdep-cancel.h>
+#include <cancel.h>
/* We should deal with kernel which have a smaller UIO_FASTIOV as well
as a very big count. */
-static ssize_t __readv (int fd, const struct iovec *vector, int count)
+static ssize_t __NC(readv)(int fd, const struct iovec *vector, int count)
{
- ssize_t bytes_read;
-
- bytes_read = INLINE_SYSCALL (readv, 3, fd, vector, count);
-
- if (bytes_read >= 0 || errno != EINVAL || count <= UIO_FASTIOV)
- return bytes_read;
-
- /* glibc tries again, but we do not. */
- //return __atomic_readv_replacement (fd, vector, count);
-
- return -1;
-}
-
-ssize_t readv (int fd, const struct iovec *vector, int count)
-{
- if (SINGLE_THREAD_P)
- return __readv (fd, vector, count);
-
- int oldtype = LIBC_CANCEL_ASYNC ();
+ ssize_t bytes_read = INLINE_SYSCALL(readv, 3, fd, vector, count);
- int result = __readv (fd, vector, count);
+ if (bytes_read >= 0 || errno != EINVAL || count <= UIO_FASTIOV)
+ return bytes_read;
- LIBC_CANCEL_RESET (oldtype);
+ /* glibc tries again, but we do not. */
+ /* return __atomic_readv_replacement (fd, vector, count); */
- return result;
+ return -1;
}
-#else
-_syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector,
- int, count)
-#endif
+CANCELLABLE_SYSCALL(ssize_t, readv, (int fd, const struct iovec *vector, int count),
+ (fd, vector, count))
diff --git a/libc/sysdeps/linux/common/writev.c b/libc/sysdeps/linux/common/writev.c
index bd0e4077d..9b59228c3 100644
--- a/libc/sysdeps/linux/common/writev.c
+++ b/libc/sysdeps/linux/common/writev.c
@@ -9,42 +9,20 @@
#include <sys/syscall.h>
#include <sys/uio.h>
-
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-#include <errno.h>
-#include <sysdep-cancel.h>
+#include <cancel.h>
/* We should deal with kernel which have a smaller UIO_FASTIOV as well
as a very big count. */
-static ssize_t __writev (int fd, const struct iovec *vector, int count)
+static ssize_t __NC(writev)(int fd, const struct iovec *vector, int count)
{
- ssize_t bytes_written;
-
- bytes_written = INLINE_SYSCALL (writev, 3, fd, vector, count);
-
- if (bytes_written >= 0 || errno != EINVAL || count <= UIO_FASTIOV)
- return bytes_written;
-
- /* glibc tries again, but we do not. */
- /* return __atomic_writev_replacement (fd, vector, count); */
-
- return -1;
-}
-
-ssize_t writev (int fd, const struct iovec *vector, int count)
-{
- if (SINGLE_THREAD_P)
- return __writev (fd, vector, count);
-
- int oldtype = LIBC_CANCEL_ASYNC ();
+ ssize_t bytes_written = INLINE_SYSCALL(writev, 3, fd, vector, count);
- ssize_t result = __writev (fd, vector, count);
+ if (bytes_written >= 0 || errno != EINVAL || count <= UIO_FASTIOV)
+ return bytes_written;
- LIBC_CANCEL_RESET (oldtype);
+ /* glibc tries again, but we do not. */
+ /* return __atomic_writev_replacement (fd, vector, count); */
- return result;
+ return -1;
}
-#else
-_syscall3(ssize_t, writev, int, filedes, const struct iovec *, vector,
- int, count)
-#endif
+CANCELLABLE_SYSCALL(ssize_t, writev, (int fd, const struct iovec *vector, int count), (fd, vector, count))