fix broken posix_fadvise on mips due to missing 7-arg syscall support
authorRich Felker <dalias@aerifal.cx>
Sun, 5 May 2019 15:24:57 +0000 (11:24 -0400)
committerRich Felker <dalias@aerifal.cx>
Sun, 5 May 2019 15:24:57 +0000 (11:24 -0400)
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.

arch/mips/syscall_arch.h

index 3b33ce186b98c4da7220bf0a1e744451f0204e7c..43bcdee7af65da1b9f46bf255d7f173ce974ace4 100644 (file)
@@ -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"