[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] memcpy() : problem when passing destination pointer
From: |
Paulo Marques |
Subject: |
Re: [avr-gcc-list] memcpy() : problem when passing destination pointer |
Date: |
Wed, 11 Feb 2009 17:32:39 +0000 |
User-agent: |
Thunderbird 2.0.0.19 (X11/20081227) |
Dave Hansen wrote:
> From: address@hidden <mailto:address@hidden>
>
> [...re: volatile use cases...]
>
> In both of these cases, "volatile" is insufficient because it does not
> imply "atomic". In the first case, you need an atomic
> read-modify-write, and in the second you need an atomic read of a wide
> value. In both cases you can achieve that by enclosing the the variable
> access in a cli-sei pair. For example, the latter case can be fixed by
> changing the routine to something like
>
> main() // or "int main(void)", yada yada
> {
> uint32_t ms; // does not need to be volatile
>
> do{ cli(); ms = Milliseconds; sei(); } while (ms < SOME_LIMIT);
> }
No, you can not. You need the macros in util/atomic.h because cli / sei
are not memory barriers and accesses to variables done inside a pair
like that can be moved out by the compiler.
Just search the archives for previous discussions and examples...
--
Paulo Marques
Software Development Department - Grupo PIE, S.A.
Phone: +351 252 290600, Fax: +351 252 290601
Web: www.grupopie.com
"There cannot be a crisis today; my schedule is already full."
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, (continued)
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Graham Davies, 2009/02/10
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Vincent Trouilliez, 2009/02/10
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Joerg Wunsch, 2009/02/10
- RE: [avr-gcc-list] memcpy() : problem when passing destination pointer, Weddington, Eric, 2009/02/10
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Vincent Trouilliez, 2009/02/11
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Bernard Fouché, 2009/02/11
- RE: [avr-gcc-list] memcpy() : problem when passing destination pointer, Dave Hansen, 2009/02/11
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer,
Paulo Marques <=
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Bernard Fouché, 2009/02/11
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, David Kelly, 2009/02/11
- [avr-gcc-list] Re: memcpy() : problem when passing destination pointer, David Brown, 2009/02/11
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Graham Davies, 2009/02/11
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Joerg Wunsch, 2009/02/12
- Re: [avr-gcc-list] memcpy() : problem when passing destination pointer, Pertti Kellomäki, 2009/02/12
- [avr-gcc-list] Re: memcpy() : problem when passing destination pointer, David Brown, 2009/02/12
Message not available
FW: [avr-gcc-list] memcpy() : problem when passing destination pointer, Michael, 2009/02/11