Subject: Re: Should PR 18434 be closed?
To: None <tech-kern@netbsd.org>
From: Naoto Shimazaki <igy@arhc.org>
List: tech-kern
Date: 04/07/2003 22:01:36
At Mon, 7 Apr 2003 06:30:32 -0400 (EDT),
der Mouse wrote:
> 
> > The reason why wi.c couldn't compile is that DELAY() macro on hpcmips
> > was defined as a block like below and wi.c used DELAY() as a
> > expression.
> 
> > from sys/arch/hpcmips/include/param.h
> > #define DELAY(n)	{ register int N = cpuspeed * (n); while (--N > 0); }
> 
> > It is easy to modify DELAY() to:
> > #define DELAY(n)	do {	\
> > 		register int N = cpuspeed * (n); while (--N > 0);	\
> > 	} while (/*CONSTCONT*/ 0)
> 
> That won't help; the result is still a statement, not an expression,
> and thus can't be used in the repeat-clause of a for() loop.

Yes, you are right.  "Wrapping a do-while" is not a solution.
That is my mistake sorry.

> If you're willing to depend on gcc, you could write it as
> 
> #define DELAY(n) ({ register int N = cpuspeed * (n); while (--N > 0); })
> 
> but that's not C.

Hmm... IMHO, I don't prefer it....

--
Naoto Shimazaki