avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] generic queue library for AVR GCC?


From: Richard Urwin
Subject: Re: [avr-gcc-list] generic queue library for AVR GCC?
Date: Tue, 16 Nov 2004 17:53:42 +0000
User-agent: KMail/1.5.3

On Tuesday 16 Nov 2004 9:36 am, David Brown wrote:
>     static inline unsigned char begin_critical_section(void) {
>         unsigned char s = SREG;
>         cli();
>         return s;
>     }
>

But you still have to declare a variable to hold the return value, and 
that was what broke the #define version.

Given an optimising compiler:

typedef enum {cs_start, cs_end} cs_enum;

static inline unsigned char critical_section(cs_enum dir)
{
        static unsigned char s;

 switch(dir)
 {
 case cs_start:
  s = SREG;
         cli();
  break;
 case cs_end:
  SREG = s;
 }
}

Not much bug protection there though.


-- 
Richard Urwin


reply via email to

[Prev in Thread] Current Thread [Next in Thread]