Tested successfully on i386..
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
modify_ldt.c personality.c prctl.c readahead.c reboot.c \
remap_file_pages.c sched_getaffinity.c sched_setaffinity.c \
sendfile64.c sendfile.c setfsgid.c setfsuid.c setresuid.c \
- splice.c vmsplice.c tee.c swapoff.c swapon.c sysctl.c sysinfo.c \
- uselib.c vhangup.c,$(CSRC))
+ splice.c vmsplice.c tee.c swapoff.c swapon.c sync_file_range.c \
+ sysctl.c sysinfo.c uselib.c vhangup.c,$(CSRC))
endif
ifneq ($(UCLIBC_BSD_SPECIFIC),y)
--- /dev/null
+/* vi: set sw=4 ts=4: */
+/*
+ * sync_file_range() for uClibc
+ *
+ * Copyright (C) 2008 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#if defined __USE_GNU
+#include <fcntl.h>
+
+#if defined __NR_sync_file_range && defined __UCLIBC_HAS_LFS__
+#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);
+int 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);
+}
+#elif defined __UCLIBC_HAS_STUBS__
+int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
+{
+ __set_errno(ENOSYS);
+ return -1;
+}
+#endif
+#endif
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
#ifdef __USE_GNU
-#if 0
/* Flags for SYNC_FILE_RANGE. */
# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
in the range before performing the
# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
the range after performing the
write. */
-#endif
/* Flags for SPLICE and VMSPLICE. */
# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
__THROW;
-#if 0
/* Selective file content synch'ing. */
extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
unsigned int __flags);
-#endif
/* Splice address range into a pipe. */
extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,