Bug in strlen on old MIPS CPUs

Steve Legg smlegg@googlemail.com
Wed Dec 29 17:49:00 GMT 2010

> but: is there a #define that can be checked to see if the CPU is

It appears that GCC defines __R3000, so this would be a safe patch.  The
same issue would happen on R2000, so possibly add || defined(__R2000) too,
but it's probably unlikely that anyone will ever compile newlib on such a
machine (if any still exist that aren't in museums or landfills ;).

--- newlib-1.18.0.orig//newlib/libc/machine/mips/strlen.c	2002-03-14
02:41:43 +0000
+++ newlib-1.18.0//newlib/libc/machine/mips/strlen.c	2010-12-21 05:22:00
@@ -20,7 +20,7 @@
 /* MIPS16 needs to come first.  */
-#if defined(__mips16)
+#if defined(__mips16) || defined(__R3000)
 strlen (const char *str)

More information about the Newlib mailing list