Re: [PATCH] posix_fadvise for ppc32

2008-10-06 Thread Bernhard Reutner-Fischer
On Sat, Oct 04, 2008 at 08:15:40AM +0200, Carmelo Amoroso wrote:
>Corinna Schultz wrote:
>> These changes are based on the glibc code that handles ppc32.  This
>> probably shouldn't be in the common dir, but I am unfamiliar with how
>> to add code into the arch-specific dir. I am also unsure about the
>> proper symbol to use in the #ifdef; however, this patch worked for us.
>> 
>> It was tested on ia32, and ppc32, and all LTP tests passed. I should  
>> note, that our ppc machine has INTERNAL_SYSCALL defined, so I don't  
>> believe the other code paths were tested.
>> 
>> Suggestions for improvements are welcome.
>> 
>> -Corinna Schultz
>> IBM LTC
>> 
>Hi Corinna,
>usually arch specific implementation will go in separate directory.
>We prefer avoid, whenever possible, adding multiple ifdef inside common code.
>May you kindly post the complete file for powerpc, so we can put it in the 
>right place.

Corinna, look at e.g. ioctl.c which has a powerpc specific "override".
___
uClibc mailing list
uClibc@uclibc.org
http://busybox.net/cgi-bin/mailman/listinfo/uclibc


Re: [PATCH] posix_fadvise for ppc32

2008-10-03 Thread Carmelo Amoroso
Corinna Schultz wrote:
> These changes are based on the glibc code that handles ppc32.  This
> probably shouldn't be in the common dir, but I am unfamiliar with how
> to add code into the arch-specific dir. I am also unsure about the
> proper symbol to use in the #ifdef; however, this patch worked for us.
> 
> It was tested on ia32, and ppc32, and all LTP tests passed. I should  
> note, that our ppc machine has INTERNAL_SYSCALL defined, so I don't  
> believe the other code paths were tested.
> 
> Suggestions for improvements are welcome.
> 
> -Corinna Schultz
> IBM LTC
> 
Hi Corinna,
usually arch specific implementation will go in separate directory.
We prefer avoid, whenever possible, adding multiple ifdef inside common code.
May you kindly post the complete file for powerpc, so we can put it in the 
right place.

TIA,
Carmelo

