This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
RE: Bug in strlen on old MIPS CPUs
- From: "Steve Legg" <smlegg at googlemail dot com>
- To: <newlib at sourceware dot org>
- Date: Mon, 10 Jan 2011 10:44:00 -0000
- Subject: RE: Bug in strlen on old MIPS CPUs
- References: <000b01cba111$88f8bdf0$9aea39d0$@com> <20110110091936.GE7761@calimero.vinschen.de>
> 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.