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>
 
  34 libc/sysdeps/linux/common/posix_fadvise.c | 30 ++++++++++++++++++++++++------
 
  35  1 file changed, 24 insertions(+), 6 deletions(-)
 
  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
 
  43  # include <bits/wordsize.h>
 
  45 -# ifdef __NR_fadvise64_64
 
  46 -int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice);
 
  48 +# if defined(__NR_fadvise64_64) && defined(__UCLIBC_HAS_LFS__)
 
  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)
 
  54 -# ifdef __NR_fadvise64_64
 
  55         return posix_fadvise64(fd, offset, len, advice);
 
  60 +int posix_fadvise(int fd, off_t offset, off_t len, int advice)
 
  63         INTERNAL_SYSCALL_DECL(err);
 
  65 +# ifdef __NR_fadvise64_64
 
  66 +#  if __WORDSIZE == 64
 
  67 +       ret = INTERNAL_SYSCALL(fadvise64_64, err, 4, fd, offset, len, advice);
 
  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));
 
  73 +       ret = INTERNAL_SYSCALL(fadvise64_64, err, 6, fd,
 
  74 +                       OFF_HI_LO (offset), OFF_HI_LO (len), advice);
 
  77 +# else  /* __NR_fadvise64 */
 
  79         ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
 
  81 @@ -43,12 +60,13 @@ int posix_fadvise(int fd, off_t offset, off_t len, int advice)
 
  83                         OFF_HI_LO (offset), len, advice);
 
  86         if (INTERNAL_SYSCALL_ERROR_P (ret, err))
 
  87                 return INTERNAL_SYSCALL_ERRNO (ret, err);
 
  91  # if defined __UCLIBC_HAS_LFS__ && (!defined __NR_fadvise64_64 || __WORDSIZE == 64)
 
  92  strong_alias(posix_fadvise,posix_fadvise64)