svn commit: trunk/uClibc/libc/sysdeps/linux/mips
vapier at uclibc.org
vapier at uclibc.org
Thu May 31 08:22:36 UTC 2007
Author: vapier
Date: 2007-05-31 01:22:35 -0700 (Thu, 31 May 2007)
New Revision: 18708
Log:
Atsushi Nemoto writes:
Current MIPS readahead(), posix_fadvise(), posix_fadvise64() do not
match with kernel on all ABIs.
On O32 ABI, a padding is needed before a long long argument.
On N32/N64, a long long argument should be passed via a single register.
Added:
trunk/uClibc/libc/sysdeps/linux/mips/posix_fadvise.c
trunk/uClibc/libc/sysdeps/linux/mips/posix_fadvise64.c
trunk/uClibc/libc/sysdeps/linux/mips/readahead.c
Modified:
trunk/uClibc/libc/sysdeps/linux/mips/Makefile.arch
Changeset:
Modified: trunk/uClibc/libc/sysdeps/linux/mips/Makefile.arch
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/mips/Makefile.arch 2007-05-31 08:21:38 UTC (rev 18707)
+++ trunk/uClibc/libc/sysdeps/linux/mips/Makefile.arch 2007-05-31 08:22:35 UTC (rev 18708)
@@ -7,7 +7,8 @@
CSRC := \
__longjmp.c brk.c setjmp_aux.c mmap.c __syscall_error.c \
- cacheflush.c pread_write.c sysmips.c _test_and_set.c sigaction.c
+ cacheflush.c pread_write.c sysmips.c _test_and_set.c sigaction.c \
+ readahead.c posix_fadvise.c posix_fadvise64.c
SSRC := bsd-_setjmp.S bsd-setjmp.S setjmp.S clone.S syscall.S pipe.S
Added: trunk/uClibc/libc/sysdeps/linux/mips/posix_fadvise.c
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/mips/posix_fadvise.c (rev 0)
+++ trunk/uClibc/libc/sysdeps/linux/mips/posix_fadvise.c 2007-05-31 08:22:35 UTC (rev 18708)
@@ -0,0 +1,39 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * posix_fadvise() for MIPS uClibc
+ * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+#include <unistd.h>
+#include <errno.h>
+#include <endian.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <fcntl.h>
+
+int posix_fadvise(int fd, off_t offset, off_t len, int advice)
+{
+/* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
+#ifdef __NR_fadvise64
+ INTERNAL_SYSCALL_DECL(err);
+# if _MIPS_SIM == _ABIO32
+ int ret = INTERNAL_SYSCALL(fadvise64, err, 7, fd, 0,
+ __LONG_LONG_PAIR ((long) (offset >> 31), (long) offset),
+ __LONG_LONG_PAIR ((long) (len >> 31), (long) len),
+ advice);
+# else /* N32 || N64 */
+ int ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
+# endif
+ if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+ return INTERNAL_SYSCALL_ERRNO (ret, err);
+ return 0;
+#else
+ return ENOSYS;
+#endif
+}
Added: trunk/uClibc/libc/sysdeps/linux/mips/posix_fadvise64.c
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/mips/posix_fadvise64.c (rev 0)
+++ trunk/uClibc/libc/sysdeps/linux/mips/posix_fadvise64.c 2007-05-31 08:22:35 UTC (rev 18708)
@@ -0,0 +1,43 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * posix_fadvise64() for MIPS uClibc
+ * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+#include <unistd.h>
+#include <errno.h>
+#include <endian.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <fcntl.h>
+
+#ifdef __UCLIBC_HAS_LFS__
+
+int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
+{
+/* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
+#ifdef __NR_fadvise64
+ INTERNAL_SYSCALL_DECL(err);
+# if _MIPS_SIM == _MIPS_SIM_ABI32
+ int ret = INTERNAL_SYSCALL(fadvise64, err, 7, fd, 0,
+ __LONG_LONG_PAIR ((long) (offset >> 32), (long) offset),
+ __LONG_LONG_PAIR ((long) (len >> 32), (long) len),
+ advice);
+# else /* N32 || N64 */
+ int ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
+# endif
+ if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+ return INTERNAL_SYSCALL_ERRNO (ret, err);
+ return 0;
+#else
+ return ENOSYS;
+#endif
+}
+
+#endif /* __UCLIBC_HAS_LFS__ */
Added: trunk/uClibc/libc/sysdeps/linux/mips/readahead.c
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/mips/readahead.c (rev 0)
+++ trunk/uClibc/libc/sysdeps/linux/mips/readahead.c 2007-05-31 08:22:35 UTC (rev 18708)
@@ -0,0 +1,38 @@
+/* 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>
+
+#ifdef __NR_readahead
+
+ssize_t readahead(int fd, off64_t offset, size_t count)
+{
+# if _MIPS_SIM == _ABIO32
+ return INLINE_SYSCALL (readahead, 5, fd, 0,
+ __LONG_LONG_PAIR ((off_t) (offset >> 32), (off_t) offset),
+ count);
+# else /* N32 || N64 */
+ return INLINE_SYSCALL (readahead, 3, fd, offset, count);
+# endif
+}
+
+#endif
More information about the uClibc-cvs
mailing list