bugAVR C Runtime Library - Bugs: bug #37778, _MemoryBarrier() in cpufunc.h...


bug #37778: _MemoryBarrier() in cpufunc.h error on compile

Submitted by:  None
Submitted on:  Mon 19 Nov 2012 09:52:10 PM UTC  
Category:  Header Severity:  3 - Normal
Priority:  9 - Immediate Item Group:  libc code
Status:  In Progress Percent Complete:  50%
Assigned to:  Dmitry Xmelkov <dmix> Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  1.8.0
Fixed Release:  None

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Sun 27 Jan 2013 05:28:17 PM UTC, comment #3:

Question is whether or not NOP should be allowed to be moved across
ordinary memory moves.

For SEI and CLI, for example, I think this is not wanted in general.

NOP is less intrusive than SEI / CLI, of course, but avr-gcc emits
__builtin_avr_nop() with a memory clobber:


Georg-Johann Lay <gjlayde>
Sun 27 Jan 2013 12:58:16 PM UTC, comment #2:

What is the necessity to add memory barrier for _NOP()?
Common usage, like:
PORTB |= 1;
PORTB &= ~1;
is safe, as hardware registers are volatile.

Dmitry Xmelkov <dmix>
Project AdministratorIn charge of this item.
Mon 19 Nov 2012 10:59:22 PM UTC, comment #1:

...and while your are fixing avr/cpufunc.h, don't forget to fix _NOP which reads:

#define NOP() __asm_ __volatile__("nop")

but should get a memory barrier:

#define NOP() __asm_ __volatile__("nop" ::: memory)

Georg-Johann Lay <gjlayde>
Mon 19 Nov 2012 09:52:10 PM UTC, original submission:

The _MemoryBarrier() macro defined in avr/cpufunc.h results in the following error when compiling:
error: expected string literal before ':' token

Currently defined as:
#define MemoryBarrier() __asm_ __volatile__(:::"memory")

Should be:
#define MemoryBarrier() __asm_ __volatile__("":::"memory")



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #30890:  pr37778.patch added by soundararajan (521B - text/x-patch - Fix, as discussed in the comments.)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by soundararajan (Updated the item)
  • -email is unavailable- added by dmix (Posted a comment)
  • -email is unavailable- added by arcanum (Updated the item)
  • -email is unavailable- added by gjlayde (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)



    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-03-14 soundararajan Attached File- => Added pr37778.patch, #30890
    2013-01-27 dmix StatusNone => In Progress
        Percent Complete0% => 50%
        Assigned toNone => dmix
    2012-11-20 arcanum Priority5 - Normal => 9 - Immediate

    Back to the top

    Powered by Savane 3.3