Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: busy loop

Re: busy loop

From: pouly amaury <amaury.pouly_at_gmail.com>
Date: Tue, 15 Jun 2010 19:42:47 +0200

2010/6/15 Edgar Toernig <froese_at_gmx.de>

> pouly amaury wrote:
> >
> > for (x = (unsigned)(FREQ>>22); x; x--)
> > asm volatile("":::"memory");
> >
> > Clobbering memory is likely to prevent gcc from optimizing the loop away.
>
> But it will break with loop-unrolling (i.e. -O3). x times nothing
> is nothing ;-) You *have* to use a nop-instruction.
>
> And the cast is bogus - only silences the compiler without fixing
> the problem.
>
> Ciao, ET.
>

Tell me if I'm wrong but the compiler can hardly unroll a loop with a
non-constant size. As FREQ is a define for cpu_frequency which has external
linkage. The cast was there before, I didn't modify it.
But anyway, rewriting it in assembly is cleary the safe way :)
Received on 2010-06-15


Page was last modified "Jan 10 2012" The Rockbox Crew
aaa