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: preprocessor: % as args to #defines


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...


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