sync_file_range.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * sync_file_range() for uClibc
  4. *
  5. * Copyright (C) 2008 Bernhard Reutner-Fischer <uclibc@uclibc.org>
  6. *
  7. * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <sys/syscall.h>
  10. #if defined __UCLIBC_HAS_LFS__ && defined __USE_GNU
  11. # include <bits/wordsize.h>
  12. # include <endian.h>
  13. # include <fcntl.h>
  14. # include <cancel.h>
  15. # ifdef __NR_sync_file_range2
  16. # undef __NR_sync_file_range
  17. # define __NR_sync_file_range __NR_sync_file_range2
  18. # endif
  19. # ifdef __NR_sync_file_range
  20. static int __NC(sync_file_range)(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
  21. {
  22. # if defined __powerpc__ && __WORDSIZE == 64
  23. return INLINE_SYSCALL(sync_file_range, 4, fd, offset, nbytes, flags);
  24. # elif defined __mips__ && __WORDSIZE == 32
  25. return INLINE_SYSCALL(sync_file_range, 7, fd, 0,
  26. OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
  27. # else
  28. return INLINE_SYSCALL(sync_file_range, 6, fd,
  29. OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
  30. # endif
  31. }
  32. CANCELLABLE_SYSCALL(int, sync_file_range, (int fd, off64_t offset, off64_t nbytes, unsigned int flags), (fd, offset, nbytes, flags))
  33. # endif
  34. #endif