> 
> This patch fixes posix_fadvise[64] function for ppc32, to send  
> arguments of the proper size and in the proper order.
> 
> Signed-off-by: Corinna Schultz <[EMAIL PROTECTED]>
> 
> diff -ruN orig/posix_fadvise64.c new/posix_fadvise64.c
> --- uClibc.orig/libc/sysdeps/linux/common/posix_fadvise64.c  
> 2008-10-03 13:08:21.589048507 -0500
> +++ uClibc.new/libc/sysdeps/linux/common/posix_fadvise64.c   
> 2008-10-03 13:11:52.697012758 -0500
> @@ -56,30 +56,48 @@
>   /* 32 bit implementation is kind of a pita */
>   #elif __WORDSIZE == 32
> 
> -#if defined INTERNAL_SYSCALL && ! defined __TARGET_powerpc__
> +#if defined INTERNAL_SYSCALL
>   int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
>   {
>  INTERNAL_SYSCALL_DECL (err);
> +#ifdef __powerpc__
> +   int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advice,
> +   __LONG_LONG_PAIR(offset >> 32, offset &  0x),
> +   __LONG_LONG_PAIR(len >> 32, len & 0x));
> +#else
>  int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd,
>   
> __LONG_LONG_PAIR(offset >> 32, offset &  0x),
>   
> __LONG_LONG_PAIR(len >> 32, len & 0x),
> -   advice);
> +#endif advice);
>  if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
>  return 0;
>  return INTERNAL_SYSCALL_ERRNO (ret, err);
>   }
>   #elif defined _syscall6 /* workaround until everyone has _syscall6() */
>   #define __NR___syscall_fadvise64_64 __NR_fadvise64_64
> +
> +#ifdef __powerpc__
> +static __inline__ _syscall6(int, __syscall_fadvise64_64, int, fd,
> +  int, advice, unsigned long, high_offset, unsigned long, low_offset,
> +  unsigned long, high_len, unsigned long, low_len);
> +#else
>   static __inline__ _syscall6(int, __syscall_fadvise64_64, int, fd,
> unsigned long, high_offset, unsigned long, low_offset,
> unsigned long, high_len, unsigned long, low_len,
> int, advice);
> +#endif
>   int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
>   {
> +#ifdef __powerpc__
> +   int ret = __syscall_fadvise64_64(fd, advice,
> +   __LONG_LONG_PAIR(offset >> 32, offset &  0x),
> +   __LONG_LONG_PAIR(len >> 32, len & 0x));
> +#else
>  int ret = __syscall_fadvise64_64(fd,
>  __LONG_LONG_PAIR(offset >> 32, offset &  0x),
>  __LONG_LONG_PAIR(len >> 32, len & 0x),
>  advice);
> +#endif
>  if (ret == -1)
>  return errno;
>  return ret;
> diff -ruN orig/posix_fadvise.c new/posix_fadvise.c
> --- uClibc.orig/libc/sysdeps/linux/common/posix_fadvise.c
> 2008-10-03 13:15:54.991477654 -0500
> +++ uClibc.new/libc/sysdeps/linux/common/posix_fadvise.c 
> 2008-10-03 13:15:32.929049499 -0500
> @@ -26,21 +26,37 @@
>   int posix_fadvise(int fd, off_t offset, off_t len, int advice)
>   {
>  INTERNAL_SYSCALL_DECL(err);
> +#ifdef __powerpc__
> +int ret = (int) (INTERNAL_SYSCALL(posix_fadvise, err, 6, fd, 0,
> +__LONG_LONG_PAIR (offset >> 31, offset), len, advice));
> +#else
>  int ret = (int) (INTERNAL_SYSCALL(posix_fadvise, err, 5, fd,
>   __LONG_LONG_PAIR (offset >> 31, offset), len, advice));
> +#endif
>   if (INTERNAL_SYSCALL_ERROR_P (ret, err))
> return INTERNAL_SYSCALL_ERRNO (ret, err);
>   return 0;
>   }
>   #else
> -static __inline__ int syscall_posix_fadvise(int fd, off_t offset1,  
> off_t offset2, off_t len, int advice);
>   #define __NR_syscall_posix_fadvise __NR_fadvise64
> ++
> ++#ifdef __powerpc__
> ++static __inline__ int syscall_posix_fadvise(int fd, int unused,  
> off_t offset1, off_t offset2, off_t len, int advice);
> ++_syscall6(int, syscall_posix_fadvise, int, fd, int, unused, off_t, offset1,
> ++  off_t, offset2, off_t, len, int, 

[PATCH] posix_fadvise for ppc32

2008-10-03 Thread Corinna Schultz
These changes are based on the glibc code that handles ppc32.  This
probably shouldn't be in the common dir, but I am unfamiliar with how
to add code into the arch-specific dir. I am also unsure about the
proper symbol to use in the #ifdef; however, this patch worked for us.

It was tested on ia32, and ppc32, and all LTP tests passed. I should  
note, that our ppc machine has INTERNAL_SYSCALL defined, so I don't  
believe the other code paths were tested.

Suggestions for improvements are welcome.

-Corinna Schultz
IBM LTC


This patch fixes posix_fadvise[64] function for ppc32, to send  
arguments of the proper size and in the proper order.

Signed-off-by: Corinna Schultz <[EMAIL PROTECTED]>

diff -ruN orig/posix_fadvise64.c new/posix_fadvise64.c
--- uClibc.orig/libc/sysdeps/linux/common/posix_fadvise64.c  
2008-10-03 13:08:21.589048507 -0500
+++ uClibc.new/libc/sysdeps/linux/common/posix_fadvise64.c   
2008-10-03 13:11:52.697012758 -0500
@@ -56,30 +56,48 @@
  /* 32 bit implementation is kind of a pita */
  #elif __WORDSIZE == 32

-#if defined INTERNAL_SYSCALL && ! defined __TARGET_powerpc__
+#if defined INTERNAL_SYSCALL
  int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
  {
 INTERNAL_SYSCALL_DECL (err);
+#ifdef __powerpc__
+   int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advice,
+   __LONG_LONG_PAIR(offset >> 32, offset &  0x),
+   __LONG_LONG_PAIR(len >> 32, len & 0x));
+#else
 int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd,
  
__LONG_LONG_PAIR(offset >> 32, offset &  0x),
  
__LONG_LONG_PAIR(len >> 32, len & 0x),
-   advice);
+#endif advice);
 if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
 return 0;
 return INTERNAL_SYSCALL_ERRNO (ret, err);
  }
  #elif defined _syscall6 /* workaround until everyone has _syscall6() */
  #define __NR___syscall_fadvise64_64 __NR_fadvise64_64
