sync_file_range.c 1.7 KB

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