41fec4490907ee1afc76a8a874628f5ecffd6ba7
[buildroot.git] /
1 From patchwork Thu Jan 9 09:35:45 2014
2 Content-Type: text/plain; charset="utf-8"
3 MIME-Version: 1.0
4 Content-Transfer-Encoding: 7bit
5 Subject: libc: posix_fadvise: Fix build breakage for !LFS
6 From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
7 X-Patchwork-Id: 308533
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
13
14 commit 00571b43df2e "libc: posix_fadvise: restore implementation for xtensa"
15 enabled posix_fadvise() for all arches (it was just not generated
16 before).
17
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
21 to break for !LFS.
22
23 Fix this by calling posix_fadvise64() only for LFS case and open-code
24 it's equivalent for !LFS.
25
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>
32
33 ---
34 libc/sysdeps/linux/common/posix_fadvise.c | 30 ++++++++++++++++++++++++------
35 1 file changed, 24 insertions(+), 6 deletions(-)
36
37 diff --git a/libc/sysdeps/linux/common/posix_fadvise.c b/libc/sysdeps/linux/common/posix_fadvise.c
38 index 25c294178e5e..14bbeeea13bc 100644
39 --- a/libc/sysdeps/linux/common/posix_fadvise.c
40 +++ b/libc/sysdeps/linux/common/posix_fadvise.c
41 @@ -22,17 +22,34 @@
42 # include <endian.h>
43 # include <bits/wordsize.h>
44
45 -# ifdef __NR_fadvise64_64
46 -int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice);
47 -# endif
48 +# if defined(__NR_fadvise64_64) && defined(__UCLIBC_HAS_LFS__)
49 +#include <_lfs_64.h>
50
51 +int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice);
52 int posix_fadvise(int fd, off_t offset, off_t len, int advice)
53 {
54 -# ifdef __NR_fadvise64_64
55 return posix_fadvise64(fd, offset, len, advice);
56 -# else
57 +}
58 +#else
59 +
60 +int posix_fadvise(int fd, off_t offset, off_t len, int advice)
61 +{
62 int ret;
63 INTERNAL_SYSCALL_DECL(err);
64 +
65 +# ifdef __NR_fadvise64_64
66 +# if __WORDSIZE == 64
67 + ret = INTERNAL_SYSCALL(fadvise64_64, err, 4, fd, offset, len, advice);
68 +# else
69 +# if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__) || defined(__arm__)
70 + ret = INTERNAL_SYSCALL(fadvise64_64, err, 6, fd, advice,
71 + OFF_HI_LO (offset), OFF_HI_LO (len));
72 +# else
73 + ret = INTERNAL_SYSCALL(fadvise64_64, err, 6, fd,
74 + OFF_HI_LO (offset), OFF_HI_LO (len), advice);
75 +# endif
76 +# endif
77 +# else /* __NR_fadvise64 */
78 # if __WORDSIZE == 64
79 ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
80 # else
81 @@ -43,12 +60,13 @@ int posix_fadvise(int fd, off_t offset, off_t len, int advice)
82 # endif
83 OFF_HI_LO (offset), len, advice);
84 # endif
85 +# endif
86 if (INTERNAL_SYSCALL_ERROR_P (ret, err))
87 return INTERNAL_SYSCALL_ERRNO (ret, err);
88 return 0;
89 -# endif
90 }
91 # if defined __UCLIBC_HAS_LFS__ && (!defined __NR_fadvise64_64 || __WORDSIZE == 64)
92 strong_alias(posix_fadvise,posix_fadvise64)
93 # endif
94 #endif
95 +#endif