aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/mips/mips64
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/mips/mips64')
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n32/syscall_types.h28
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/syscall_cancel.S108
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/sysdep.h52
3 files changed, 158 insertions, 30 deletions
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscall_types.h b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscall_types.h
new file mode 100644
index 0000000000..b3a8b0b634
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscall_types.h
@@ -0,0 +1,28 @@
+/* Types and macros used for syscall issuing. MIPS64n32 version.
+ Copyright (C) 2023 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/>. */
+
+#ifndef _SYSCALL_TYPES_H
+#define _SYSCALL_TYPES_H
+
+typedef long long int __syscall_arg_t;
+
+/* Convert X to a long long, without losing any bits if it is one
+ already or warning if it is a 32-bit pointer. */
+#define __SSC(__x) ((__syscall_arg_t) (__typeof__ ((__x) - (__x))) (__x))
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscall_cancel.S b/sysdeps/unix/sysv/linux/mips/mips64/syscall_cancel.S
new file mode 100644
index 0000000000..f172041324
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips64/syscall_cancel.S
@@ -0,0 +1,108 @@
+/* Cancellable syscall wrapper. Linux/mips64 version.
+ Copyright (C) 2023 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <sys/asm.h>
+#include <descr-const.h>
+
+/* long int __syscall_cancel_arch (int *cancelhandling,
+ __syscall_arg_t nr,
+ __syscall_arg_t arg1,
+ __syscall_arg_t arg2,
+ __syscall_arg_t arg3,
+ __syscall_arg_t arg4,
+ __syscall_arg_t arg5,
+ __syscall_arg_t arg6,
+ __syscall_arg_t arg7) */
+
+#define FRAME_SIZE 32
+
+ .text
+NESTED (__syscall_cancel_arch, FRAME_SIZE, ra)
+ .mask 0x90010000, -SZREG
+ .fmask 0x00000000, 0
+ LONG_ADDIU sp, sp, -FRAME_SIZE
+ cfi_def_cfa_offset (FRAME_SIZE)
+ sd gp, 16(sp)
+ cfi_offset (gp, -16)
+ lui gp, %hi(%neg(%gp_rel(__syscall_cancel_arch)))
+ LONG_ADDU gp, gp, t9
+ sd ra, 24(sp)
+ sd s0, 8(sp)
+ cfi_offset (ra, -8)
+ cfi_offset (s0, -24)
+ LONG_ADDIU gp, gp, %lo(%neg(%gp_rel(__syscall_cancel_arch)))
+
+ .global __syscall_cancel_arch_start
+__syscall_cancel_arch_start:
+
+ lw v0, 0(a0)
+ andi v0, v0, TCB_CANCELED_BITMASK
+ .set noreorder
+ .set nomacro
+ bne v0, zero, 2f
+ move s0, a1
+ .set macro
+ .set reorder
+
+ move a0, a2
+ move a1, a3
+ move a2, a4
+ move a3, a5
+ move a4, a6
+ move a5, a7
+
+ .set noreorder
+ move v0, s0
+ syscall
+ .set reorder
+
+ .global __syscall_cancel_arch_end
+__syscall_cancel_arch_end:
+
+ .set noreorder
+ .set nomacro
+ bnel a3, zero, 1f
+ SUBU v0, zero, v0
+ .set macro
+ .set reorder
+
+1:
+ ld ra, 24(sp)
+ ld gp, 16(sp)
+ ld s0, 8(sp)
+
+ .set noreorder
+ .set nomacro
+ jr ra
+ LONG_ADDIU sp, sp, FRAME_SIZE
+ .set macro
+ .set reorder
+
+ cfi_remember_state
+ cfi_def_cfa_offset (0)
+ cfi_restore (s0)
+ cfi_restore (gp)
+ cfi_restore (ra)
+ .align 3
+2:
+ cfi_restore_state
+ LONG_L t9, %got_disp(__syscall_do_cancel)(gp)
+ .reloc 3f, R_MIPS_JALR, __syscall_do_cancel
+3: jalr t9
+END (__syscall_cancel_arch)
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
index 0a1711dad2..0438bed23d 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
@@ -44,15 +44,7 @@
#undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
#define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
-#if _MIPS_SIM == _ABIN32
-/* Convert X to a long long, without losing any bits if it is one
- already or warning if it is a 32-bit pointer. */
-# define ARGIFY(X) ((long long int) (__typeof__ ((X) - (X))) (X))
-typedef long long int __syscall_arg_t;
-#else
-# define ARGIFY(X) ((long int) (X))
-typedef long int __syscall_arg_t;
-#endif
+#include <syscall_types.h>
/* Note that the original Linux syscall restart convention required the
instruction immediately preceding SYSCALL to initialize $v0 with the
@@ -120,7 +112,7 @@ typedef long int __syscall_arg_t;
long int _sys_result; \
\
{ \
- __syscall_arg_t _arg1 = ARGIFY (arg1); \
+ __syscall_arg_t _arg1 = __SSC (arg1); \
register __syscall_arg_t __s0 asm ("$16") __attribute__ ((unused))\
= (number); \
register __syscall_arg_t __v0 asm ("$2"); \
@@ -144,8 +136,8 @@ typedef long int __syscall_arg_t;
long int _sys_result; \
\
{ \
- __syscall_arg_t _arg1 = ARGIFY (arg1); \
- __syscall_arg_t _arg2 = ARGIFY (arg2); \
+ __syscall_arg_t _arg1 = __SSC (arg1); \
+ __syscall_arg_t _arg2 = __SSC (arg2); \
register __syscall_arg_t __s0 asm ("$16") __attribute__ ((unused))\
= (number); \
register __syscall_arg_t __v0 asm ("$2"); \
@@ -170,9 +162,9 @@ typedef long int __syscall_arg_t;
long int _sys_result; \
\
{ \
- __syscall_arg_t _arg1 = ARGIFY (arg1); \
- __syscall_arg_t _arg2 = ARGIFY (arg2); \
- __syscall_arg_t _arg3 = ARGIFY (arg3); \
+ __syscall_arg_t _arg1 = __SSC (arg1); \
+ __syscall_arg_t _arg2 = __SSC (arg2); \
+ __syscall_arg_t _arg3 = __SSC (arg3); \
register __syscall_arg_t __s0 asm ("$16") __attribute__ ((unused))\
= (number); \
register __syscall_arg_t __v0 asm ("$2"); \
@@ -199,10 +191,10 @@ typedef long int __syscall_arg_t;
long int _sys_result; \
\
{ \
- __syscall_arg_t _arg1 = ARGIFY (arg1); \
- __syscall_arg_t _arg2 = ARGIFY (arg2); \
- __syscall_arg_t _arg3 = ARGIFY (arg3); \
- __syscall_arg_t _arg4 = ARGIFY (arg4); \
+ __syscall_arg_t _arg1 = __SSC (arg1); \
+ __syscall_arg_t _arg2 = __SSC (arg2); \
+ __syscall_arg_t _arg3 = __SSC (arg3); \
+ __syscall_arg_t _arg4 = __SSC (arg4); \
register __syscall_arg_t __s0 asm ("$16") __attribute__ ((unused))\
= (number); \
register __syscall_arg_t __v0 asm ("$2"); \
@@ -229,11 +221,11 @@ typedef long int __syscall_arg_t;
long int _sys_result; \
\
{ \
- __syscall_arg_t _arg1 = ARGIFY (arg1); \
- __syscall_arg_t _arg2 = ARGIFY (arg2); \
- __syscall_arg_t _arg3 = ARGIFY (arg3); \
- __syscall_arg_t _arg4 = ARGIFY (arg4); \
- __syscall_arg_t _arg5 = ARGIFY (arg5); \
+ __syscall_arg_t _arg1 = __SSC (arg1); \
+ __syscall_arg_t _arg2 = __SSC (arg2); \
+ __syscall_arg_t _arg3 = __SSC (arg3); \
+ __syscall_arg_t _arg4 = __SSC (arg4); \
+ __syscall_arg_t _arg5 = __SSC (arg5); \
register __syscall_arg_t __s0 asm ("$16") __attribute__ ((unused))\
= (number); \
register __syscall_arg_t __v0 asm ("$2"); \
@@ -261,12 +253,12 @@ typedef long int __syscall_arg_t;
long int _sys_result; \
\
{ \
- __syscall_arg_t _arg1 = ARGIFY (arg1); \
- __syscall_arg_t _arg2 = ARGIFY (arg2); \
- __syscall_arg_t _arg3 = ARGIFY (arg3); \
- __syscall_arg_t _arg4 = ARGIFY (arg4); \
- __syscall_arg_t _arg5 = ARGIFY (arg5); \
- __syscall_arg_t _arg6 = ARGIFY (arg6); \
+ __syscall_arg_t _arg1 = __SSC (arg1); \
+ __syscall_arg_t _arg2 = __SSC (arg2); \
+ __syscall_arg_t _arg3 = __SSC (arg3); \
+ __syscall_arg_t _arg4 = __SSC (arg4); \
+ __syscall_arg_t _arg5 = __SSC (arg5); \
+ __syscall_arg_t _arg6 = __SSC (arg6); \
register __syscall_arg_t __s0 asm ("$16") __attribute__ ((unused))\
= (number); \
register __syscall_arg_t __v0 asm ("$2"); \