readv.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* 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. #include <sys/syscall.h>
  11. #include <sys/uio.h>
  12. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  13. #include <sysdep-cancel.h>
  14. /* We should deal with kernel which have a smaller UIO_FASTIOV as well
  15. as a very big count. */
  16. static ssize_t __readv (int fd, const struct iovec *vector, int count)
  17. {
  18. ssize_t bytes_read;
  19. bytes_read = INLINE_SYSCALL (readv, 3, fd, vector, count);
  20. if (bytes_read >= 0 || errno != EINVAL || count <= UIO_FASTIOV)
  21. return bytes_read;
  22. /* glibc tries again, but we do not. */
  23. //return __atomic_readv_replacement (fd, vector, count);
  24. return -1;
  25. }
  26. ssize_t readv (int fd, const struct iovec *vector, int count)
  27. {
  28. if (SINGLE_THREAD_P)
  29. return __readv (fd, vector, count);
  30. int oldtype = LIBC_CANCEL_ASYNC ();
  31. int result = __readv (fd, vector, count);
  32. LIBC_CANCEL_RESET (oldtype);
  33. return result;
  34. }
  35. #else
  36. _syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector,
  37. int, count)
  38. #endif