From: Paulo Marques <[EMAIL PROTECTED]>
Dave Hansen wrote:
[...]
You've opened some new cans of worms here, but I'll only make one small
comment
I was afraid of that (the cans of worms, not your comment) ;)
Thanks for noticing the implied smiley. Looking at what I wrote, I'm not
sure it has the tone that was intended...
[...]
static uint16_t atomic_read_16(uint16_t *ptr)
{
uint16_t ret;
cli();
ret = (volatile)(*ptr);
Your cast to volatile here is not only unnecessary, it's wrong.
[...]
But you're actually wrong about the volatile not being needed. Because the
"sei" instruction doesn't claim anything about memory clobbers, without
volatile the compiler would be free to re-order instructions and do the
"sei" before the assignment.
Ouch. I would have thought the "volatile" int the sei macro would have
taken care of this.
This is no theoretical scenario. Just search the archives for previous
threads over this.
I didn't find anything in a quick search, but I believe you.
Would declaring the variable (ret) 'volatile' let us remove the cast?
Regards,
-=Dave
_________________________________________________________________
Get the latest Windows Live Messenger 8.1 Beta version. Join now.
http://ideas.live.com
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list