fix pread/pwrite syscall calling convention on sh
authorRich Felker <dalias@aerifal.cx>
Thu, 11 Aug 2016 22:36:46 +0000 (18:36 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 11 Aug 2016 22:36:46 +0000 (18:36 -0400)
despite sh not generally using register-pair alignment for 64-bit
syscall arguments, there are arch-specific versions of the syscall
entry points for pread and pwrite which include a dummy argument for
alignment before the 64-bit offset argument.

arch/sh/syscall_arch.h
src/internal/syscall.h
src/unistd/pread.c
src/unistd/pwrite.c

index f63675a81f15667264b5f9e5988c6ef501b16ff2..84758fe0a0bf946d4a57c020345c3df04d7a09c6 100644 (file)
@@ -2,6 +2,7 @@
 ((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
 ((union { long long ll; long l[2]; }){ .ll = x }).l[1]
 #define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x))
+#define __SYSCALL_LL_PRW(x) 0, __SYSCALL_LL_E((x))
 
 /* The extra OR instructions are to work around a hardware bug:
  * http://documentation.renesas.com/doc/products/mpumcu/tu/tnsh7456ae.pdf
index ff3cf53a8cbed53f1d05862e0ee9d56ae345a5e5..6d378a81982b66a251ae8e9b3d1610dc8624cfc4 100644 (file)
 #define SYSCALL_MMAP2_UNIT 4096ULL
 #endif
 
+#ifndef __SYSCALL_LL_PRW
+#define __SYSCALL_LL_PRW(x) __SYSCALL_LL_O(x)
+#endif
+
 #ifndef __scc
 #define __scc(X) ((long) (X))
 typedef long syscall_arg_t;
index 3d2799fdd49dfec3a2a4d2d5896b8ab06fef3f27..5483eb9d71f0f8172287cb95e975b8d151a45a5a 100644 (file)
@@ -4,7 +4,7 @@
 
 ssize_t pread(int fd, void *buf, size_t size, off_t ofs)
 {
-       return syscall_cp(SYS_pread, fd, buf, size, __SYSCALL_LL_O(ofs));
+       return syscall_cp(SYS_pread, fd, buf, size, __SYSCALL_LL_PRW(ofs));
 }
 
 LFS64(pread);
index bbe4c345dcbe4a5ca5eb15db0358d331301cb665..4bf3d7dfcdaa1171fab942005fee289a35cd59f8 100644 (file)
@@ -4,7 +4,7 @@
 
 ssize_t pwrite(int fd, const void *buf, size_t size, off_t ofs)
 {
-       return syscall_cp(SYS_pwrite, fd, buf, size, __SYSCALL_LL_O(ofs));
+       return syscall_cp(SYS_pwrite, fd, buf, size, __SYSCALL_LL_PRW(ofs));
 }
 
 LFS64(pwrite);