summaryrefslogtreecommitdiff
path: root/arch/mips/syscall_arch.h
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2019-09-26 19:14:36 -0400
committerRich Felker <dalias@aerifal.cx>2019-09-26 19:14:36 -0400
commit9f6dd78593e1d3b06f6e72f8479c91361e28ac28 (patch)
treeaa6fb50dd9eb2a74e0cf0c23bf00ef28765cfa07 /arch/mips/syscall_arch.h
parentb678f7b46a614ca8985b3ef662d96036e06e8810 (diff)
downloadmusl-9f6dd78593e1d3b06f6e72f8479c91361e28ac28.tar.gz
fix mips r6 syscall clobber lists not to include hi/lo registers
mips r6 (an incompatible isa from traditional mips) removes the hi and lo registers used for mul/div results. older gcc versions accepted them in the clobber list for asm, but their presence is incorrect and breaks on later versions. in the process of fixing this, the clobber list for 32-bit mips syscalls has been deduplicated via a macro like on mips64 and n32.
Diffstat (limited to 'arch/mips/syscall_arch.h')
-rw-r--r--arch/mips/syscall_arch.h34
1 files changed, 18 insertions, 16 deletions
diff --git a/arch/mips/syscall_arch.h b/arch/mips/syscall_arch.h
index 2ef8a952..808aa41d 100644
--- a/arch/mips/syscall_arch.h
+++ b/arch/mips/syscall_arch.h
@@ -5,6 +5,16 @@
#define SYSCALL_RLIM_INFINITY (-1UL/2)
+#if __mips_isa_rev >= 6
+#define SYSCALL_CLOBBERLIST \
+ "$1", "$3", "$11", "$12", "$13", \
+ "$14", "$15", "$24", "$25", "memory"
+#else
+#define SYSCALL_CLOBBERLIST \
+ "$1", "$3", "$11", "$12", "$13", \
+ "$14", "$15", "$24", "$25", "hi", "lo", "memory"
+#endif
+
static inline long __syscall0(long n)
{
register long r7 __asm__("$7");
@@ -12,8 +22,7 @@ static inline long __syscall0(long n)
__asm__ __volatile__ (
"addu $2,$0,%2 ; syscall"
: "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7)
- : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
- "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+ : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
return r7 ? -r2 : r2;
}
@@ -26,8 +35,7 @@ static inline long __syscall1(long n, long a)
"addu $2,$0,%2 ; syscall"
: "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
"r"(r4)
- : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
- "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+ : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
return r7 ? -r2 : r2;
}
@@ -41,8 +49,7 @@ static inline long __syscall2(long n, long a, long b)
"addu $2,$0,%2 ; syscall"
: "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
"r"(r4), "r"(r5)
- : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
- "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+ : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
return r7 ? -r2 : r2;
}
@@ -57,8 +64,7 @@ static inline long __syscall3(long n, long a, long b, long c)
"addu $2,$0,%2 ; syscall"
: "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
"r"(r4), "r"(r5), "r"(r6)
- : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
- "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+ : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
return r7 ? -r2 : r2;
}
@@ -73,8 +79,7 @@ static inline long __syscall4(long n, long a, long b, long c, long d)
"addu $2,$0,%2 ; syscall"
: "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
"r"(r4), "r"(r5), "r"(r6)
- : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
- "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+ : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
return r7 ? -r2 : r2;
}
@@ -92,8 +97,7 @@ static inline long __syscall5(long n, long a, long b, long c, long d, long e)
"addu $sp,$sp,32"
: "=&r"(r2), "=r"(r7), "+r"(r8)
: "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6)
- : "$1", "$3", "$9", "$10", "$11", "$12", "$13",
- "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+ : SYSCALL_CLOBBERLIST, "$9", "$10");
return r7 ? -r2 : r2;
}
@@ -112,8 +116,7 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
"addu $sp,$sp,32"
: "=&r"(r2), "=r"(r7), "+r"(r8), "+r"(r9)
: "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6)
- : "$1", "$3", "$10", "$11", "$12", "$13",
- "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+ : SYSCALL_CLOBBERLIST, "$10");
return r7 ? -r2 : r2;
}
@@ -133,8 +136,7 @@ static inline long __syscall7(long n, long a, long b, long c, long d, long e, lo
"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");
+ : SYSCALL_CLOBBERLIST);
return r7 ? -r2 : r2;
}