sync_file_range.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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, flags, offset, nbytes);
  24. # elif (defined __mips__ && _MIPS_SIM == _ABIO32) || \
  25. (defined(__UCLIBC_SYSCALL_ALIGN_64BIT__) && !(defined(__powerpc__) || defined(__xtensa__)))
  26. /* arch with 64-bit data in even reg alignment #2: [arcv2/others-in-future]
  27. * stock syscall handler in kernel (reg hole punched)
  28. * see libc/sysdeps/linux/common/posix_fadvise.c for more details */
  29. return INLINE_SYSCALL(sync_file_range, 7, fd, 0,
  30. OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
  31. # elif defined __NR_sync_file_range2
  32. return INLINE_SYSCALL(sync_file_range, 6, fd, flags,
  33. OFF64_HI_LO(offset), OFF64_HI_LO(nbytes));
  34. # else
  35. return INLINE_SYSCALL(sync_file_range, 6, fd,
  36. OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
  37. # endif
  38. }
  39. CANCELLABLE_SYSCALL(int, sync_file_range, (int fd, off64_t offset, off64_t nbytes, unsigned int flags), (fd, offset, nbytes, flags))
  40. # endif
  41. #endif