025-libc-sync_file_range.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. Index: uClibc-0.9.33.2/libc/sysdeps/linux/common/sync_file_range.c
  2. ===================================================================
  3. --- uClibc-0.9.33.2.orig/libc/sysdeps/linux/common/sync_file_range.c 2012-05-15 09:20:09.000000000 +0200
  4. +++ uClibc-0.9.33.2/libc/sysdeps/linux/common/sync_file_range.c 2015-04-03 00:27:47.701221722 +0200
  5. @@ -4,24 +4,39 @@
  6. *
  7. * Copyright (C) 2008 Bernhard Reutner-Fischer <uclibc@uclibc.org>
  8. *
  9. - * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  10. + * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
  11. */
  12. #include <sys/syscall.h>
  13. -#if defined __USE_GNU
  14. -#include <fcntl.h>
  15. +#if defined __UCLIBC_HAS_LFS__ && defined __USE_GNU
  16. +# include <bits/wordsize.h>
  17. +# include <endian.h>
  18. +# include <fcntl.h>
  19. -#if defined __NR_sync_file_range && defined __UCLIBC_HAS_LFS__
  20. -#define __NR___syscall_sync_file_range __NR_sync_file_range
  21. -static __inline__ _syscall6(int, __syscall_sync_file_range, int, fd,
  22. - off_t, offset_hi, off_t, offset_lo,
  23. - off_t, nbytes_hi, off_t, nbytes_lo, unsigned int, flags)
  24. +# ifdef __NR_sync_file_range2
  25. +# undef __NR_sync_file_range
  26. +# define __NR_sync_file_range __NR_sync_file_range2
  27. +# endif
  28. +
  29. +# ifdef __NR_sync_file_range
  30. int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
  31. {
  32. - return __syscall_sync_file_range(fd,
  33. - __LONG_LONG_PAIR((long)(offset >> 32), (long)(offset & 0xffffffff)),
  34. - __LONG_LONG_PAIR((long)(nbytes >> 32), (long)(nbytes & 0xffffffff)),
  35. - flags);
  36. +# if defined __powerpc__ && __WORDSIZE == 64
  37. + return INLINE_SYSCALL(sync_file_range, 4, fd, flags, offset, nbytes);
  38. +# elif (defined __mips__ && _MIPS_SIM == _ABIO32) || \
  39. + (defined(__UCLIBC_SYSCALL_ALIGN_64BIT__) && !(defined(__powerpc__) || defined(__xtensa__)))
  40. + /* arch with 64-bit data in even reg alignment #2: [arcv2/others-in-future]
  41. + * stock syscall handler in kernel (reg hole punched)
  42. + * see libc/sysdeps/linux/common/posix_fadvise.c for more details */
  43. + return INLINE_SYSCALL(sync_file_range, 7, fd, 0,
  44. + OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
  45. +# elif defined __NR_sync_file_range2
  46. + return INLINE_SYSCALL(sync_file_range, 6, fd, flags,
  47. + OFF64_HI_LO(offset), OFF64_HI_LO(nbytes));
  48. +# else
  49. + return INLINE_SYSCALL(sync_file_range, 6, fd,
  50. + OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
  51. +# endif
  52. }
  53. -#endif
  54. +# endif
  55. #endif