[RFC PATCH 25/38] sendfile: prefer sendfile64 syscall

Jonas Bonn jonas at southpole.se
Tue Sep 6 08:30:49 UTC 2011


Signed-off-by: Jonas Bonn <jonas at southpole.se>
---
 libc/sysdeps/linux/common/sendfile.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/libc/sysdeps/linux/common/sendfile.c b/libc/sysdeps/linux/common/sendfile.c
index 89bab9f..1d0c823 100644
--- a/libc/sysdeps/linux/common/sendfile.c
+++ b/libc/sysdeps/linux/common/sendfile.c
@@ -11,13 +11,30 @@
 #include <unistd.h>
 #include <sys/sendfile.h>
 
-#ifdef __NR_sendfile
+#ifdef __NR_sendfile64
+ssize_t sendfile(int out_fd, int in_fd, __off_t* offset, size_t count)
+{
+	__off64_t off64, *off;
+	ssize_t res;
 
+	if (offset) {
+		off = &off64;
+		off64 = *offset;
+	} else
+		off = NULL;
+
+	res = INLINE_SYSCALL(sendfile64, 4, out_fd, in_fd, off, count);
+	*offset = off64;
+
+	return res;
+}
+
+#elif defined __NR_sendfile
 _syscall4(ssize_t, sendfile, int, out_fd, int, in_fd, __off_t *, offset,
 		  size_t, count)
 
-#if ! defined __NR_sendfile64 && defined __UCLIBC_HAS_LFS__
+#ifdef __UCLIBC_HAS_LFS__
 strong_alias(sendfile,sendfile64)
 #endif
 
-#endif /* __NR_sendfile */
+#endif
-- 
1.7.5.4



More information about the uClibc mailing list