sync_file_range.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * sync_file_range() for uClibc
  3. *
  4. * Copyright (C) 2008 Bernhard Reutner-Fischer <uclibc@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <sys/syscall.h>
  9. #if defined __USE_GNU
  10. # include <bits/wordsize.h>
  11. # include <endian.h>
  12. # include <fcntl.h>
  13. # include <cancel.h>
  14. # ifdef __NR_sync_file_range2
  15. # undef __NR_sync_file_range
  16. # define __NR_sync_file_range __NR_sync_file_range2
  17. # endif
  18. # ifdef __NR_sync_file_range
  19. static int __NC(sync_file_range)(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
  20. {
  21. # if defined __powerpc__ && __WORDSIZE == 64
  22. return INLINE_SYSCALL(sync_file_range, 4, fd, flags, offset, nbytes);
  23. # elif defined __arm__ && defined __thumb__
  24. return INLINE_SYSCALL(sync_file_range, 6, fd,
  25. OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
  26. # elif (defined __mips__ && _MIPS_SIM == _ABIO32) || \
  27. (defined(__UCLIBC_SYSCALL_ALIGN_64BIT__) && !(defined(__powerpc__) || defined(__xtensa__) || defined(__nds32__) || defined(__csky__)))
  28. /* arch with 64-bit data in even reg alignment #2: [arcv2/others-in-future]
  29. * stock syscall handler in kernel (reg hole punched)
  30. * see libc/sysdeps/linux/common/posix_fadvise.c for more details */
  31. return INLINE_SYSCALL(sync_file_range, 7, fd, 0,
  32. OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
  33. # elif defined __NR_sync_file_range2
  34. return INLINE_SYSCALL(sync_file_range, 6, fd, flags,
  35. OFF64_HI_LO(offset), OFF64_HI_LO(nbytes));
  36. # else
  37. return INLINE_SYSCALL(sync_file_range, 6, fd,
  38. OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
  39. # endif
  40. }
  41. CANCELLABLE_SYSCALL(int, sync_file_range, (int fd, off64_t offset, off64_t nbytes, unsigned int flags), (fd, offset, nbytes, flags))
  42. # endif
  43. #endif