This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: #pragma optimization_level


>>>>> "Joe" == Joe Buck <Joe.Buck@synopsys.COM> writes:

 Joe> Georg Bauhaus <bauhaus@futureapps.de> writes:
 >> | A busy-loop function is used to effect a delay, not too precise,
 >> | but portably. Like
 >> | 
 >> | #define COUNT 1000
 >> | 
 >> | void f() { | /*volatile*/ /*register*/ int i;
 >> | 
 >> | for (i = 0; i < COUNT; ++i)
 >> |           ;

 Joe> On Sat, Apr 02, 2005 at 01:48:56AM +0200, Gabriel Dos Reis
 Joe> wrote:
 >> This must be an FAQ.  The above is no way of (no matter how
 >> popular the urban legend makes it) implementing delay.  Adding a
 >> #pragma just makes teh situation worse.

 Joe> Unfortunately, where there is a good argument for not using
 Joe> empty loops as busy-waits, at one time it was documented GCC
 Joe> behavior that it would work, so we can't really blame the users
 Joe> for trusting the doc.

Would this work:

      for (i=0; i < foo; i++)
	  asm volatile ("");

Or perhaps with  asm volatile ("":::"memory") instead?

   paul


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]