about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/writev.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/writev.c')
-rw-r--r--sysdeps/unix/sysv/linux/writev.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/sysdeps/unix/sysv/linux/writev.c b/sysdeps/unix/sysv/linux/writev.c
index 05978665fa..55e915d34d 100644
--- a/sysdeps/unix/sysv/linux/writev.c
+++ b/sysdeps/unix/sysv/linux/writev.c
@@ -1,5 +1,5 @@
 /* writev supports all Linux kernels >= 2.0.
-   Copyright (C) 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1997,1998,2000,2002,2003,2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -25,6 +25,7 @@
 #include <sysdep-cancel.h>
 #include <sys/syscall.h>
 #include <bp-checks.h>
+#include <kernel-features.h>
 
 static ssize_t __atomic_writev_replacement (int, const struct iovec *,
 					    int) internal_function;
@@ -36,40 +37,38 @@ static ssize_t __atomic_writev_replacement (int, const struct iovec *,
 #endif
 
 
-/* We should deal with kernel which have a smaller UIO_FASTIOV as well
-   as a very big count.  */
-static ssize_t
-do_writev (int fd, const struct iovec *vector, int count)
-{
-  ssize_t bytes_written;
-
-  bytes_written = INLINE_SYSCALL (writev, 3, fd, CHECK_N (vector, count), count);
-
-  if (bytes_written >= 0 || errno != EINVAL || count <= UIO_FASTIOV)
-    return bytes_written;
-
-  return __atomic_writev_replacement (fd, vector, count);
-}
-
 ssize_t
 __libc_writev (fd, vector, count)
      int fd;
      const struct iovec *vector;
      int count;
 {
-  if (SINGLE_THREAD_P)
-    return do_writev (fd, vector, count);
+  ssize_t result;
 
-  int oldtype = LIBC_CANCEL_ASYNC ();
+  if (SINGLE_THREAD_P)
+    result = INLINE_SYSCALL (writev, 3, fd, CHECK_N (vector, count), count);
+  else
+    {
+      int oldtype = LIBC_CANCEL_ASYNC ();
 
-  ssize_t result = do_writev (fd, vector, count);
+      result = INLINE_SYSCALL (writev, 3, fd, CHECK_N (vector, count), count);
 
-  LIBC_CANCEL_RESET (oldtype);
+      LIBC_CANCEL_RESET (oldtype);
+    }
 
+#ifdef __ASSUME_COMPLETE_READV_WRITEV
   return result;
+#else
+  if (result >= 0 || errno != EINVAL || count <= UIO_FASTIOV)
+    return result;
+
+  return __atomic_writev_replacement (fd, vector, count);
+#endif
 }
 strong_alias (__libc_writev, __writev)
 weak_alias (__libc_writev, writev)
 
-#define __libc_writev static internal_function __atomic_writev_replacement
-#include <sysdeps/posix/writev.c>
+#ifndef __ASSUME_COMPLETE_READV_WRITEV
+# define __libc_writev static internal_function __atomic_writev_replacement
+# include <sysdeps/posix/writev.c>
+#endif