summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2012-06-18 11:18:10 +0200
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2013-01-08 09:02:36 +0100
commitff6efa4488b338e0a72f574b26e4fff669acab8d (patch)
treec23eebc884bc2efce47ad3eb146033201d86f532 /libc/sysdeps/linux/common
parent495c425c3b10fd9e277995fa2a379ba4a62f78bf (diff)
libc: handle sync_file_range
Add cancellation and support arm, ppc64, mips32. Compile-tested. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/sysdeps/linux/common')
-rw-r--r--libc/sysdeps/linux/common/sync_file_range.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/libc/sysdeps/linux/common/sync_file_range.c b/libc/sysdeps/linux/common/sync_file_range.c
index b07f8e501..66751c65d 100644
--- a/libc/sysdeps/linux/common/sync_file_range.c
+++ b/libc/sysdeps/linux/common/sync_file_range.c
@@ -4,24 +4,34 @@
*
* Copyright (C) 2008 Bernhard Reutner-Fischer <uclibc@uclibc.org>
*
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
*/
#include <sys/syscall.h>
-
-#if defined __NR_sync_file_range && defined __UCLIBC_HAS_LFS__ && defined __USE_GNU
+#if defined __UCLIBC_HAS_LFS__ && defined __USE_GNU
+# include <bits/wordsize.h>
+# include <endian.h>
# include <fcntl.h>
+# include <cancel.h>
-# define __NR___syscall_sync_file_range __NR_sync_file_range
-static __inline__ _syscall6(int, __syscall_sync_file_range, int, fd,
- off_t, offset_hi, off_t, offset_lo,
- off_t, nbytes_hi, off_t, nbytes_lo, unsigned int, flags)
+# ifdef __NR_sync_file_range2
+# undef __NR_sync_file_range
+# define __NR_sync_file_range __NR_sync_file_range2
+# endif
-int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
+# ifdef __NR_sync_file_range
+static int __NC(sync_file_range)(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
{
- return __syscall_sync_file_range(fd,
- __LONG_LONG_PAIR((long)(offset >> 32), (long)(offset & 0xffffffff)),
- __LONG_LONG_PAIR((long)(nbytes >> 32), (long)(nbytes & 0xffffffff)),
- flags);
+# if defined __powerpc__ && __WORDSIZE == 64
+ return INLINE_SYSCALL(sync_file_range, 4, fd, offset, nbytes, flags);
+# elif defined __mips__ && __WORDSIZE == 32
+ return INLINE_SYSCALL(sync_file_range, 7, fd, 0,
+ OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
+# else
+ return INLINE_SYSCALL(sync_file_range, 6, fd,
+ OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
+# endif
}
+CANCELLABLE_SYSCALL(int, sync_file_range, (int fd, off64_t offset, off64_t nbytes, unsigned int flags), (fd, offset, nbytes, flags))
+# endif
#endif