This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: preprocessor: % as args to #defines
- From: espie at quatramaran dot ens dot fr (Marc Espie)
- To: pinskia at physics dot uc dot edu
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 14 Feb 2004 15:59:50 +0100 (CET)
- Subject: Re: preprocessor: % as args to #defines
- Organization:
- References: <200401291844.i0TIiDT05165@linsvr1.uk.superh.com> <87u12eh9kj.fsf@egil.codesourcery.com> <C381627E-528C-11D8-8CEA-0003931B8A28@apple.com>
Let's talk real-life, then.
Is theere any kind of standard for intrinsices on, say, i386 ?
Speaking from personal experience, the OpenBSD kernel uses inline
assembler to:
- do IO
- establish bufspace barriers (not sure if that's applicable to i386)
- change interrupt blocking level.
The interrupt level hadnling roughly looks like this:
volatile int cpl; /* Current interrupt priority level. */
volatile int ipending; /* Interrupts pending. */
volatile int astpending;/* Asynchronous software traps (softints) pending. */
static __inline int
splraise(ncpl)
int ncpl;
{
int ocpl = cpl;
if (ncpl > ocpl)
cpl = ncpl;
__asm __volatile("":::"memory");
return (ocpl);
}
note the asm volatile.
software interrupt registration uses asm too.
static __inline void
softintr(mask)
int mask;
{
__asm __volatile("orl %1, %0" : "=m"(ipending) : "ir" (mask));
}
can I now do this kind of thing in C entirely ? this is not code I know
well, btw...