summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2019-05-05 11:24:57 -0400
committerRich Felker <dalias@aerifal.cx>2019-05-05 11:24:57 -0400
commitd02e72ad51ea3b06cb168d872e3e5c126bb3df9d (patch)
tree03c0f5eb0b6244972f95756fb1ca09b683dae376
parentd7b583420bfc0897b6ccc90afb7e41333a221c09 (diff)
downloadmusl-d02e72ad51ea3b06cb168d872e3e5c126bb3df9d.tar.gz
fix broken posix_fadvise on mips due to missing 7-arg syscall support
commit 788d5e24ca19c6291cebd8d1ad5b5ed6abf42665 exposed the breakage at build time by removing support for 7-argument syscalls; however, the external __syscall function provided for mips before did not pass a 7th argument from the stack, so the behavior was just silently broken.
-rw-r--r--arch/mips/syscall_arch.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/arch/mips/syscall_arch.h b/arch/mips/syscall_arch.h
index 3b33ce18..43bcdee7 100644
--- a/arch/mips/syscall_arch.h
+++ b/arch/mips/syscall_arch.h
@@ -147,6 +147,31 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
return r2;
}
+static inline long __syscall7(long n, long a, long b, long c, long d, long e, long f, long g)
+{
+ register long r4 __asm__("$4") = a;
+ register long r5 __asm__("$5") = b;
+ register long r6 __asm__("$6") = c;
+ register long r7 __asm__("$7") = d;
+ register long r8 __asm__("$8") = e;
+ register long r9 __asm__("$9") = f;
+ register long r10 __asm__("$10") = g;
+ register long r2 __asm__("$2");
+ __asm__ __volatile__ (
+ "subu $sp,$sp,32 ; sw $8,16($sp) ; sw $9,20($sp) ; sw $10,24($sp) ; "
+ "addu $2,$0,%5 ; syscall ;"
+ "addu $sp,$sp,32"
+ : "=&r"(r2), "=r"(r7), "+r"(r8), "+r"(r9), "+r"(r10)
+ : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6)
+ : "$1", "$3", "$11", "$12", "$13",
+ "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+ if (r7) return -r2;
+ long ret = r2;
+ if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b);
+ if (n == SYS_fstatat64) __stat_fix(c);
+ return r2;
+}
+
#define VDSO_USEFUL
#define VDSO_CGT_SYM "__vdso_clock_gettime"
#define VDSO_CGT_VER "LINUX_2.6"