I was looking at a bug in my new memcpy in glibc & newlib and traced it
down to this code:

#if (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA == _MIPS_ISA_MIPS5) || \
    (_MIPS_ISA == _MIPS_ISA_MIPS32) || (_MIPS_ISA == _MIPS_ISA_MIPS64)

The problem is that GCC is defining _MIPS_ISA to something
(_MIPS_ISA_MIPS1 in this case) but it does not define _MIPS_ISA_MIPS1
or _MIPS_ISA_MIPS4 (or any other _MIPS_ISA_MIPS* macro) to anything.
So if _MIPS_ISA is defined to _MIPS_ISA_MIPS1, this if statement is
considered to be true because _MIPS_ISA expands to _MIPS_ISA_MIPS1 which
is expanded to nothing.  And since _MIPS_ISA_MIPS4 (or 5 or 32 or 64)
is also not defined they are expanded to nothing and we get a true
comparison when we did not want one.

For my memcpy code I am looking at checking to see if __mips is set to
4, 5, 32, or 64 instead of using this check but I was wondering if we
should change GCC in someway to make the _MIPS_ISA macro more useful.
Or should we just ignore this macro and get people to use __mips or one
of the other macros instead?

Steve Ellcey
steve.ell...@imgtec.com (Previously sell...@mips.com)


Reply via email to