This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] SPU compile


Hi,

the attached patch fixes a compile problem on the SPU if newlib gets compiled 
with GCC 4.3 and avoids a few warnings produced by SPU code. Ok to apply?

Regards
Ken

libgloss/ChangeLog:

2008-09-10  Ken Werner  <ken.werner@de.ibm.com>
        * spu/dirfuncs.c: Avoid warnings.
        * spu/kill.c: Likewise.


newlib/ChangeLog:

2008-09-10  Ken Werner  <ken.werner@de.ibm.com>

        * libc/machine/spu/strcpy.h: Add missing header.
        * libc/machine/spu/spu_timer_slih.c: Remove unused Variable.
        * libm/machine/spu/headers/lgammaf4.h: Add type cast.

Index: src/libgloss/spu/dirfuncs.c
===================================================================
--- src.orig/libgloss/spu/dirfuncs.c
+++ src/libgloss/spu/dirfuncs.c
@@ -56,22 +56,30 @@ typedef struct {
   unsigned int pad0[3];
 } syscall_opendir_t;
 
+typedef struct {
+  uint64_t dir;
+  unsigned int pad0[2];
+} syscall_opendir_ret_t;
+
 DIR *
 opendir (const char *name)
 {
   DIR *dir;
-  int ppc_dir, i;
-  syscall_opendir_t sys;
+  int i;
+  union {
+    syscall_opendir_t sys;
+    syscall_opendir_ret_t ret;
+  } u;
 
-  sys.name = (unsigned int) name;
+  u.sys.name = (unsigned int) name;
   for (i = 0; i < SPE_OPENDIR_MAX; i++) {
     if (!spe_dir[i].ppc_dir) {
       dir = &spe_dir[i];
-      __send_to_ppe (JSRE_POSIX1_SIGNALCODE, JSRE_OPENDIR, &sys);
+      __send_to_ppe (JSRE_POSIX1_SIGNALCODE, JSRE_OPENDIR, &u);
       /*
        * Pull 64 bits out of the result.
        */
-      dir->ppc_dir = ((uint64_t*)&sys)[0];
+      dir->ppc_dir = u.ret.dir;
       if (!dir->ppc_dir) {
         dir = NULL;
       }
@@ -163,5 +171,5 @@ telldir (DIR *dir)
 {
   uint64_t ppc_dir = dir->ppc_dir;
 
-  __send_to_ppe (JSRE_POSIX1_SIGNALCODE, JSRE_TELLDIR, &ppc_dir);
+  return __send_to_ppe (JSRE_POSIX1_SIGNALCODE, JSRE_TELLDIR, &ppc_dir);
 }
Index: src/libgloss/spu/kill.c
===================================================================
--- src.orig/libgloss/spu/kill.c
+++ src/libgloss/spu/kill.c
@@ -31,6 +31,7 @@ Author: Andreas Neukoetter (ti95neuk@de.
 */
 
 #include <unistd.h>
+#include <errno.h>
 
 int
 kill (int pid, int sig)
@@ -39,5 +40,7 @@ kill (int pid, int sig)
 	  {
 		  _exit (sig);
 	  }
+	errno = ESRCH;
+	return -1;
 }
 
Index: src/newlib/libc/machine/spu/strcpy.h
===================================================================
--- src.orig/newlib/libc/machine/spu/strcpy.h
+++ src/newlib/libc/machine/spu/strcpy.h
@@ -30,6 +30,7 @@
 
 #include <spu_intrinsics.h>
 #include "vec_literal.h"
+#include <string.h>
 
 /*
  * Supply an inline _strncpy for strcpy/cat and strncpy/cat. Relies on
Index: src/newlib/libc/machine/spu/spu_timer_slih.c
===================================================================
--- src.orig/newlib/libc/machine/spu/spu_timer_slih.c
+++ src/newlib/libc/machine/spu/spu_timer_slih.c
@@ -55,7 +55,7 @@ __reset_spu_decr (int val)
      value is the current timeout value minus the current decrementer value.
      Occasionally the read returns 0 - a second read will clear this
      condition.  */
-  int decval0 = spu_readch (SPU_RdDec);
+  spu_readch (SPU_RdDec);
   int decval = spu_readch (SPU_RdDec);
   /* Restart decrementer with next timeout val.  */
   __enable_spu_decr (enable_val, mask);
Index: src/newlib/libm/machine/spu/headers/lgammaf4.h
===================================================================
--- src.orig/newlib/libm/machine/spu/headers/lgammaf4.h
+++ src/newlib/libm/machine/spu/headers/lgammaf4.h
@@ -426,7 +426,7 @@
   vec_float4 xappr = spu_sub(xabs, xoffset);

   /* If in Stirling partition, do some setup before the madds */
-  xappr = spu_sel(xappr, inv_xsqu, gt_r7start);
+  xappr = spu_sel(xappr, inv_xsqu, (vector unsigned int)gt_r7start);



@@ -463,13 +463,13 @@
    */

   /* Finish the Near 0 formula */
-  result = spu_sel(spu_sub(result, ln_x), result, gt_r1start);
+  result = spu_sel(spu_sub(result, ln_x), result, (vector unsigned int)gt_r1start);

   /* Finish Stirling's Approximation */
   vec_float4 resultstirling = spu_madd(spu_sub(xabs, spu_splats(0.5f)), ln_x, halflog2pi);
   resultstirling = spu_sub(resultstirling, xabs);
   resultstirling = spu_add(spu_mul(result,inv_x), resultstirling);
-  result = spu_sel(result, resultstirling, gt_r7start);
+  result = spu_sel(result, resultstirling, (vector unsigned int)gt_r7start);


   /* Adjust due to systematic truncation */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]