diff mbox series

[23/28] mips: Implement n32 lseek64 in C

Message ID 20201118195552.2687336-24-adhemerval.zanella@linaro.org
State New
Headers show
Series More Linux syscall refactor | expand

Commit Message

Adhemerval Zanella Nov. 18, 2020, 7:55 p.m. UTC
Checked on mips64-n32-linux-gnu.
---
 .../unix/sysv/linux/mips/mips64/n32/lseek64.c | 47 +++++++++++++++++++
 .../sysv/linux/mips/mips64/n32/syscalls.list  |  5 --
 2 files changed, 47 insertions(+), 5 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/lseek64.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/lseek64.c b/sysdeps/unix/sysv/linux/mips/mips64/n32/lseek64.c
new file mode 100644
index 0000000000..65cec75caf
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/lseek64.c
@@ -0,0 +1,47 @@ 
+/* Linux lseek implementation, 64 bits off_t.  MIPS64n32 version.
+   Copyright (C) 2020 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, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <sysdep.h>
+
+static inline off64_t
+__lseek64_syscall (long int name, int fd, off64_t offset, int whence)
+{
+  register __syscall_arg_t s0 asm ("$16") = name;
+  register __syscall_arg_t v0 asm ("$2");
+  register __syscall_arg_t a0 asm ("$4") = ARGIFY (fd);
+  register __syscall_arg_t a1 asm ("$5") = ARGIFY (offset);
+  register __syscall_arg_t a2 asm ("$6") = ARGIFY (whence);
+  register __syscall_arg_t a3 asm ("$7");
+  asm volatile (".set\tnoreorder\n\t"
+		MOVE32 "\t%0, %2\n\t"
+		"syscall\n\t"
+		".set reorder"
+		: "=r" (v0), "=r" (a3)
+		: "r" (s0), "r" (a0), "r" (a1), "r" (a2)
+		: __SYSCALL_CLOBBERS);
+  return a3 != 0
+	 ? SYSCALL_ERROR_LABEL (INTERNAL_SYSCALL_ERRNO (v0))
+         : v0;
+}
+
+#undef INLINE_SYSCALL_CALL
+#define INLINE_SYSCALL_CALL(name, ...) \
+  __lseek64_syscall(__NR_##name, __VA_ARGS__)
+
+#include <sysdeps/unix/sysv/linux/lseek64.c>
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
deleted file mode 100644
index 6f665635e0..0000000000
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
+++ /dev/null
@@ -1,5 +0,0 @@ 
-# File name	Caller	Syscall name	# args	Strong name	Weak names
-
-# C syscall macros cannot be used because this syscall has a 64-bit
-# return value.
-lseek64		-	lseek		i:iii	__lseek64	__libc_lseek64 lseek64@@GLIBC_2.2 llseek@GLIBC_2.0:GLIBC_2.28