[PTACH] strchr broken on SPU with non 16byte aligned argument

Kazunori Asayama asayama@sm.sony.co.jp
Mon Dec 4 17:29:00 GMT 2006


Joel Sherrill <joel.sherrill@oarcorp.com> wrote:
> Kazunori Asayama wrote:
> > Andrew_Pinski@playstation.sony.com wrote:
> >   
> >>   I noticed that the GCC testcase gcc.c-torture/execute/string-opt-5.c
> >> is failing on the spu and was debugging it and it looks like strchr does 
> >> not handle correctly a non 16byte aligned agrument.
> >> Here is the reduced testcase which is failing:
> >>     
> >
> > Here is a patch to fix the problem.
> > But I'm worried that there may be similar problem to it...
> >
> >   
> Technically, shouldn't that unsigned int cast be a uintptr_t?

Yes, you are right in general, I think. But in this case, it was not a
reason why the function did not work correctly.

> 
> Any ideas whether other spu/str* code has similar pointer math which
> might be suspect?

Anyway, we should have and run tests against both of aligned and
unaligned inputs. If so, we would be able to avoid this bug. 

And I think that such tests are useful not only for SPU specific
implementations, but also for generic ones
(i.e. newlib/libc/string/*), because some of them also do 'special
processing' against unaligned inputs.

Thanks,
--
(ASAYAMA Kazunori
  (asayama@sm.sony.co.jp))
t



More information about the Newlib mailing list