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]

RE: Bug in strlen on old MIPS CPUs


> Wouldn't it be better to add a nop, like this?
> 
> Index: libc/machine/mips/strlen.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/machine/mips/strlen.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 strlen.c
> --- libc/machine/mips/strlen.c	14 Mar 2002 02:41:43 -0000	1.2
> +++ libc/machine/mips/strlen.c	10 Jan 2011 09:19:11 -0000
> @@ -60,6 +60,9 @@ __asm__(""			/* 32-bit MIPS targets */
>  	"	addiu	$2,$4,1\n"
>  	"\n"
>  	"1:	lbu	$3,0($4)\n"
> +#ifdef (__R3000)
> +	"	nop	\n"
> +#endif
>  	"	bnez	$3,1b\n"
>  	"	addiu	$4,$4,1\n"
>  	"\n"

That works too - GCC generates exactly this code anyway (which is why I prefer just using the C version ;).  But yes, either patch will work (btw if someone you are committing this then it's definitely worth adding a check for __R2000 too because it would in theory have the exact same problem and GCC does support it so it's possible to build such a configuration).

Thanks,
Steve.



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