authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-07-18 11:43:39-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-07-18 11:43:39-04:00
log04ce5376a8ba030249765779d5dcda0770445979
tree445433b21feb3959adacfd138c81f04401464760
parentaaa4bf75d386058d6aca8c4db7244c51c27ce386
signaturelock-open Commit is signed but in an unrecognized format.

carry some upstream patches to musl to fix riscv inline asm

Upstream commits: * 8eb49e0485fc547eead9e47200bbee6d81f391c1 * 2dcbeabd917e404a0dde0195388da401b849b9a4 * f0eb2e77b2132a88e2f00d8e06ffa7638c40b4bc These will be in the next version of musl, so no harm carrying them here.

2 files changed, 13 insertions(+), 9 deletions(-)

lib/libc/musl/arch/riscv64/atomic_arch.h+12-8
......@@ -8,13 +8,15 @@ static inline void a_barrier()
88static inline int a_cas(volatile int *p, int t, int s)
99{
1010 int old, tmp;
11 __asm__("\n1: lr.w.aqrl %0, %2\n"
11 __asm__ __volatile__ (
12 "\n1: lr.w.aqrl %0, (%2)\n"
1213 " bne %0, %3, 1f\n"
13 " sc.w.aqrl %1, %4, %2\n"
14 " sc.w.aqrl %1, %4, (%2)\n"
1415 " bnez %1, 1b\n"
1516 "1:"
16 : "=&r"(old), "+r"(tmp), "+A"(*p)
17 : "r"(t), "r"(s));
17 : "=&r"(old), "=r"(tmp)
18 : "r"(p), "r"(t), "r"(s)
19 : "memory");
1820 return old;
1921}
2022
......@@ -23,12 +25,14 @@ static inline void *a_cas_p(volatile void *p, void *t, void *s)
2325{
2426 void *old;
2527 int tmp;
26 __asm__("\n1: lr.d.aqrl %0, %2\n"
28 __asm__ __volatile__ (
29 "\n1: lr.d.aqrl %0, (%2)\n"
2730 " bne %0, %3, 1f\n"
28 " sc.d.aqrl %1, %4, %2\n"
31 " sc.d.aqrl %1, %4, (%2)\n"
2932 " bnez %1, 1b\n"
3033 "1:"
31 : "=&r"(old), "+r"(tmp), "+A"(*(long *)p)
32 : "r"(t), "r"(s));
34 : "=&r"(old), "=r"(tmp)
35 : "r"(p), "r"(t), "r"(s)
36 : "memory");
3337 return old;
3438}
lib/libc/musl/arch/riscv64/syscall_arch.h+1-1
......@@ -3,7 +3,7 @@
33
44#define __asm_syscall(...) \
55 __asm__ __volatile__ ("ecall\n\t" \
6 : "+r"(a0) : __VA_ARGS__ : "memory"); \
6 : "=r"(a0) : __VA_ARGS__ : "memory"); \
77 return a0; \
88
99static inline long __syscall0(long n)