Subject: Re: mc_cpuspeed() returns wrong value on gcc3
To: None <>
From: Paul Koning <>
List: port-pmax
Date: 04/29/2004 09:43:32
>>>>> "Izumi" == Izumi Tsutsui <> writes:

 Izumi> pmax (and maybe some other mips ports) use mc_cpuspeed() and
 Izumi> mips_mcclock_tickloop() in mips_mccloc.c to determine their
 Izumi> CPU clock, but after gcc3 import mips_mcclock_tickloop()
 Izumi> returns smaller values at least on DECstation 5000/125.

 Izumi> ...An easy fix is to remove one dummy nop from __asm lines, but I
 Izumi> guess such code should not depend on compiler and should be
 Izumi> written in asm.

Yes, such code should only be written in assembler.  It can't possibly
work reliably when written in a high level language.  (More precisely,
the timing loop must be in assembler.  The call entry/exit code could
be in C, that wouldn't affect the accuracy.)

Apart from that, the nop instructions should be ssnop, otherwise the
answer will be completely wrong for a superscalar machine.  Better
still would be to use CPU-specific code, because some CPU types have a
register that tells you the clock speed directly, so you don't have to
measure it.