uclibc-ng: bump version from 1.0.6 to 1.0.8
[openwrt/openwrt.git] / toolchain / uClibc / patches-0.9.33.2 / 025-libc-sync_file_range.patch
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
13 #include <sys/syscall.h>
14 -#if defined __USE_GNU
15 -#include <fcntl.h>
16 +#if defined __UCLIBC_HAS_LFS__ && defined __USE_GNU
17 +# include <bits/wordsize.h>
18 +# include <endian.h>
19 +# include <fcntl.h>
20
21 -#if defined __NR_sync_file_range && defined __UCLIBC_HAS_LFS__
22 -#define __NR___syscall_sync_file_range __NR_sync_file_range
23 -static __inline__ _syscall6(int, __syscall_sync_file_range, int, fd,
24 - off_t, offset_hi, off_t, offset_lo,
25 - off_t, nbytes_hi, off_t, nbytes_lo, unsigned int, flags)
26 +# ifdef __NR_sync_file_range2
27 +# undef __NR_sync_file_range
28 +# define __NR_sync_file_range __NR_sync_file_range2
29 +# endif
30 +
31 +# ifdef __NR_sync_file_range
32 int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
33 {
34 - return __syscall_sync_file_range(fd,
35 - __LONG_LONG_PAIR((long)(offset >> 32), (long)(offset & 0xffffffff)),
36 - __LONG_LONG_PAIR((long)(nbytes >> 32), (long)(nbytes & 0xffffffff)),
37 - flags);
38 +# if defined __powerpc__ && __WORDSIZE == 64
39 + return INLINE_SYSCALL(sync_file_range, 4, fd, flags, offset, nbytes);
40 +# elif (defined __mips__ && _MIPS_SIM == _ABIO32) || \
41 + (defined(__UCLIBC_SYSCALL_ALIGN_64BIT__) && !(defined(__powerpc__) || defined(__xtensa__)))
42 + /* arch with 64-bit data in even reg alignment #2: [arcv2/others-in-future]
43 + * stock syscall handler in kernel (reg hole punched)
44 + * see libc/sysdeps/linux/common/posix_fadvise.c for more details */
45 + return INLINE_SYSCALL(sync_file_range, 7, fd, 0,
46 + OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
47 +# elif defined __NR_sync_file_range2
48 + return INLINE_SYSCALL(sync_file_range, 6, fd, flags,
49 + OFF64_HI_LO(offset), OFF64_HI_LO(nbytes));
50 +# else
51 + return INLINE_SYSCALL(sync_file_range, 6, fd,
52 + OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
53 +# endif
54 }
55 -#endif
56 +# endif
57 #endif