RFC: #pragma optimization_level
Georg Bauhaus
bauhaus@futureapps.de
Sat Apr 2 01:30:00 GMT 2005
Gabriel Dos Reis wrote:
>| void f() {
>| /*volatile*/ /*register*/ int i;
>|
>| for (i = 0; i < COUNT; ++i)
>| ;
>
>This must be an FAQ. The above is no way of (no matter how popular
>the urban legend makes it) implementing delay.
>
As a normative statement, a busy loop might not be the
way to implement delay. But the guys are working
with essentially a CPU and nothing else to help it.
No timers, no external clock, nothing.
So as a matter of fact, there is no choice but to use
a loop. The question they ask then is, can I instruct
the compiler to turn the above loop into a loop at
object code level, and can I say so in the source text,
visible to following programmer generations?
volatile might be a first step. However, a number
of gcc users will be more happy when they can
instruct the compiler to turn an empty C loop into
an object code loop using a register for counting.
I can't say what the proportion of gcc users is who
want this feature, but it isn't 0.0.
More information about the Gcc
mailing list