diff mbox

[5/6] h8300: Add new feature

Message ID 1431934327-1278-6-git-send-email-ysato@users.sourceforge.jp
State Superseded
Headers show

Commit Message

Yoshinori Sato May 18, 2015, 7:32 a.m. UTC
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 ldso/ldso/h8300/dl-sysdep.h                |  1 +
 libc/sysdeps/linux/h8300/posix_fadvise64.c | 60 ++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)
 create mode 100644 ldso/ldso/h8300/dl-sysdep.h
 create mode 100644 libc/sysdeps/linux/h8300/posix_fadvise64.c
diff mbox

Patch

diff --git a/ldso/ldso/h8300/dl-sysdep.h b/ldso/ldso/h8300/dl-sysdep.h
new file mode 100644
index 0000000..880d048
--- /dev/null
+++ b/ldso/ldso/h8300/dl-sysdep.h
@@ -0,0 +1 @@ 
+/* dl not supported */
diff --git a/libc/sysdeps/linux/h8300/posix_fadvise64.c b/libc/sysdeps/linux/h8300/posix_fadvise64.c
new file mode 100644
index 0000000..20ecca8
--- /dev/null
+++ b/libc/sysdeps/linux/h8300/posix_fadvise64.c
@@ -0,0 +1,60 @@ 
+/* vi: set sw=4 ts=4: */
+/*
+ * posix_fadvise64() for uClibc
+ * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@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__
+#ifdef __NR_fadvise64_64
+
+int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
+{
+	unsigned long offset_h, offset_l;
+	unsigned long len_h, len_l;
+	register unsigned int __asm__("er0") er0;
+	offset_h = ofsfet >> 32;
+	offset_l = offset & 0xffffffffUL;
+	len_h = len >> 32;
+	len_l = len & 0xffffffffUL;
+	__asm__ __volatile__ (
+		"mov.l %6, er5\n\t"
+		"mov.l %5, er4\n\t"
+		"mov.l %4, er3\n\t"
+		"mov.l %3, er2\n\t"
+		"mov.l %2, er1\n\t"
+		"mov.l %1, er0\n\t"
+		"mov.l %7, er6\n\t"
+		"trapa #0"
+		: "=r" (er0)
+		: "0" (__NR_posix_fadvice64) , "g" (fd), "g" (offset_h), "g" (offset_l),
+		  "g" (len_h), "g" (len_l), "g" (advice)
+		: "memory" );
+
+	if (er0 >= 0)
+		return 0;
+	else
+		return -er0;
+}
+#elif !defined __NR_fadvise64 && defined __UCLIBC_HAS_STUBS__
+/* This is declared as a strong alias in posix_fadvise.c if __NR_fadvise64
+ * is defined.
+ */
+int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
+{
+	return ENOSYS;
+}
+#endif /* __NR_fadvise64_64 */
+#endif /* __UCLIBC_HAS_LFS__ */