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

Joel Sherrill joel.sherrill@oarcorp.com
Mon Dec 4 05:53:00 GMT 2006


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?

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

--joel
> Thanks,
> --
> (ASAYAMA Kazunori
>   (asayama@sm.sony.co.jp))
> t
>
> Index: newlib/newlib/libc/machine/spu/strchr.c
> ===================================================================
> --- newlib.orig/newlib/libc/machine/spu/strchr.c
> +++ newlib/newlib/libc/machine/spu/strchr.c
> @@ -51,7 +51,7 @@ char *strchr(const char *s, int c)
>    ptr = (vec_uchar16 *)s;
>  
>    skip = (unsigned int)(ptr) & 15;
> -  mask = spu_rlmask(one, -skip);
> +  mask = spu_rlmask(one, -(skip + 16));
>  
>    vc = spu_splats((unsigned char)(c));
>  
>   



More information about the Newlib mailing list