From 5c742ff1a53e556b8f6ad4c3ea89d67380c22adf Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Tue, 16 Sep 2008 14:02:54 +0000 Subject: - add sync_file_range() Tested successfully on i386.. --- libc/sysdeps/linux/common/Makefile.in | 4 ++-- libc/sysdeps/linux/common/sync_file_range.c | 33 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 libc/sysdeps/linux/common/sync_file_range.c (limited to 'libc/sysdeps/linux/common') diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in index d61ae9f4f..c55f0fe49 100644 --- a/libc/sysdeps/linux/common/Makefile.in +++ b/libc/sysdeps/linux/common/Makefile.in @@ -35,8 +35,8 @@ CSRC := $(filter-out inotify.c ioperm.c iopl.c madvise.c \ 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) diff --git a/libc/sysdeps/linux/common/sync_file_range.c b/libc/sysdeps/linux/common/sync_file_range.c new file mode 100644 index 000000000..53f7ae6a1 --- /dev/null +++ b/libc/sysdeps/linux/common/sync_file_range.c @@ -0,0 +1,33 @@ +/* vi: set sw=4 ts=4: */ +/* + * sync_file_range() for uClibc + * + * Copyright (C) 2008 Bernhard Reutner-Fischer + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include +#if defined __USE_GNU +#include + +#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 -- cgit v1.2.3