+
+#ifdef __powerpc__
+static __inline__ _syscall6(int, __syscall_fadvise64_64, int, fd,
+  int, advice, unsigned long, high_offset, unsigned long, low_offset,
+  unsigned long, high_len, unsigned long, low_len);
+#else
  static __inline__ _syscall6(int, __syscall_fadvise64_64, int, fd,
unsigned long, high_offset, unsigned long, low_offset,
unsigned long, high_len, unsigned long, low_len,
int, advice);
+#endif
  int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
  {
+#ifdef __powerpc__
+   int ret = __syscall_fadvise64_64(fd, advice,
+   __LONG_LONG_PAIR(offset >> 32, offset &  0x),
+   __LONG_LONG_PAIR(len >> 32, len & 0x));
+#else
 int ret = __syscall_fadvise64_64(fd,
 __LONG_LONG_PAIR(offset >> 32, offset &  0x),
 __LONG_LONG_PAIR(len >> 32, len & 0x),
 advice);
+#endif
 if (ret == -1)
 return errno;
 return ret;
diff -ruN orig/posix_fadvise.c new/posix_fadvise.c
--- uClibc.orig/libc/sysdeps/linux/common/posix_fadvise.c
2008-10-03 13:15:54.991477654 -0500
+++ uClibc.new/libc/sysdeps/linux/common/posix_fadvise.c 
2008-10-03 13:15:32.929049499 -0500
@@ -26,21 +26,37 @@
  int posix_fadvise(int fd, off_t offset, off_t len, int advice)
  {
 INTERNAL_SYSCALL_DECL(err);
+#ifdef __powerpc__
+int ret = (int) (INTERNAL_SYSCALL(posix_fadvise, err, 6, fd, 0,
+__LONG_LONG_PAIR (offset >> 31, offset), len, advice));
+#else
 int ret = (int) (INTERNAL_SYSCALL(posix_fadvise, err, 5, fd,
  __LONG_LONG_PAIR (offset >> 31, offset), len, advice));
+#endif
  if (INTERNAL_SYSCALL_ERROR_P (ret, err))
return INTERNAL_SYSCALL_ERRNO (ret, err);
  return 0;
  }
  #else
-static __inline__ int syscall_posix_fadvise(int fd, off_t offset1,  
off_t offset2, off_t len, int advice);
  #define __NR_syscall_posix_fadvise __NR_fadvise64
++
++#ifdef __powerpc__
++static __inline__ int syscall_posix_fadvise(int fd, int unused,  
off_t offset1, off_t offset2, off_t len, int advice);
++_syscall6(int, syscall_posix_fadvise, int, fd, int, unused, off_t, offset1,
++  off_t, offset2, off_t, len, int, advice);
++#else
++static __inline__ int syscall_posix_fadvise(int fd, off_t offset1,  
off_t offset2, off_t len, int advice);
  _syscall5(int, syscall_posix_fadvise, int, fd, off_t, offset1,
off_t, offset2, off_t, len, int, advice);
+#endif

  int posix_fadvise(int fd, off_t offset, off_t len, int advice)
  {
+#ifdef __powerpc__
++   int ret = syscall_posix_fadvise(fd, 0, __LONG_LONG_PAIR  
(offset >> 31, offset), len, advice);
++#else
 int ret = syscall_posix_fadvise(fd,