[Top][All Lists]

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

Re: [avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is f

From: Dmitry K.
Subject: Re: [avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is faulty
Date: Tue, 27 Sep 2005 14:03:46 +1100
User-agent: KMail/1.5

On Tuesday 27 September 2005 01:54, Björn wrote:
> Follow-up Comment #5, bug #14616 (project avr-libc):
> The unfortunate thing is, that using volatile is not enough. Even if it
> works for your extremely simple test case: I am having a more complex test
> case example in my application code, where it does *not* work because gcc
> reorders the statements. 

I am discouraged.
I have try the next example with 3 compilers:
        3.3.5, 3.4.4 and 4.0.0
with 2 optimization levels:
        -Os, -O3
All 6 results are fine:  write to volatile is not reordered.


Example is:
#include <avr/io.h>

unsigned int volatile val;

void foo1 (void)
    unsigned char tmp = SREG;
    asm volatile ("cli");
    val = 100;
    SREG = tmp;

void foo2 (void)
    asm volatile ("cli");
    val = 100;
    asm volatile ("sei");

reply via email to

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