1 From patchwork Thu Jan 9 09:35:45 2014
2 Content-Type: text/plain; charset="utf-8"
4 Content-Transfer-Encoding: 7bit
5 Subject: libc: posix_fadvise: Fix build breakage for !LFS
6 From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
8 Message-Id: <1389260145-8810-1-git-send-email-vgupta@synopsys.com>
9 To: <uclibc@uclibc.org>
10 Cc: Francois.Bedard@synopsys.com, Vineet Gupta <Vineet.Gupta1@synopsys.com>,
11 markos Chandras <markos.chandras@gmail.com>
12 Date: Thu, 9 Jan 2014 15:05:45 +0530
14 commit 00571b43df2e "libc: posix_fadvise: restore implementation for xtensa"
15 enabled posix_fadvise() for all arches (it was just not generated
18 However this also unearthed an issue introduced by ee84b8b400
19 "linux: posix_fadvise: use new SYSCALL_ALIGN_64BIT" which is to
20 referencing LFS'ish code (off64_t) w/o proper checks which causes build
23 Fix this by calling posix_fadvise64() only for LFS case and open-code
24 it's equivalent for !LFS.
26 Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
27 Cc: Mike Frysinger <vapier@gentoo.org>
28 Cc: Baruch Siach <baruch@tkos.co.il>
29 Cc: Khem Raj <raj.khem@gmail.com>
30 Cc: markos Chandras <markos.chandras@gmail.com>
31 Cc: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
35 Patch status: sent upstream (http://patchwork.ozlabs.org/patch/308533/)
37 libc/sysdeps/linux/common/posix_fadvise.c | 30 ++++++++++++++++++++++++------
38 1 file changed, 24 insertions(+), 6 deletions(-)
40 diff --git a/libc/sysdeps/linux/common/posix_fadvise.c b/libc/sysdeps/linux/common/posix_fadvise.c
41 index 25c294178e5e..14bbeeea13bc 100644
42 --- a/libc/sysdeps/linux/common/posix_fadvise.c
43 +++ b/libc/sysdeps/linux/common/posix_fadvise.c
46 # include <bits/wordsize.h>
48 -# ifdef __NR_fadvise64_64
49 -int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice);
51 +# if defined(__NR_fadvise64_64) && defined(__UCLIBC_HAS_LFS__)
54 +int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice);
55 int posix_fadvise(int fd, off_t offset, off_t len, int advice)
57 -# ifdef __NR_fadvise64_64
58 return posix_fadvise64(fd, offset, len, advice);
63 +int posix_fadvise(int fd, off_t offset, off_t len, int advice)
66 INTERNAL_SYSCALL_DECL(err);
68 +# ifdef __NR_fadvise64_64
69 +# if __WORDSIZE == 64
70 + ret = INTERNAL_SYSCALL(fadvise64_64, err, 4, fd, offset, len, advice);
72 +# if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__) || defined(__arm__)
73 + ret = INTERNAL_SYSCALL(fadvise64_64, err, 6, fd, advice,
74 + OFF_HI_LO (offset), OFF_HI_LO (len));
76 + ret = INTERNAL_SYSCALL(fadvise64_64, err, 6, fd,
77 + OFF_HI_LO (offset), OFF_HI_LO (len), advice);
80 +# else /* __NR_fadvise64 */
82 ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
84 @@ -43,12 +60,13 @@ int posix_fadvise(int fd, off_t offset, off_t len, int advice)
86 OFF_HI_LO (offset), len, advice);
89 if (INTERNAL_SYSCALL_ERROR_P (ret, err))
90 return INTERNAL_SYSCALL_ERRNO (ret, err);
94 # if defined __UCLIBC_HAS_LFS__ && (!defined __NR_fadvise64_64 || __WORDSIZE == 64)
95 strong_alias(posix_fadvise,posix_fadvise64)