b17ea5269dc07f22a6ebe7fed0c79a0eb56585e6
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / uclibc / 7bf35c8b7d4a1f97174eb49f47f33946b282114c / 0002-libc-posix_fadvise-Fix-build-breakage-for-LFS.patch
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
35 Patch status: sent upstream (http://patchwork.ozlabs.org/patch/308533/)
36
37 libc/sysdeps/linux/common/posix_fadvise.c | 30 ++++++++++++++++++++++++------
38  1 file changed, 24 insertions(+), 6 deletions(-)
39
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
44 @@ -22,17 +22,34 @@
45  # include <endian.h>
46  # include <bits/wordsize.h>
47  
48 -# ifdef __NR_fadvise64_64
49 -int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice);
50 -# endif
51 +# if defined(__NR_fadvise64_64) && defined(__UCLIBC_HAS_LFS__)
52 +#include <_lfs_64.h>
53  
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)
56  {
57 -# ifdef __NR_fadvise64_64
58         return posix_fadvise64(fd, offset, len, advice);
59 -# else
60 +}
61 +#else
62 +
63 +int posix_fadvise(int fd, off_t offset, off_t len, int advice)
64 +{
65         int ret;
66         INTERNAL_SYSCALL_DECL(err);
67 +
68 +# ifdef __NR_fadvise64_64
69 +#  if __WORDSIZE == 64
70 +       ret = INTERNAL_SYSCALL(fadvise64_64, err, 4, fd, offset, len, advice);
71 +#  else
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));
75 +#   else
76 +       ret = INTERNAL_SYSCALL(fadvise64_64, err, 6, fd,
77 +                       OFF_HI_LO (offset), OFF_HI_LO (len), advice);
78 +#   endif
79 +#  endif
80 +# else  /* __NR_fadvise64 */
81  #  if __WORDSIZE == 64
82         ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
83  #  else
84 @@ -43,12 +60,13 @@ int posix_fadvise(int fd, off_t offset, off_t len, int advice)
85  #   endif
86                         OFF_HI_LO (offset), len, advice);
87  #  endif
88 +#  endif
89         if (INTERNAL_SYSCALL_ERROR_P (ret, err))
90                 return INTERNAL_SYSCALL_ERRNO (ret, err);
91         return 0;
92 -#  endif
93  }
94  # if defined __UCLIBC_HAS_LFS__ && (!defined __NR_fadvise64_64 || __WORDSIZE == 64)
95  strong_alias(posix_fadvise,posix_fadvise64)
96  # endif
97  #endif
98 +#endif