fix posix_fadvise syscall args on powerpc, unify with arm fix
authorRich Felker <dalias@aerifal.cx>
Fri, 1 Jul 2016 17:32:35 +0000 (13:32 -0400)
committerRich Felker <dalias@aerifal.cx>
Fri, 1 Jul 2016 17:32:35 +0000 (13:32 -0400)
commit 6d38c9cf80f47623e5e48190046673bbd0dc410b provided an
arm-specific version of posix_fadvise to address the alternate
argument order the kernel expects on arm, but neglected to address
that powerpc (32-bit) has the same issue. instead of having arch
variant files in duplicate, simply put the alternate version in the
top-level file under the control of a macro defined in syscall_arch.h.

arch/arm/syscall_arch.h
arch/powerpc/syscall_arch.h
src/fcntl/arm/posix_fadvise.c [deleted file]
src/fcntl/posix_fadvise.c

index 64461ec8f5f819770584e07dfbe4a5a165bd3b83..6023303bfe82d01e9558ba6b89211e3c4f343a0d 100644 (file)
@@ -76,3 +76,5 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
 #define VDSO_USEFUL
 #define VDSO_CGT_SYM "__vdso_clock_gettime"
 #define VDSO_CGT_VER "LINUX_2.6"
+
+#define SYSCALL_FADVISE_6_ARG
index e7cb1a26d62505a7c27d3d0bab7bde3f986ea682..004060e6d6ede1274acb8b849eadb5458a37652f 100644 (file)
@@ -5,3 +5,5 @@
 
 #undef SYSCALL_NO_INLINE
 #define SYSCALL_NO_INLINE
+
+#define SYSCALL_FADVISE_6_ARG
diff --git a/src/fcntl/arm/posix_fadvise.c b/src/fcntl/arm/posix_fadvise.c
deleted file mode 100644 (file)
index 5c52f6b..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <fcntl.h>
-#include "syscall.h"
-#include "libc.h"
-
-int posix_fadvise(int fd, off_t base, off_t len, int advice)
-{
-       /* ARM-specific syscall argument order */
-       return -__syscall(SYS_fadvise, fd, advice,
-               __SYSCALL_LL_E(base), __SYSCALL_LL_E(len));
-}
-
-LFS64(posix_fadvise);
index fc1562e258902b82fbb7cee33a27b36942e2a0f9..c1a0ef5a2079dd0606e7e0166c622e52c2090628 100644 (file)
@@ -4,8 +4,16 @@
 
 int posix_fadvise(int fd, off_t base, off_t len, int advice)
 {
+#if defined(SYSCALL_FADVISE_6_ARG)
+       /* Some archs, at least arm and powerpc, have the syscall
+        * arguments reordered to avoid needing 7 argument registers
+        * due to 64-bit argument alignment. */
+       return -__syscall(SYS_fadvise, fd, advice,
+               __SYSCALL_LL_E(base), __SYSCALL_LL_E(len));
+#else
        return -__syscall(SYS_fadvise, fd, __SYSCALL_LL_O(base),
                __SYSCALL_LL_E(len), advice);
+#endif
 }
 
 LFS64(posix_fadvise);