sendfile64.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  3. *
  4. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  5. */
  6. /* sendfile64 syscall. Copes with 64 bit and 32 bit machines
  7. * and on 32 bit machines this sends things into the kernel as
  8. * two 32-bit arguments (high and low 32 bits of length) that
  9. * are ordered based on endianess. It turns out endian.h has
  10. * just the macro we need to order things, __LONG_LONG_PAIR.
  11. */
  12. #include <features.h>
  13. #include <unistd.h>
  14. #include <errno.h>
  15. #include <endian.h>
  16. #include <stdint.h>
  17. #include <sys/sendfile.h>
  18. #include <sys/syscall.h>
  19. #if defined __NR_sendfile64
  20. # if __WORDSIZE == 64 || (defined(__powerpc__) && defined (__UCLIBC_HAS_LFS__))
  21. /* For a 64 bit machine, life is simple... */
  22. _syscall4(ssize_t,sendfile64, int, out_fd, int, in_fd, __off64_t *, offset, size_t, count);
  23. # elif __WORDSIZE == 32
  24. # if defined __UCLIBC_HAS_LFS__
  25. _syscall4(ssize_t,sendfile64, int, out_fd, int, in_fd, __off64_t *, offset, size_t, count);
  26. # endif /* __UCLIBC_HAS_LFS__ */
  27. # else /* __WORDSIZE */
  28. # error Your machine is not 64 bit or 32 bit, I am dazed and confused.
  29. # endif /* __WORDSIZE */
  30. #else /* ! defined __NR_sendfile64 */
  31. ssize_t sendfile64 (int out_fd, int in_fd, __off64_t *offset, size_t count)
  32. {
  33. __set_errno (ENOSYS);
  34. return -1;
  35. }
  36. #endif