summaryrefslogtreecommitdiffstats
path: root/libc/sysdeps/linux/common/readahead.c
diff options
context:
space:
mode:
author"Steven J. Hill" <sjhill@realitydiluted.com>2006-12-16 04:24:32 +0000
committer"Steven J. Hill" <sjhill@realitydiluted.com>2006-12-16 04:24:32 +0000
commit1a7e83aa3b67ab61fa26f6e31a38c4c52408a689 (patch)
treef7bd98f1f48754f16130e48aa392853b522fa090 /libc/sysdeps/linux/common/readahead.c
parent958879310a07ac8d0c259d8e6416d6d1de4b0675 (diff)
downloaduClibc-alpine-1a7e83aa3b67ab61fa26f6e31a38c4c52408a689.tar.bz2
uClibc-alpine-1a7e83aa3b67ab61fa26f6e31a38c4c52408a689.tar.xz
Copy from trunk.
Diffstat (limited to 'libc/sysdeps/linux/common/readahead.c')
-rw-r--r--libc/sysdeps/linux/common/readahead.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/common/readahead.c b/libc/sysdeps/linux/common/readahead.c
new file mode 100644
index 000000000..ae7a57c44
--- /dev/null
+++ b/libc/sysdeps/linux/common/readahead.c
@@ -0,0 +1,58 @@
+/* Provide kernel hint to read ahead.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <bits/wordsize.h>
+
+#ifdef __UCLIBC_HAS_LFS__
+
+#include <_lfs_64.h>
+
+#ifdef __NR_readahead
+
+# define __NR___readahead __NR_readahead
+
+# if __WORDSIZE == 64
+
+static inline _syscall3(ssize_t, __readahead, int, fd,
+ off_t, offset, size_t, count);
+
+ssize_t readahead(int fd, off_t offset, size_t count)
+{
+ return __readahead(fd, offset, count);
+}
+
+# else
+
+static inline _syscall4(ssize_t, __readahead, int, fd,
+ off_t, high_offset, off_t, low_offset, size_t, count);
+
+ssize_t readahead(int fd, off64_t offset, size_t count)
+{
+ return __readahead(fd, (off_t) (offset >> 32), (off_t) (offset & 0xffffffff), count);
+}
+
+# endif
+
+#endif
+
+#endif /* __UCLIBC_HAS_LFS__ */