Fresh pull from upstream
[librecmc/librecmc.git] / toolchain / musl / patches / 015-fix-pread-pwrite-syscall-calling-convention-on-sh.patch
1 From 7cc3a28eed7e3b72a1ce4568fb55154bb0540726 Mon Sep 17 00:00:00 2001
2 From: Rich Felker <dalias@aerifal.cx>
3 Date: Thu, 11 Aug 2016 18:36:46 -0400
4 Subject: fix pread/pwrite syscall calling convention on sh
5
6 despite sh not generally using register-pair alignment for 64-bit
7 syscall arguments, there are arch-specific versions of the syscall
8 entry points for pread and pwrite which include a dummy argument for
9 alignment before the 64-bit offset argument.
10 ---
11  arch/sh/syscall_arch.h | 1 +
12  src/internal/syscall.h | 4 ++++
13  src/unistd/pread.c     | 2 +-
14  src/unistd/pwrite.c    | 2 +-
15  4 files changed, 7 insertions(+), 2 deletions(-)
16
17 diff --git a/arch/sh/syscall_arch.h b/arch/sh/syscall_arch.h
18 index f63675a..84758fe 100644
19 --- a/arch/sh/syscall_arch.h
20 +++ b/arch/sh/syscall_arch.h
21 @@ -2,6 +2,7 @@
22  ((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
23  ((union { long long ll; long l[2]; }){ .ll = x }).l[1]
24  #define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x))
25 +#define __SYSCALL_LL_PRW(x) 0, __SYSCALL_LL_E((x))
26  
27  /* The extra OR instructions are to work around a hardware bug:
28   * http://documentation.renesas.com/doc/products/mpumcu/tu/tnsh7456ae.pdf
29 diff --git a/src/internal/syscall.h b/src/internal/syscall.h
30 index ff3cf53..6d378a8 100644
31 --- a/src/internal/syscall.h
32 +++ b/src/internal/syscall.h
33 @@ -12,6 +12,10 @@
34  #define SYSCALL_MMAP2_UNIT 4096ULL
35  #endif
36  
37 +#ifndef __SYSCALL_LL_PRW
38 +#define __SYSCALL_LL_PRW(x) __SYSCALL_LL_O(x)
39 +#endif
40 +
41  #ifndef __scc
42  #define __scc(X) ((long) (X))
43  typedef long syscall_arg_t;
44 diff --git a/src/unistd/pread.c b/src/unistd/pread.c
45 index 3d2799f..5483eb9 100644
46 --- a/src/unistd/pread.c
47 +++ b/src/unistd/pread.c
48 @@ -4,7 +4,7 @@
49  
50  ssize_t pread(int fd, void *buf, size_t size, off_t ofs)
51  {
52 -       return syscall_cp(SYS_pread, fd, buf, size, __SYSCALL_LL_O(ofs));
53 +       return syscall_cp(SYS_pread, fd, buf, size, __SYSCALL_LL_PRW(ofs));
54  }
55  
56  LFS64(pread);
57 diff --git a/src/unistd/pwrite.c b/src/unistd/pwrite.c
58 index bbe4c34..4bf3d7d 100644
59 --- a/src/unistd/pwrite.c
60 +++ b/src/unistd/pwrite.c
61 @@ -4,7 +4,7 @@
62  
63  ssize_t pwrite(int fd, const void *buf, size_t size, off_t ofs)
64  {
65 -       return syscall_cp(SYS_pwrite, fd, buf, size, __SYSCALL_LL_O(ofs));
66 +       return syscall_cp(SYS_pwrite, fd, buf, size, __SYSCALL_LL_PRW(ofs));
67  }
68  
69  LFS64(pwrite);
70 -- 
71 cgit v0.11.2