Subject: Re: build aborts in regress/lib/libpthread/sem
To: None <port-dreamcast@netbsd.org>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: port-dreamcast
Date: 02/19/2003 23:00:48
In article <yf98yweoomr.fsf@mc.pp.se>
marcus@mc.pp.se wrote:

> One way to do it is like this:
> 
> #define G2_LOCK				\
>   do {					\
>     int _s = _cpu_intr_suspend();	\
>     WAIT_G2DMA
> 
> #define G2_UNLOCK			\
>     _cpu_intr_resume(_s);		\
>   } while(/*CONSTCOND*/0)
> 
> Not terribly pretty, but in this limited context I think it's ok, and
> it avoids unnecessary repetition.

Umm, but it doesn't work across other loops:
---
{
 G2_LOCK;
 for(;;) {
   :
  G2_UNLOCK;
   :
  G2_LOCK;
   :
 }
 G2_UNLOCK;
}
---

In article <20030217163411.GB21753@yeah-baby.shagadelic.org>
thorpej@wasabisystems.com wrote:

> Declare the temp variable in the function that uses LOCK/UNLOCK
> and pass the temp variable as an argument to the macros?

Or prepare one more macro to declare the temp variable?
---
#define G2LOCK_DECL int __s

#define G2_LOCK								\
	do {								\
		__s = _cpu_exception_suspend();				\
		/* suspend any G2 DMA here... */			\
		while((*(volatile unsigned int *)0xa05f688c) & 0x20);	\
	} while(/*CONSTCOND*/0)

#define G2_UNLOCK							\
	do {								\
		/* resume any G2 DMA here... */				\
		_cpu_exception_resume(__s);				\
	} while(/*CONSTCOND*/0)
---
Izumi Tsutsui
tsutsui@ceres.dti.ne.jp